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

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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1931 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1931 net::URLRequest* request) { 1932 net::URLRequest* request) {
1932 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1933 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1933 IncrementOutstandingRequestsCount(-1, info); 1934 IncrementOutstandingRequestsCount(-1, info);
1934 } 1935 }
1935 1936
1936 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1937 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1937 ResourceContext* resource_context, 1938 ResourceContext* resource_context,
1938 int frame_tree_node_id, 1939 int frame_tree_node_id,
1939 const NavigationRequestInfo& info, 1940 const NavigationRequestInfo& info,
1940 NavigationURLLoaderImplCore* loader) { 1941 NavigationURLLoaderImplCore* loader,
1942 ServiceWorkerContextWrapper* service_worker_context) {
1941 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1943 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1942 // browser-side navigations project. 1944 // browser-side navigations project.
1943 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1945 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1944 switches::kEnableBrowserSideNavigation)); 1946 switches::kEnableBrowserSideNavigation));
1945 1947
1946 ResourceType resource_type = info.is_main_frame ? 1948 ResourceType resource_type = info.is_main_frame ?
1947 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1949 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1948 1950
1949 if (is_shutdown_ || 1951 if (is_shutdown_ ||
1950 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1952 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 } 1997 }
1996 1998
1997 SetReferrerForRequest(new_request.get(), info.common_params.referrer); 1999 SetReferrerForRequest(new_request.get(), info.common_params.referrer);
1998 2000
1999 net::HttpRequestHeaders headers; 2001 net::HttpRequestHeaders headers;
2000 headers.AddHeadersFromString(info.begin_params.headers); 2002 headers.AddHeadersFromString(info.begin_params.headers);
2001 new_request->SetExtraRequestHeaders(headers); 2003 new_request->SetExtraRequestHeaders(headers);
2002 2004
2003 new_request->SetLoadFlags(load_flags); 2005 new_request->SetLoadFlags(load_flags);
2004 2006
2007 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2008 GetChromeBlobStorageContextForResourceContext(resource_context));
clamy 2015/08/31 12:09:27 nit: extra line needed.
Fabrice (no longer in Chrome) 2015/08/31 14:00:35 You mean a new line? Done.
2005 // Resolve elements from request_body and prepare upload data. 2009 // Resolve elements from request_body and prepare upload data.
2006 if (info.request_body.get()) { 2010 if (info.request_body.get()) {
2007 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
2008 GetChromeBlobStorageContextForResourceContext(resource_context));
2009 AttachRequestBodyBlobDataHandles( 2011 AttachRequestBodyBlobDataHandles(
2010 info.request_body.get(), 2012 info.request_body.get(),
2011 blob_context); 2013 blob_context);
2012 // TODO(davidben): The FileSystemContext is null here. In the case where 2014 // TODO(davidben): The FileSystemContext is null here. In the case where
2013 // another renderer requested this navigation, this should be the same 2015 // another renderer requested this navigation, this should be the same
2014 // FileSystemContext passed into ShouldServiceRequest. 2016 // FileSystemContext passed into ShouldServiceRequest.
2015 new_request->set_upload(UploadDataStreamBuilder::Build( 2017 new_request->set_upload(UploadDataStreamBuilder::Build(
2016 info.request_body.get(), 2018 info.request_body.get(),
2017 blob_context, 2019 blob_context,
2018 nullptr, // file_system_context 2020 nullptr, // file_system_context
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2066 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2065 // Hang on to a reference to ensure the blob is not released prior 2067 // Hang on to a reference to ensure the blob is not released prior
2066 // to the job being started. 2068 // to the job being started.
2067 ChromeBlobStorageContext* blob_context = 2069 ChromeBlobStorageContext* blob_context =
2068 GetChromeBlobStorageContextForResourceContext(resource_context); 2070 GetChromeBlobStorageContextForResourceContext(resource_context);
2069 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2071 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2070 new_request.get(), 2072 new_request.get(),
2071 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); 2073 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
2072 } 2074 }
2073 2075
2074 // TODO(davidben): Attach ServiceWorkerRequestHandler. 2076 RequestContextFrameType frame_type = info.is_main_frame ?
2075 // TODO(michaeln): Help out with this and that. 2077 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL :
2078 REQUEST_CONTEXT_FRAME_TYPE_NESTED;
2079 // TODO: sync loads should set skip_service_worker to true.
2080 ServiceWorkerRequestHandler::InitializeHandler(
2081 new_request.get(),
2082 service_worker_context,
2083 blob_context,
2084 (filter_ != nullptr) ? filter_->child_id() : -1,
2085 info.common_params.service_worker_provider_id,
2086 info.begin_params.skip_service_worker,
2087 FETCH_REQUEST_MODE_NO_CORS,
2088 FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
2089 FetchRedirectMode::FOLLOW_MODE,
2090 resource_type,
2091 info.begin_params.request_context_type,
2092 frame_type,
2093 info.request_body,
2094 loader);
2095
2076 // TODO(davidben): Attach AppCacheInterceptor. 2096 // TODO(davidben): Attach AppCacheInterceptor.
2077 2097
2078 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2098 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2079 new_request.get(), loader)); 2099 new_request.get(), loader));
2080 2100
2081 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2101 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2082 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2102 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2083 // currently it's a no-op. 2103 // currently it's a no-op.
2084 handler = AddStandardHandlers(new_request.get(), resource_type, 2104 handler = AddStandardHandlers(new_request.get(), resource_type,
2085 resource_context, 2105 resource_context,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 load_flags |= net::LOAD_PREFETCH; 2426 load_flags |= net::LOAD_PREFETCH;
2407 } 2427 }
2408 2428
2409 if (is_sync_load) 2429 if (is_sync_load)
2410 load_flags |= net::LOAD_IGNORE_LIMITS; 2430 load_flags |= net::LOAD_IGNORE_LIMITS;
2411 2431
2412 return load_flags; 2432 return load_flags;
2413 } 2433 }
2414 2434
2415 } // namespace content 2435 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698