Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Issue 2446553002: Support Service Worker NavigationPreload with PlzNavigate. (Closed)

Created:
4 years, 1 month ago by horo
Modified:
4 years, 1 month ago
Reviewers:
falken, clamy, alexmos, nasko, piman
CC:
chromium-reviews, michaeln, jsbell+serviceworker_chromium.org, serviceworker-reviews, creis+watch_chromium.org, mlamouri+watch-content_chromium.org, shimazu+serviceworker_chromium.org, nasko+codewatch_chromium.org, jam, kinuko+serviceworker, nhiroki, blink-reviews-bindings_chromium.org, haraken, dglazkov+blink, blink-reviews-api_chromium.org, darin-cc_chromium.org, blink-reviews, horo+watch_chromium.org, kinuko+watch, tzik, falken+watch_chromium.org, blink-worker-reviews_chromium.org, clamy, nasko
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Support Service Worker NavigationPreload with PlzNavigate. When ServiceWorkerFetchDispatcher sends the navigation preload request, it uses MojoURLLoaderFactoryGetter to get the mojom::URLLoaderFactory which is associated with the RenderProcessHost. This MojoURLLoaderFactoryGetter is created in RenderProcessHostImpl::CreateMessageFilters() and passed to ServiceWorkerDispatcherHost. So ServiceWorkerFetchDispatcher can get it from ServiceWorkerDispatcherHost via ServiceWorkerProviderHost and ServiceWorkerControlleeRequestHandler and ServiceWorkerURLRequestJob. But if PlzNavigate is enabled, when ServiceWorkerProviderHost::PreCreateNavigationHost() creates a ServiceWorkerProviderHost, the ServiceWorkerProviderHost is not associated with any ServiceWorkerDispatcherHost. So ServiceWorkerFetchDispatcher can't get the MojoURLLoaderFactoryGetter. To solve this problem, this CL introduces RenderProcessHost::CreateURLLoaderFactoryGetter() and: - NavigationRequest::OnStartChecksComplete() creates a MojoURLLoaderFactoryGetter from the navigating_frame_host's process and pass it to ServiceWorkerNavigationHandleCore. - ServiceWorkerRequestHandler::InitializeForNavigation() gets the MojoURLLoaderFactoryGetter from ServiceWorkerNavigationHandleCore and pass it to ServiceWorkerProviderHost. - So when ServiceWorkerProviderHost::CreateRequestHandler() is called, ServiceWorkerProviderHost must have a MojoURLLoaderFactoryGetter. BUG=649558 TEST=content_browsertests --enable-browser-side-navigation --gtest_filter=ServiceWorkerBrowserTest/ServiceWorkerNavigationPreloadTest.* CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Patch Set 1 #

Total comments: 3

Patch Set 2 : remove unnecessary comment #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+69 lines, -29 lines) Patch
M content/browser/frame_host/navigation_handle_impl.h View 2 chunks +3 lines, -1 line 0 comments Download
M content/browser/frame_host/navigation_handle_impl.cc View 1 chunk +4 lines, -3 lines 0 comments Download
M content/browser/frame_host/navigation_request.cc View 1 chunk +3 lines, -1 line 0 comments Download
M content/browser/renderer_host/render_process_host_impl.h View 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/renderer_host/render_process_host_impl.cc View 1 2 chunks +7 lines, -2 lines 2 comments Download
M content/browser/service_worker/service_worker_fetch_dispatcher.cc View 1 chunk +0 lines, -5 lines 0 comments Download
M content/browser/service_worker/service_worker_navigation_handle.h View 2 chunks +3 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_navigation_handle.cc View 1 chunk +4 lines, -3 lines 0 comments Download
M content/browser/service_worker/service_worker_navigation_handle_core.h View 3 chunks +7 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_navigation_handle_core.cc View 1 chunk +5 lines, -2 lines 0 comments Download
M content/browser/service_worker/service_worker_provider_host.h View 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_provider_host.cc View 6 chunks +14 lines, -7 lines 0 comments Download
M content/browser/service_worker/service_worker_request_handler.cc View 1 chunk +1 line, -0 lines 0 comments Download
M content/public/browser/render_process_host.h View 1 5 chunks +8 lines, -0 lines 0 comments Download
M content/public/test/mock_render_process_host.h View 1 chunk +1 line, -0 lines 0 comments Download
M content/public/test/mock_render_process_host.cc View 1 chunk +5 lines, -0 lines 0 comments Download
M testing/buildbot/filters/browser-side-navigation.linux.content_browsertests.filter View 1 chunk +0 lines, -3 lines 0 comments Download

Messages

Total messages: 51 (38 generated)
horo
falken@ Could you please review this?
4 years, 1 month ago (2016-10-26 17:34:38 UTC) #25
falken
this lgtm https://codereview.chromium.org/2446553002/diff/100001/content/public/browser/render_process_host.h File content/public/browser/render_process_host.h (right): https://codereview.chromium.org/2446553002/diff/100001/content/public/browser/render_process_host.h#newcode340 content/public/browser/render_process_host.h:340: // used for fetching navigation preload request. ...
4 years, 1 month ago (2016-10-27 02:07:49 UTC) #26
horo
https://codereview.chromium.org/2446553002/diff/100001/content/public/browser/render_process_host.h File content/public/browser/render_process_host.h (right): https://codereview.chromium.org/2446553002/diff/100001/content/public/browser/render_process_host.h#newcode340 content/public/browser/render_process_host.h:340: // used for fetching navigation preload request. On 2016/10/27 ...
4 years, 1 month ago (2016-10-27 02:20:27 UTC) #30
horo
clamy@ Could you please review this?
4 years, 1 month ago (2016-10-27 02:25:56 UTC) #34
falken
https://codereview.chromium.org/2446553002/diff/100001/content/public/browser/render_process_host.h File content/public/browser/render_process_host.h (right): https://codereview.chromium.org/2446553002/diff/100001/content/public/browser/render_process_host.h#newcode340 content/public/browser/render_process_host.h:340: // used for fetching navigation preload request. On 2016/10/27 ...
4 years, 1 month ago (2016-10-27 02:27:56 UTC) #35
horo
Ah, clamy@ is ooo until Nov 2. alexmos@ Could you please review content/browser/frame_host/OWNERS?
4 years, 1 month ago (2016-10-27 02:30:20 UTC) #37
alexmos
frame_host LGTM. I'm not as familiar with service worker internals, so this is mostly a ...
4 years, 1 month ago (2016-10-28 01:13:09 UTC) #40
horo
nasko@ Could you please review content/browser/renderer_host/render_process_host_impl.* content/public/browser/render_process_host.h content/public/test/mock_render_process_host.*?
4 years, 1 month ago (2016-10-28 01:48:20 UTC) #43
horo
piman@ Could you please review content/browser/renderer_host/render_process_host_impl.* content/public/browser/render_process_host.h content/public/test/mock_render_process_host.*?
4 years, 1 month ago (2016-10-31 08:20:15 UTC) #47
horo
https://codereview.chromium.org/2446553002/diff/120001/content/browser/renderer_host/render_process_host_impl.cc File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2446553002/diff/120001/content/browser/renderer_host/render_process_host_impl.cc#newcode1414 content/browser/renderer_host/render_process_host_impl.cc:1414: weak_factory_.GetWeakPtr()); WeakPtr is not thread safe. So we should ...
4 years, 1 month ago (2016-10-31 14:50:32 UTC) #48
piman
https://codereview.chromium.org/2446553002/diff/120001/content/browser/renderer_host/render_process_host_impl.cc File content/browser/renderer_host/render_process_host_impl.cc (right): https://codereview.chromium.org/2446553002/diff/120001/content/browser/renderer_host/render_process_host_impl.cc#newcode1414 content/browser/renderer_host/render_process_host_impl.cc:1414: weak_factory_.GetWeakPtr()); On 2016/10/31 14:50:32, horo wrote: > WeakPtr is ...
4 years, 1 month ago (2016-10-31 20:43:25 UTC) #49
horo
On 2016/10/31 20:43:25, piman wrote: > https://codereview.chromium.org/2446553002/diff/120001/content/browser/renderer_host/render_process_host_impl.cc > File content/browser/renderer_host/render_process_host_impl.cc (right): > > https://codereview.chromium.org/2446553002/diff/120001/content/browser/renderer_host/render_process_host_impl.cc#newcode1414 > ...
4 years, 1 month ago (2016-10-31 22:09:42 UTC) #50
horo
4 years, 1 month ago (2016-11-01 10:15:40 UTC) #51
Message was sent while issue was closed.
On 2016/10/31 22:09:42, horo wrote:
> On 2016/10/31 20:43:25, piman wrote:
> >
>
https://codereview.chromium.org/2446553002/diff/120001/content/browser/render...
> > File content/browser/renderer_host/render_process_host_impl.cc (right):
> > 
> >
>
https://codereview.chromium.org/2446553002/diff/120001/content/browser/render...
> > content/browser/renderer_host/render_process_host_impl.cc:1414:
> > weak_factory_.GetWeakPtr());
> > On 2016/10/31 14:50:32, horo wrote:
> > > WeakPtr is not thread safe.
> > > So we should not pass the MojoURLLoaderFactoryGetter to the IO thread.
> > >
> >
>
http://www.chromium.org/developers/design-documents/threading#base_WeakPtr_an...
> > > 
> > > I will create another CL to avoid this problem.
> > > 
> > > Sorry for confusion.
> > 
> > I'll wait for the update before a full review. Just one thing: if there are
> > specific expectations about the value returned from
> CreateURLLoaderFactoryGetter
> > (i.e. used on a different thread than where it's queried?), can you document
> > that in the API?
> > 
> > FYI, WeakPtr is not generally thread-safe, however it can be copied to other
> > threads - I don't know if that matters to you. The restriction is that it
can
> > only be dereferenced  on the same thread as it gets cancelled (i.e. the
thread
> > the WeakPtrFactory gets destroyed).
> 
> ServiceWorkerFetchDispatcher::MaybeStartNavigationPreload() executes the
> MojoURLLoaderFactoryGetter on the IO thread.
> But the WeakPtr is dereferenced on the UI thread in the destructor of
> RenderProcessHostImpl.
> So it is the problem.

I created two CLs.
- Stop using MojoURLLoaderFactoryGetter
  https://codereview.chromium.org/2465813003/
- Support Service Worker NavigationPreload with PlzNavigate (without
MojoURLLoaderFactoryGetter)
  https://codereview.chromium.org/2460223003/

Powered by Google App Engine
This is Rietveld 408576698