Bug 102151 - Consolidate FrameLoader::load() into one function taking a FrameLoadRequest
Summary: Consolidate FrameLoader::load() into one function taking a FrameLoadRequest
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: James Simonsen
URL:
Keywords:
Depends on: 102834 103371 103379
Blocks: 84883
  Show dependency treegraph
 
Reported: 2012-11-13 16:35 PST by James Simonsen
Modified: 2012-11-27 17:08 PST (History)
15 users (show)

See Also:


Attachments
Patch (41.93 KB, patch)
2012-11-13 16:40 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (43.01 KB, patch)
2012-11-13 17:50 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (42.15 KB, patch)
2012-11-14 15:22 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (42.16 KB, patch)
2012-11-14 16:22 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (42.13 KB, patch)
2012-11-15 16:29 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (56.99 KB, patch)
2012-11-19 19:52 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (56.32 KB, patch)
2012-11-20 20:27 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (56.46 KB, patch)
2012-11-21 15:45 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch for landing (50.49 KB, patch)
2012-11-26 15:33 PST, James Simonsen
no flags Details | Formatted Diff | Diff
Patch (50.35 KB, patch)
2012-11-27 16:13 PST, James Simonsen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Simonsen 2012-11-13 16:35:08 PST
Consolidate FrameLoader::load() into one function taking a FrameLoadRequest
Comment 1 James Simonsen 2012-11-13 16:40:38 PST
Created attachment 174026 [details]
Patch
Comment 2 Early Warning System Bot 2012-11-13 16:51:24 PST
Comment on attachment 174026 [details]
Patch

Attachment 174026 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/14833048
Comment 3 EFL EWS Bot 2012-11-13 17:14:19 PST
Comment on attachment 174026 [details]
Patch

Attachment 174026 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14817853
Comment 4 Build Bot 2012-11-13 17:16:22 PST
Comment on attachment 174026 [details]
Patch

Attachment 174026 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14821760
Comment 5 James Simonsen 2012-11-13 17:50:09 PST
Created attachment 174037 [details]
Patch
Comment 6 Darin Adler 2012-11-13 17:56:23 PST
Comment on attachment 174037 [details]
Patch

It’s neat having only one function to call. But almost every single call site is getting significantly more complex and uglier here. Especially the long expression to fetch the security origin. Is there any way to do this without uglifying so many different call sites?
Comment 7 James Simonsen 2012-11-13 18:04:40 PST
(In reply to comment #6)
> (From update of attachment 174037 [details])
> It’s neat having only one function to call. But almost every single call site is getting significantly more complex and uglier here. Especially the long expression to fetch the security origin. Is there any way to do this without uglifying so many different call sites?

That particular issue could be fixed by deriving the SecurityOrigin from the Frame. That just needs a new constructor for FrameLoadRequest.

I did not find a single instance where lockHistory was true. Did I miss it? If not, that could be removed.

With those changes, a lot of the call sites could become one-liners ala:

m_frame->loader()->load(FrameLoadRequest(m_frame, resourceRequest));
Comment 8 Build Bot 2012-11-13 18:11:40 PST
Comment on attachment 174037 [details]
Patch

Attachment 174037 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14823621
Comment 9 Adam Barth 2012-11-13 18:29:04 PST
> m_frame->loader()->load(FrameLoadRequest(m_frame, resourceRequest));

That might improve the call sites.
Comment 10 EFL EWS Bot 2012-11-13 19:07:38 PST
Comment on attachment 174037 [details]
Patch

Attachment 174037 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14665656
Comment 11 EFL EWS Bot 2012-11-13 19:25:44 PST
Comment on attachment 174037 [details]
Patch

Attachment 174037 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14838062
Comment 12 James Simonsen 2012-11-14 15:22:18 PST
Created attachment 174269 [details]
Patch
Comment 13 James Simonsen 2012-11-14 15:25:45 PST
(In reply to comment #9)
> > m_frame->loader()->load(FrameLoadRequest(m_frame, resourceRequest));
> 
> That might improve the call sites.

Done. It cleaned up the most common case. We could add similar constructors for the other two cases: plugins (which pass a frame name) and substitute data. Let me know.
Comment 14 Early Warning System Bot 2012-11-14 15:28:52 PST
Comment on attachment 174269 [details]
Patch

Attachment 174269 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/14837493
Comment 15 Early Warning System Bot 2012-11-14 15:37:49 PST
Comment on attachment 174269 [details]
Patch

Attachment 174269 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/14834497
Comment 16 EFL EWS Bot 2012-11-14 16:01:49 PST
Comment on attachment 174269 [details]
Patch

Attachment 174269 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14848100
Comment 17 Build Bot 2012-11-14 16:19:13 PST
Comment on attachment 174269 [details]
Patch

Attachment 174269 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14843305
Comment 18 James Simonsen 2012-11-14 16:22:25 PST
Created attachment 174282 [details]
Patch
Comment 19 Early Warning System Bot 2012-11-14 16:31:18 PST
Comment on attachment 174282 [details]
Patch

Attachment 174282 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/14848115
Comment 20 Early Warning System Bot 2012-11-14 16:35:49 PST
Comment on attachment 174282 [details]
Patch

Attachment 174282 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/14834516
Comment 21 Build Bot 2012-11-14 21:36:40 PST
Comment on attachment 174282 [details]
Patch

Attachment 174282 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14832660
Comment 22 Build Bot 2012-11-15 05:21:48 PST
Comment on attachment 174282 [details]
Patch

Attachment 174282 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14832819
Comment 23 James Simonsen 2012-11-15 16:29:55 PST
Created attachment 174552 [details]
Patch
Comment 24 Adam Barth 2012-11-15 17:47:52 PST
Comment on attachment 174552 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=174552&action=review

> Source/WebCore/loader/FrameLoadRequest.h:30
> +#include "Document.h"
> +#include "Frame.h"

These are some large headers.  Do we really need to include them, or can we forward declare the classes?

> Source/WebCore/loader/FrameLoadRequest.h:69
> +    FrameLoadRequest(Frame* frame, const ResourceRequest& resourceRequest)
> +        : m_requester(frame->document()->securityOrigin())
> +        , m_resourceRequest(resourceRequest)
> +        , m_lockHistory(false)
> +        , m_shouldCheckNewWindowPolicy(false)
>      {
>      }

Maybe we should move this constructor out of line?

> Source/WebKit/blackberry/Api/WebPage.cpp:753
> +    frameRequest.setSubstituteData(substituteData);

I wonder if it would be worth adding an optional SubstituteData parameter to the above given that you've got this pattern in a bunch of places.

> Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp:137
> +    request.setSubstituteData(SubstituteData(buf, String("text/html"), String("UTF-8"), KURL()));

There's no need to call the String constructor explicitly.  The compiler should let you call it implicitly.

Also, I would probably rename buf to buffer and len to length.  This is really a lot of work to load the empty string!

> Source/WebKit/mac/Plugins/WebPluginController.mm:407
> +        frameRequest.setShouldCheckNewWindowPolicy(true);

I like that we don't have these mysterious "false" parameters anymore.
Comment 25 Build Bot 2012-11-15 19:46:24 PST
Comment on attachment 174552 [details]
Patch

Attachment 174552 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14857465
Comment 26 James Simonsen 2012-11-19 19:52:13 PST
Created attachment 175119 [details]
Patch
Comment 27 James Simonsen 2012-11-19 19:53:38 PST
(In reply to comment #24)
> (From update of attachment 174552 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=174552&action=review
> 
> > Source/WebCore/loader/FrameLoadRequest.h:30
> > +#include "Document.h"
> > +#include "Frame.h"
> 
> These are some large headers.  Do we really need to include them, or can we forward declare the classes?

Done.

> 
> > Source/WebCore/loader/FrameLoadRequest.h:69
> > +    FrameLoadRequest(Frame* frame, const ResourceRequest& resourceRequest)
> > +        : m_requester(frame->document()->securityOrigin())
> > +        , m_resourceRequest(resourceRequest)
> > +        , m_lockHistory(false)
> > +        , m_shouldCheckNewWindowPolicy(false)
> >      {
> >      }
> 
> Maybe we should move this constructor out of line?

Done.

> 
> > Source/WebKit/blackberry/Api/WebPage.cpp:753
> > +    frameRequest.setSubstituteData(substituteData);
> 
> I wonder if it would be worth adding an optional SubstituteData parameter to the above given that you've got this pattern in a bunch of places.

Done.

> 
> > Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp:137
> > +    request.setSubstituteData(SubstituteData(buf, String("text/html"), String("UTF-8"), KURL()));
> 
> There's no need to call the String constructor explicitly.  The compiler should let you call it implicitly.

Done.

> 
> Also, I would probably rename buf to buffer and len to length.  This is really a lot of work to load the empty string!

Done and agreed.

> 
> > Source/WebKit/mac/Plugins/WebPluginController.mm:407
> > +        frameRequest.setShouldCheckNewWindowPolicy(true);
> 
> I like that we don't have these mysterious "false" parameters anymore.

Agreed.

I'll land this after all the EWS bots go green. It changes a bunch of port-specific code.
Comment 28 WebKit Review Bot 2012-11-20 10:31:16 PST
Comment on attachment 175119 [details]
Patch

Clearing flags on attachment: 175119

Committed r135295: <http://trac.webkit.org/changeset/135295>
Comment 29 WebKit Review Bot 2012-11-20 10:31:23 PST
All reviewed patches have been landed.  Closing bug.
Comment 30 Adam Barth 2012-11-20 11:23:50 PST
Comment on attachment 175119 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=175119&action=review

> Source/WebKit/blackberry/Api/WebPage.cpp:753
> +    FrameLoadRequest frameRequest(m_mainFrame, request, substituteData);
> +    m_mainFrame->loader()->load(frameRequest);

These lines can be combined

> Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp:755
> +    FrameLoadRequest frameRequest(m_frame, originalRequest, errorData);
> +    m_frame->loader()->load(frameRequest);

ditto

> Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp:137
> +    FrameLoadRequest request(webFrame->frame(), ResourceRequest(url), SubstituteData(buffer, "text/html", "UTF-8", KURL()));
> +    webFrame->frame()->loader()->load(request);

ditto

> Source/WebKit/efl/ewk/ewk_frame.cpp:421
> +    WebCore::FrameLoadRequest frameRequest(smartData->frame, request, substituteData);
> +    smartData->frame->loader()->load(frameRequest);

ditto

> Source/WebKit/gtk/webkit/webkitwebframe.cpp:717
> +    FrameLoadRequest frameRequest(coreFrame, request, substituteData);
> +    coreFrame->loader()->load(frameRequest);

ditto

> Source/WebKit/mac/WebView/WebFrame.mm:1405
> +    FrameLoadRequest frameRequest(_private->coreFrame, request, substituteData);
> +    _private->coreFrame->loader()->load(frameRequest);

ditto

> Source/WebKit/qt/Api/qwebframe.cpp:891
> +    FrameLoadRequest frameRequest(d->frame, request, substituteData);
> +    d->frame->loader()->load(frameRequest);

ditto

> Source/WebKit/qt/Api/qwebframe.cpp:922
> +    FrameLoadRequest frameRequest(d->frame, request, substituteData);
> +    d->frame->loader()->load(frameRequest);

ditto

> Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp:980
> +    FrameLoadRequest frameRequest(coreFrame, request, substituteData);
> +    coreFrame->loader()->load(frameRequest);

ditto

> Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp:1169
> +    WebCore::FrameLoadRequest frameRequest(m_frame, request, substituteData);
> +    m_frame->loader()->load(frameRequest);

ditto

> Source/WebKit/win/WebFrame.cpp:584
> +        FrameLoadRequest frameRequest(coreFrame, request, substituteData);
> +        coreFrame->loader()->load(frameRequest);

ditto

> Source/WebKit/wx/WebFrame.cpp:328
> +        WebCore::FrameLoadRequest frameRequest(m_impl->frame, WebCore::ResourceRequest(url), substituteData);
> +        m_impl->frame->loader()->load(frameRequest);

ditto

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:837
> +    FrameLoadRequest frameRequest(m_mainFrame->coreFrame(), request, substituteData);
> +    m_mainFrame->coreFrame()->loader()->load(frameRequest);

ditto
Comment 31 James Simonsen 2012-11-20 11:27:47 PST
(In reply to comment #30)
> (From update of attachment 175119 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=175119&action=review
> 
> > Source/WebKit/blackberry/Api/WebPage.cpp:753
> > +    FrameLoadRequest frameRequest(m_mainFrame, request, substituteData);
> > +    m_mainFrame->loader()->load(frameRequest);
> 
> These lines can be combined

I'll get these in a followup patch. There are still a few other load* functions (loadURLIntoChildFrame, loadFrameRequest) that should be combined. I'll do it then.
Comment 32 Adam Barth 2012-11-20 11:29:37 PST
Thanks!
Comment 33 WebKit Review Bot 2012-11-20 13:57:23 PST
Re-opened since this is blocked by bug 102834
Comment 34 James Simonsen 2012-11-20 20:27:28 PST
Created attachment 175329 [details]
Patch
Comment 35 James Simonsen 2012-11-20 20:30:42 PST
I removed the ASSERT that caused this to be reverted. The ASSERT was new in this patch and I only added it because I thought it was a good, paranoid thing to do. But, at least with Chrome's DRT, the baseURL passed in is empty, so it was causing the ASSERT to fail.

Since I'm doing another rev on this patch anyway, I also worked in the change to make most of callsites one-liners.
Comment 36 Early Warning System Bot 2012-11-20 20:36:09 PST
Comment on attachment 175329 [details]
Patch

Attachment 175329 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/14907845
Comment 37 EFL EWS Bot 2012-11-20 20:44:27 PST
Comment on attachment 175329 [details]
Patch

Attachment 175329 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14905839
Comment 38 Build Bot 2012-11-20 20:56:53 PST
Comment on attachment 175329 [details]
Patch

Attachment 175329 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14916851
Comment 39 Build Bot 2012-11-20 21:04:17 PST
Comment on attachment 175329 [details]
Patch

Attachment 175329 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14901807
Comment 40 Csaba Osztrogonác 2012-11-20 21:36:59 PST
(In reply to comment #33)
> Re-opened since this is blocked by bug 102834

And it made plugin related tests crash on Qt:
http://build.webkit.sed.hu/builders/x86-64%20Linux%20Qt%20Release/builds/45265

I think it is unrelated to the assertion mentioned, because it is a relase tester bot.
Comment 41 James Simonsen 2012-11-21 15:45:59 PST
Created attachment 175539 [details]
Patch
Comment 42 Adam Barth 2012-11-21 22:48:11 PST
> And it made plugin related tests crash on Qt:
> http://build.webkit.sed.hu/builders/x86-64%20Linux%20Qt%20Release/builds/45265

^^^ James, did you see this failure with the previous patch?
Comment 43 James Simonsen 2012-11-26 13:13:02 PST
(In reply to comment #42)
> > And it made plugin related tests crash on Qt:
> > http://build.webkit.sed.hu/builders/x86-64%20Linux%20Qt%20Release/builds/45265
> 
> ^^^ James, did you see this failure with the previous patch?

Yeah, I fixed that too. Sorry for not updating the bug with the status before going on vacation.

I also made the callsites one-liners as you'd requested earlier. I will merge and land this again later today.
Comment 44 James Simonsen 2012-11-26 15:33:10 PST
Created attachment 176094 [details]
Patch for landing
Comment 45 WebKit Review Bot 2012-11-26 16:18:36 PST
Comment on attachment 176094 [details]
Patch for landing

Clearing flags on attachment: 176094

Committed r135786: <http://trac.webkit.org/changeset/135786>
Comment 46 WebKit Review Bot 2012-11-26 16:18:45 PST
All reviewed patches have been landed.  Closing bug.
Comment 47 Roger Fong 2012-11-26 18:34:39 PST
Caused some tests to fail on Windows port:
http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r135786%20(30279)/results.html

plugins/get-file-url.html
plugins/geturl-replace-query.html
http/tests/plugins/post-url-file.html

They all seem to time out now.
Comment 48 Brady Eidson 2012-11-26 20:58:24 PST
(In reply to comment #47)
> Caused some tests to fail on Windows port:
> http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r135786%20(30279)/results.html
> 
> plugins/get-file-url.html
> plugins/geturl-replace-query.html
> http/tests/plugins/post-url-file.html
> 
> They all seem to time out now.

Then we need to roll this out then, right?
Comment 49 Csaba Osztrogonác 2012-11-26 22:42:13 PST
(In reply to comment #47)
> Caused some tests to fail on Windows port:
> http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r135786%20(30279)/results.html
> 
> plugins/get-file-url.html
> plugins/geturl-replace-query.html
> http/tests/plugins/post-url-file.html
> 
> They all seem to time out now.

Same tests started to timeout on Qt.
Comment 50 Csaba Osztrogonác 2012-11-27 01:42:43 PST
Rolled out by http://trac.webkit.org/changeset/135837
Comment 51 James Simonsen 2012-11-27 16:13:20 PST
Created attachment 176358 [details]
Patch
Comment 52 James Simonsen 2012-11-27 16:14:54 PST
Okay, I built the Qt port and debugged this. I think we're good to go now. I've tested it on Chrome, Mac, and Qt. No wonder nobody had done this earlier.
Comment 53 Adam Barth 2012-11-27 16:19:46 PST
Comment on attachment 176358 [details]
Patch

ok
Comment 54 WebKit Review Bot 2012-11-27 17:08:26 PST
Comment on attachment 176358 [details]
Patch

Clearing flags on attachment: 176358

Committed r135952: <http://trac.webkit.org/changeset/135952>
Comment 55 WebKit Review Bot 2012-11-27 17:08:36 PST
All reviewed patches have been landed.  Closing bug.