Bug 35758 - [Chromium] Pass the WebFrameClient into WebStorageArea::setItem so we can figure out the routing ID
Summary: [Chromium] Pass the WebFrameClient into WebStorageArea::setItem so we can fig...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Jeremy Orlow
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-04 11:33 PST by Jeremy Orlow
Modified: 2010-04-30 07:19 PDT (History)
2 users (show)

See Also:


Attachments
patch (6.00 KB, patch)
2010-03-04 11:36 PST, Jeremy Orlow
fishd: review-
Details | Formatted Diff | Diff
Addressed comments (5.64 KB, patch)
2010-03-05 03:04 PST, Jeremy Orlow
fishd: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Orlow 2010-03-04 11:33:28 PST
Pass the WebFrameClient into WebStorageArea::setItem so we can figure out the routing ID.
Comment 1 Jeremy Orlow 2010-03-04 11:36:14 PST
Created attachment 50040 [details]
patch
Comment 2 WebKit Review Bot 2010-03-04 11:41:41 PST
Attachment 50040 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebKit/chromium/src/StorageAreaProxy.cpp:44:  Alphabetical sorting problem.  [build/include_order] [4]
WebKit/chromium/src/StorageAreaProxy.cpp:91:  Tab found; better to use spaces  [whitespace/tab] [1]
WebKit/chromium/public/WebStorageArea.h:77:  Use 0 instead of NULL.  [readability/null] [5]
Total errors found: 3 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Fisher (:fishd, Google) 2010-03-04 13:27:14 PST
Comment on attachment 50040 [details]
patch

>  String StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
>  {
> -    bool quotaException = false;
> +    WebKit::WebFrameClient* webFrameClient = 0;
> +    WebKit::WebViewImpl* webViewImpl = static_cast<WebKit::ChromeClientImpl*>(frame->page()->chrome()->client())->webView();
> +    if (webViewImpl) {
> +        WebKit::WebFrameImpl* webFrameImpl = webViewImpl->mainFrameImpl();
> +        if (webFrameImpl)
> +            webFrameClient = webFrameImpl->client();
> +    }  

I think you should just use WebFrameImpl::fromFrame(frame) here, and pass
along the WebFrame instead of the WebFrameClient.  You could also just pass
the WebView since we don't need the WebFrame.

Even better would be to move createLocalStorageNamespace to WebViewClient.
This is a much better solution since it avoids the layering violation of
passing a WebFrame or WebView to the WebKitClient (platform layer).

For just hacking a solution for the release branch, I'm okay with adding
the WebFrame/WebView parameter, but it would really be nice to not make
that be the long-term solution.

-Darin
Comment 4 Jeremy Orlow 2010-03-04 13:42:11 PST
(In reply to comment #3)
> (From update of attachment 50040 [details])
> >  String StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
> >  {
> > -    bool quotaException = false;
> > +    WebKit::WebFrameClient* webFrameClient = 0;
> > +    WebKit::WebViewImpl* webViewImpl = static_cast<WebKit::ChromeClientImpl*>(frame->page()->chrome()->client())->webView();
> > +    if (webViewImpl) {
> > +        WebKit::WebFrameImpl* webFrameImpl = webViewImpl->mainFrameImpl();
> > +        if (webFrameImpl)
> > +            webFrameClient = webFrameImpl->client();
> > +    }  
> 
> I think you should just use WebFrameImpl::fromFrame(frame) here, and pass
> along the WebFrame instead of the WebFrameClient.  You could also just pass
> the WebView since we don't need the WebFrame.
> 
> Even better would be to move createLocalStorageNamespace to WebViewClient.
> This is a much better solution since it avoids the layering violation of
> passing a WebFrame or WebView to the WebKitClient (platform layer).
> 
> For just hacking a solution for the release branch, I'm okay with adding
> the WebFrame/WebView parameter, but it would really be nice to not make
> that be the long-term solution.

Moving createLocalStorageNamespace does not help or make sense since the LocalStorageNamespace is created on first use and stored with the page group.  Thus it doesn't tell us which frame/WebView is currently using it.

Passing in a WebFrame doesn't work because only the WebFrameImpl (which is private to the WebKit API) is the only way to get at the WebFrameClient*.  As far as I can tell, we can't get a WebFrameClient from a WebView either.

I believe using WebFrameImpl::fromFrame() should work and will clean up the code though.  But besides that, I don't see how any of these suggestions are workable.  If you have a second to look at this in depth and see if there is a way to simplify it, I'd greatly appreciate it, but as far as I can tell, fromFrame() is the only thing I can change here.  I don't believe I technically have any layering violations either since WebFrameClient is in public.  Am I missing anything?
Comment 5 Darin Fisher (:fishd, Google) 2010-03-04 14:47:27 PST
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 50040 [details] [details])
> > >  String StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
> > >  {
> > > -    bool quotaException = false;
> > > +    WebKit::WebFrameClient* webFrameClient = 0;
> > > +    WebKit::WebViewImpl* webViewImpl = static_cast<WebKit::ChromeClientImpl*>(frame->page()->chrome()->client())->webView();
> > > +    if (webViewImpl) {
> > > +        WebKit::WebFrameImpl* webFrameImpl = webViewImpl->mainFrameImpl();
> > > +        if (webFrameImpl)
> > > +            webFrameClient = webFrameImpl->client();
> > > +    }  
> > 
> > I think you should just use WebFrameImpl::fromFrame(frame) here, and pass
> > along the WebFrame instead of the WebFrameClient.  You could also just pass
> > the WebView since we don't need the WebFrame.
> > 
> > Even better would be to move createLocalStorageNamespace to WebViewClient.
> > This is a much better solution since it avoids the layering violation of
> > passing a WebFrame or WebView to the WebKitClient (platform layer).
> > 
> > For just hacking a solution for the release branch, I'm okay with adding
> > the WebFrame/WebView parameter, but it would really be nice to not make
> > that be the long-term solution.
> 
> Moving createLocalStorageNamespace does not help or make sense since the
> LocalStorageNamespace is created on first use and stored with the page group. 
> Thus it doesn't tell us which frame/WebView is currently using it.

I see.


> Passing in a WebFrame doesn't work because only the WebFrameImpl (which is
> private to the WebKit API) is the only way to get at the WebFrameClient*.  As
> far as I can tell, we can't get a WebFrameClient from a WebView either.

No, no... in Chromium land, you are trying to get to a RenderView.  RenderView
has a static FromWebView method that you can use to map from a WebView to a
RenderView.

Please note that it is valid to use the WebKit API with a null WebFrameClient
if you are not interested in any of the WebFrameClient methods.  Same goes for
other Client interfaces (except for WebKitClient).  This is why it is better to
pass around the WebFrame or WebView instead.


> fromFrame() is the only thing I can change here.  I don't believe I technically
> have any layering violations either since WebFrameClient is in public.  Am I
> missing anything?

WebKitClient is supposed to correspond to platform services, which should not be
parameterized by a frame.  If we need to make per-frame queries, then that is
what WebFrameClient is for.

Another way to fix this problem is to add a WebFrameClient method named
setStorageItem (or something like that), but that seems a little strange.
Comment 6 Darin Fisher (:fishd, Google) 2010-03-04 20:11:09 PST
I thought about this some more, and I'm fine with passing the WebFrame as a parameter to WebStorageArea methods.
Comment 7 Jeremy Orlow 2010-03-05 03:04:55 PST
Created attachment 50094 [details]
Addressed comments

I guess using the WebView is better, though it seems less efficient having to rely on the map, I guess it doesn't really matter.

All the other comments have been addressed.
Comment 8 Darin Fisher (:fishd, Google) 2010-03-05 10:49:50 PST
Comment on attachment 50094 [details]
Addressed comments

> +    virtual void setItem(const WebString& key, const WebString& newValue, const WebURL& url, Result& result, WebString& oldValue, WebView*)

nit: it occurred to me that passing the WebView loses information.  passing the WebFrame
might be better, although it doesn't matter to chromium.

r=me
Comment 9 Jeremy Orlow 2010-03-08 04:29:52 PST
Landed in 55659