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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "content/browser/loader/redirect_to_file_resource_handler.h" 46 #include "content/browser/loader/redirect_to_file_resource_handler.h"
47 #include "content/browser/loader/resource_message_filter.h" 47 #include "content/browser/loader/resource_message_filter.h"
48 #include "content/browser/loader/resource_request_info_impl.h" 48 #include "content/browser/loader/resource_request_info_impl.h"
49 #include "content/browser/loader/stream_resource_handler.h" 49 #include "content/browser/loader/stream_resource_handler.h"
50 #include "content/browser/loader/sync_resource_handler.h" 50 #include "content/browser/loader/sync_resource_handler.h"
51 #include "content/browser/loader/throttling_resource_handler.h" 51 #include "content/browser/loader/throttling_resource_handler.h"
52 #include "content/browser/loader/upload_data_stream_builder.h" 52 #include "content/browser/loader/upload_data_stream_builder.h"
53 #include "content/browser/renderer_host/render_view_host_delegate.h" 53 #include "content/browser/renderer_host/render_view_host_delegate.h"
54 #include "content/browser/renderer_host/render_view_host_impl.h" 54 #include "content/browser/renderer_host/render_view_host_impl.h"
55 #include "content/browser/resource_context_impl.h" 55 #include "content/browser/resource_context_impl.h"
56 #include "content/browser/service_worker/service_worker_provider_host.h"
56 #include "content/browser/service_worker/service_worker_request_handler.h" 57 #include "content/browser/service_worker/service_worker_request_handler.h"
57 #include "content/browser/streams/stream.h" 58 #include "content/browser/streams/stream.h"
58 #include "content/browser/streams/stream_context.h" 59 #include "content/browser/streams/stream_context.h"
59 #include "content/browser/streams/stream_registry.h" 60 #include "content/browser/streams/stream_registry.h"
60 #include "content/browser/web_contents/web_contents_impl.h" 61 #include "content/browser/web_contents/web_contents_impl.h"
61 #include "content/common/appcache_interfaces.h" 62 #include "content/common/appcache_interfaces.h"
62 #include "content/common/navigation_params.h" 63 #include "content/common/navigation_params.h"
63 #include "content/common/resource_messages.h" 64 #include "content/common/resource_messages.h"
64 #include "content/common/site_isolation_policy.h" 65 #include "content/common/site_isolation_policy.h"
65 #include "content/common/ssl_status_serialization.h" 66 #include "content/common/ssl_status_serialization.h"
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 1354
1354 // Initialize the service worker handler for the request. We don't use 1355 // Initialize the service worker handler for the request. We don't use
1355 // ServiceWorker for synchronous loads to avoid renderer deadlocks. 1356 // ServiceWorker for synchronous loads to avoid renderer deadlocks.
1356 ServiceWorkerRequestHandler::InitializeHandler( 1357 ServiceWorkerRequestHandler::InitializeHandler(
1357 new_request.get(), filter_->service_worker_context(), blob_context, 1358 new_request.get(), filter_->service_worker_context(), blob_context,
1358 child_id, request_data.service_worker_provider_id, 1359 child_id, request_data.service_worker_provider_id,
1359 request_data.skip_service_worker || is_sync_load, 1360 request_data.skip_service_worker || is_sync_load,
1360 request_data.fetch_request_mode, request_data.fetch_credentials_mode, 1361 request_data.fetch_request_mode, request_data.fetch_credentials_mode,
1361 request_data.fetch_redirect_mode, request_data.resource_type, 1362 request_data.fetch_redirect_mode, request_data.resource_type,
1362 request_data.fetch_request_context_type, request_data.fetch_frame_type, 1363 request_data.fetch_request_context_type, request_data.fetch_frame_type,
1363 request_data.request_body); 1364 request_data.request_body, nullptr);
1364 1365
1365 // Have the appcache associate its extra info with the request. 1366 // Have the appcache associate its extra info with the request.
1366 AppCacheInterceptor::SetExtraRequestInfo( 1367 AppCacheInterceptor::SetExtraRequestInfo(
1367 new_request.get(), filter_->appcache_service(), child_id, 1368 new_request.get(), filter_->appcache_service(), child_id,
1368 request_data.appcache_host_id, request_data.resource_type, 1369 request_data.appcache_host_id, request_data.resource_type,
1369 request_data.should_reset_appcache); 1370 request_data.should_reset_appcache);
1370 1371
1371 scoped_ptr<ResourceHandler> handler( 1372 scoped_ptr<ResourceHandler> handler(
1372 CreateResourceHandler( 1373 CreateResourceHandler(
1373 new_request.get(), 1374 new_request.get(),
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1925 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1925 net::URLRequest* request) { 1926 net::URLRequest* request) {
1926 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1927 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1927 IncrementOutstandingRequestsCount(-1, info); 1928 IncrementOutstandingRequestsCount(-1, info);
1928 } 1929 }
1929 1930
1930 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1931 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1931 ResourceContext* resource_context, 1932 ResourceContext* resource_context,
1932 int frame_tree_node_id, 1933 int frame_tree_node_id,
1933 const NavigationRequestInfo& info, 1934 const NavigationRequestInfo& info,
1934 NavigationURLLoaderImplCore* loader) { 1935 NavigationURLLoaderImplCore* loader,
1936 ServiceWorkerContextWrapper* service_worker_context) {
1935 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1937 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1936 // browser-side navigations project. 1938 // browser-side navigations project.
1937 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1939 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1938 switches::kEnableBrowserSideNavigation)); 1940 switches::kEnableBrowserSideNavigation));
1939 1941
1940 ResourceType resource_type = info.is_main_frame ? 1942 ResourceType resource_type = info.is_main_frame ?
1941 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1943 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1942 1944
1943 if (is_shutdown_ || 1945 if (is_shutdown_ ||
1944 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1946 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 } 1991 }
1990 1992
1991 SetReferrerForRequest(new_request.get(), info.common_params.referrer); 1993 SetReferrerForRequest(new_request.get(), info.common_params.referrer);
1992 1994
1993 net::HttpRequestHeaders headers; 1995 net::HttpRequestHeaders headers;
1994 headers.AddHeadersFromString(info.begin_params.headers); 1996 headers.AddHeadersFromString(info.begin_params.headers);
1995 new_request->SetExtraRequestHeaders(headers); 1997 new_request->SetExtraRequestHeaders(headers);
1996 1998
1997 new_request->SetLoadFlags(load_flags); 1999 new_request->SetLoadFlags(load_flags);
1998 2000
2001 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2002 GetChromeBlobStorageContextForResourceContext(resource_context));
2003
1999 // Resolve elements from request_body and prepare upload data. 2004 // Resolve elements from request_body and prepare upload data.
2000 if (info.request_body.get()) { 2005 if (info.request_body.get()) {
2001 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2002 GetChromeBlobStorageContextForResourceContext(resource_context));
2003 AttachRequestBodyBlobDataHandles( 2006 AttachRequestBodyBlobDataHandles(
2004 info.request_body.get(), 2007 info.request_body.get(),
2005 blob_context); 2008 blob_context);
2006 // TODO(davidben): The FileSystemContext is null here. In the case where 2009 // TODO(davidben): The FileSystemContext is null here. In the case where
2007 // another renderer requested this navigation, this should be the same 2010 // another renderer requested this navigation, this should be the same
2008 // FileSystemContext passed into ShouldServiceRequest. 2011 // FileSystemContext passed into ShouldServiceRequest.
2009 new_request->set_upload(UploadDataStreamBuilder::Build( 2012 new_request->set_upload(UploadDataStreamBuilder::Build(
2010 info.request_body.get(), 2013 info.request_body.get(),
2011 blob_context, 2014 blob_context,
2012 nullptr, // file_system_context 2015 nullptr, // file_system_context
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2061 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2059 // Hang on to a reference to ensure the blob is not released prior 2062 // Hang on to a reference to ensure the blob is not released prior
2060 // to the job being started. 2063 // to the job being started.
2061 ChromeBlobStorageContext* blob_context = 2064 ChromeBlobStorageContext* blob_context =
2062 GetChromeBlobStorageContextForResourceContext(resource_context); 2065 GetChromeBlobStorageContextForResourceContext(resource_context);
2063 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2066 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2064 new_request.get(), 2067 new_request.get(),
2065 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); 2068 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
2066 } 2069 }
2067 2070
2068 // TODO(davidben): Attach ServiceWorkerRequestHandler. 2071 RequestContextFrameType frame_type = info.is_main_frame ?
2069 // TODO(michaeln): Help out with this and that. 2072 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL :
2073 REQUEST_CONTEXT_FRAME_TYPE_NESTED;
2074 // TODO: sync loads should set skip_service_worker to true.
2075 ServiceWorkerRequestHandler::InitializeHandler(
michaeln 2015/09/16 00:56:42 I think it'd be worth creating a new Init method f
Fabrice (no longer in Chrome) 2015/09/30 17:32:07 Done.
2076 new_request.get(),
2077 service_worker_context,
2078 blob_context,
2079 (filter_ != nullptr) ? filter_->child_id() : -1,
2080 info.common_params.service_worker_provider_id,
2081 info.begin_params.skip_service_worker,
2082 FETCH_REQUEST_MODE_NO_CORS,
2083 FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
2084 FetchRedirectMode::FOLLOW_MODE,
2085 resource_type,
2086 info.begin_params.request_context_type,
2087 frame_type,
2088 info.request_body,
2089 loader);
2090
2070 // TODO(davidben): Attach AppCacheInterceptor. 2091 // TODO(davidben): Attach AppCacheInterceptor.
2071 2092
2072 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2093 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2073 new_request.get(), loader)); 2094 new_request.get(), loader));
2074 2095
2075 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2096 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2076 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2097 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2077 // currently it's a no-op. 2098 // currently it's a no-op.
2078 handler = AddStandardHandlers(new_request.get(), resource_type, 2099 handler = AddStandardHandlers(new_request.get(), resource_type,
2079 resource_context, 2100 resource_context,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 load_flags |= net::LOAD_PREFETCH; 2421 load_flags |= net::LOAD_PREFETCH;
2401 } 2422 }
2402 2423
2403 if (is_sync_load) 2424 if (is_sync_load)
2404 load_flags |= net::LOAD_IGNORE_LIMITS; 2425 load_flags |= net::LOAD_IGNORE_LIMITS;
2405 2426
2406 return load_flags; 2427 return load_flags;
2407 } 2428 }
2408 2429
2409 } // namespace content 2430 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698