Summary: | [GTK] Add destroy notify for register_uri_scheme | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Jesse van den Kieboom <jessevdk> | ||||||
Component: | WebKitGTK | Assignee: | Nobody <webkit-unassigned> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | cgarcia, gustavo, mrobinson, webkit.review.bot | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Attachments: |
|
Description
Jesse van den Kieboom
2012-08-17 01:59:55 PDT
Created attachment 159050 [details]
Add destroy notify
Comment on attachment 159050 [details] Add destroy notify View in context: https://bugs.webkit.org/attachment.cgi?id=159050&action=review Thank you very much for the patch. Please read this http://www.webkit.org/coding/contributing.html Patches should include a ChangeLog and you should set the r flag to ? to ask for a review. > Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp:68 > + if (destroyNotify) > + { > + destroyNotify(userData); > + } Don't see use braces for one-line ifs, see http://www.webkit.org/coding/coding-style.html > Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp:394 > + * @destroy_notify: destroy notify for @user_data I prefer to call this something like user_data_destroy_func > Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp:568 > - WebKitURISchemeHandler handler = context->priv->uriSchemeHandlers.get(webkit_uri_scheme_request_get_scheme(request)); > + WebKitURISchemeHandler const &handler = context->priv->uriSchemeHandlers.get(webkit_uri_scheme_request_get_scheme(request)); Unfortunately this is not enough, when the handler is set to the HashMap it's also copied, so the destructor will be called in that case too. So, we have several options here: a) Make WebKitURISchemeHandler a refcounted class instead of a struct. b) Ierate all handlers in webkitWebContextFinalize to call destroy_notify function probably a) is easier, you need to convert it into a class deriving from RefCounted class WebKitURISchemeHandler: public RefCounted<WebKitURISchemeHandler> { and then change the HashMap definition to: typedef HashMap<String, RefPtr<WebKitURISchemeHandler> > URISchemeHandlerMap; > Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:165 > - webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this); > + webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0); Ideally the destroy notify should also be tested in the unit tests, but in this case it's not so easy, because the web context is destroyed when all tests have finished. Jesse, are you working on a new patch for this? Since it's an api change I would like to land this patch before the release. Created attachment 159644 [details]
Updated patch
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API Comment on attachment 159644 [details]
Updated patch
LGTM
Comment on attachment 159644 [details] Updated patch View in context: https://bugs.webkit.org/attachment.cgi?id=159644&action=review > Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:168 > - webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this); > + webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0); I think Carlos wanted to have the test checking the destroy notify callback. (In reply to comment #7) > (From update of attachment 159644 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=159644&action=review > > > Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:168 > > - webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this); > > + webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0); > > I think Carlos wanted to have the test checking the destroy notify callback. Yes, but unfortunately it's not possible: "Ideally the destroy notify should also be tested in the unit tests, but in this case it's not so easy, because the web context is destroyed when all tests have finished." Comment on attachment 159644 [details]
Updated patch
Please wait EWS before landing :)
(In reply to comment #9) > (From update of attachment 159644 [details]) > Please wait EWS before landing :) Sure, thanks reviewing! Committed r126152: <http://trac.webkit.org/changeset/126152> |