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

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 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 1342
1342 // Initialize the service worker handler for the request. We don't use 1343 // Initialize the service worker handler for the request. We don't use
1343 // ServiceWorker for synchronous loads to avoid renderer deadlocks. 1344 // ServiceWorker for synchronous loads to avoid renderer deadlocks.
1344 ServiceWorkerRequestHandler::InitializeHandler( 1345 ServiceWorkerRequestHandler::InitializeHandler(
1345 new_request.get(), filter_->service_worker_context(), blob_context, 1346 new_request.get(), filter_->service_worker_context(), blob_context,
1346 child_id, request_data.service_worker_provider_id, 1347 child_id, request_data.service_worker_provider_id,
1347 request_data.skip_service_worker || is_sync_load, 1348 request_data.skip_service_worker || is_sync_load,
1348 request_data.fetch_request_mode, request_data.fetch_credentials_mode, 1349 request_data.fetch_request_mode, request_data.fetch_credentials_mode,
1349 request_data.fetch_redirect_mode, request_data.resource_type, 1350 request_data.fetch_redirect_mode, request_data.resource_type,
1350 request_data.fetch_request_context_type, request_data.fetch_frame_type, 1351 request_data.fetch_request_context_type, request_data.fetch_frame_type,
1351 request_data.request_body); 1352 request_data.request_body, nullptr);
1352 1353
1353 // Have the appcache associate its extra info with the request. 1354 // Have the appcache associate its extra info with the request.
1354 AppCacheInterceptor::SetExtraRequestInfo( 1355 AppCacheInterceptor::SetExtraRequestInfo(
1355 new_request.get(), filter_->appcache_service(), child_id, 1356 new_request.get(), filter_->appcache_service(), child_id,
1356 request_data.appcache_host_id, request_data.resource_type, 1357 request_data.appcache_host_id, request_data.resource_type,
1357 request_data.should_reset_appcache); 1358 request_data.should_reset_appcache);
1358 1359
1359 scoped_ptr<ResourceHandler> handler( 1360 scoped_ptr<ResourceHandler> handler(
1360 CreateResourceHandler( 1361 CreateResourceHandler(
1361 new_request.get(), 1362 new_request.get(),
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1918 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1918 net::URLRequest* request) { 1919 net::URLRequest* request) {
1919 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1920 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1920 IncrementOutstandingRequestsCount(-1, info); 1921 IncrementOutstandingRequestsCount(-1, info);
1921 } 1922 }
1922 1923
1923 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1924 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1924 ResourceContext* resource_context, 1925 ResourceContext* resource_context,
1925 int frame_tree_node_id, 1926 int frame_tree_node_id,
1926 const NavigationRequestInfo& info, 1927 const NavigationRequestInfo& info,
1927 NavigationURLLoaderImplCore* loader) { 1928 NavigationURLLoaderImplCore* loader,
1929 ServiceWorkerContextWrapper* service_worker_context) {
1928 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1930 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1929 // browser-side navigations project. 1931 // browser-side navigations project.
1930 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1932 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1931 switches::kEnableBrowserSideNavigation)); 1933 switches::kEnableBrowserSideNavigation));
1932 1934
1933 ResourceType resource_type = info.is_main_frame ? 1935 ResourceType resource_type = info.is_main_frame ?
1934 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1936 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1935 1937
1936 if (is_shutdown_ || 1938 if (is_shutdown_ ||
1937 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1939 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 } 1984 }
1983 1985
1984 SetReferrerForRequest(new_request.get(), info.common_params.referrer); 1986 SetReferrerForRequest(new_request.get(), info.common_params.referrer);
1985 1987
1986 net::HttpRequestHeaders headers; 1988 net::HttpRequestHeaders headers;
1987 headers.AddHeadersFromString(info.begin_params.headers); 1989 headers.AddHeadersFromString(info.begin_params.headers);
1988 new_request->SetExtraRequestHeaders(headers); 1990 new_request->SetExtraRequestHeaders(headers);
1989 1991
1990 new_request->SetLoadFlags(load_flags); 1992 new_request->SetLoadFlags(load_flags);
1991 1993
1994 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1995 GetChromeBlobStorageContextForResourceContext(resource_context));
1992 // Resolve elements from request_body and prepare upload data. 1996 // Resolve elements from request_body and prepare upload data.
1993 if (info.request_body.get()) { 1997 if (info.request_body.get()) {
1994 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1995 GetChromeBlobStorageContextForResourceContext(resource_context));
1996 AttachRequestBodyBlobDataHandles( 1998 AttachRequestBodyBlobDataHandles(
1997 info.request_body.get(), 1999 info.request_body.get(),
1998 blob_context); 2000 blob_context);
1999 // TODO(davidben): The FileSystemContext is null here. In the case where 2001 // TODO(davidben): The FileSystemContext is null here. In the case where
2000 // another renderer requested this navigation, this should be the same 2002 // another renderer requested this navigation, this should be the same
2001 // FileSystemContext passed into ShouldServiceRequest. 2003 // FileSystemContext passed into ShouldServiceRequest.
2002 new_request->set_upload(UploadDataStreamBuilder::Build( 2004 new_request->set_upload(UploadDataStreamBuilder::Build(
2003 info.request_body.get(), 2005 info.request_body.get(),
2004 blob_context, 2006 blob_context,
2005 nullptr, // file_system_context 2007 nullptr, // file_system_context
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2052 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2051 // Hang on to a reference to ensure the blob is not released prior 2053 // Hang on to a reference to ensure the blob is not released prior
2052 // to the job being started. 2054 // to the job being started.
2053 ChromeBlobStorageContext* blob_context = 2055 ChromeBlobStorageContext* blob_context =
2054 GetChromeBlobStorageContextForResourceContext(resource_context); 2056 GetChromeBlobStorageContextForResourceContext(resource_context);
2055 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2057 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2056 new_request.get(), 2058 new_request.get(),
2057 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); 2059 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
2058 } 2060 }
2059 2061
2060 // TODO(davidben): Attach ServiceWorkerRequestHandler. 2062 // TODO: sync loads should set skip_service_worker to true.
2061 // TODO(michaeln): Help out with this and that. 2063 ServiceWorkerRequestHandler::InitializeHandler(
2064 new_request.get(),
2065 service_worker_context,
2066 blob_context,
2067 (filter_ != nullptr) ? filter_->child_id() : -1,
2068 info.common_params.service_worker_provider_id,
2069 info.begin_params.skip_service_worker,
2070 FETCH_REQUEST_MODE_NO_CORS,
2071 FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
2072 FetchRedirectMode::FOLLOW_MODE,
2073 resource_type,
2074 info.begin_params.request_context_type,
2075 info.begin_params.frame_type,
2076 info.request_body,
2077 loader);
2078
2062 // TODO(davidben): Attach AppCacheInterceptor. 2079 // TODO(davidben): Attach AppCacheInterceptor.
2063 2080
2064 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2081 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2065 new_request.get(), loader)); 2082 new_request.get(), loader));
2066 2083
2067 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2084 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2068 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2085 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2069 // currently it's a no-op. 2086 // currently it's a no-op.
2070 handler = AddStandardHandlers(new_request.get(), resource_type, 2087 handler = AddStandardHandlers(new_request.get(), resource_type,
2071 resource_context, 2088 resource_context,
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 2420 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
2404 && !policy->CanReadRawCookies(child_id)) { 2421 && !policy->CanReadRawCookies(child_id)) {
2405 VLOG(1) << "Denied unauthorized request for raw headers"; 2422 VLOG(1) << "Denied unauthorized request for raw headers";
2406 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 2423 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
2407 } 2424 }
2408 2425
2409 return load_flags; 2426 return load_flags;
2410 } 2427 }
2411 2428
2412 } // namespace content 2429 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698