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

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: Style, placeholders, all that stuff Created 5 years, 4 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 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 1308
1308 // Initialize the service worker handler for the request. We don't use 1309 // Initialize the service worker handler for the request. We don't use
1309 // ServiceWorker for synchronous loads to avoid renderer deadlocks. 1310 // ServiceWorker for synchronous loads to avoid renderer deadlocks.
1310 ServiceWorkerRequestHandler::InitializeHandler( 1311 ServiceWorkerRequestHandler::InitializeHandler(
1311 new_request.get(), filter_->service_worker_context(), blob_context, 1312 new_request.get(), filter_->service_worker_context(), blob_context,
1312 child_id, request_data.service_worker_provider_id, 1313 child_id, request_data.service_worker_provider_id,
1313 request_data.skip_service_worker || is_sync_load, 1314 request_data.skip_service_worker || is_sync_load,
1314 request_data.fetch_request_mode, request_data.fetch_credentials_mode, 1315 request_data.fetch_request_mode, request_data.fetch_credentials_mode,
1315 request_data.fetch_redirect_mode, request_data.resource_type, 1316 request_data.fetch_redirect_mode, request_data.resource_type,
1316 request_data.fetch_request_context_type, request_data.fetch_frame_type, 1317 request_data.fetch_request_context_type, request_data.fetch_frame_type,
1317 request_data.request_body); 1318 request_data.request_body, nullptr);
1318 1319
1319 // Have the appcache associate its extra info with the request. 1320 // Have the appcache associate its extra info with the request.
1320 AppCacheInterceptor::SetExtraRequestInfo( 1321 AppCacheInterceptor::SetExtraRequestInfo(
1321 new_request.get(), filter_->appcache_service(), child_id, 1322 new_request.get(), filter_->appcache_service(), child_id,
1322 request_data.appcache_host_id, request_data.resource_type, 1323 request_data.appcache_host_id, request_data.resource_type,
1323 request_data.should_reset_appcache); 1324 request_data.should_reset_appcache);
1324 1325
1325 scoped_ptr<ResourceHandler> handler( 1326 scoped_ptr<ResourceHandler> handler(
1326 CreateResourceHandler( 1327 CreateResourceHandler(
1327 new_request.get(), 1328 new_request.get(),
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( 1881 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest(
1881 net::URLRequest* request) { 1882 net::URLRequest* request) {
1882 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); 1883 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
1883 IncrementOutstandingRequestsCount(-1, info); 1884 IncrementOutstandingRequestsCount(-1, info);
1884 } 1885 }
1885 1886
1886 void ResourceDispatcherHostImpl::BeginNavigationRequest( 1887 void ResourceDispatcherHostImpl::BeginNavigationRequest(
1887 ResourceContext* resource_context, 1888 ResourceContext* resource_context,
1888 int frame_tree_node_id, 1889 int frame_tree_node_id,
1889 const NavigationRequestInfo& info, 1890 const NavigationRequestInfo& info,
1890 NavigationURLLoaderImplCore* loader) { 1891 NavigationURLLoaderImplCore* loader,
1892 ServiceWorkerContextWrapper* service_worker_context) {
1891 // PlzNavigate: BeginNavigationRequest currently should only be used for the 1893 // PlzNavigate: BeginNavigationRequest currently should only be used for the
1892 // browser-side navigations project. 1894 // browser-side navigations project.
1893 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1895 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1894 switches::kEnableBrowserSideNavigation)); 1896 switches::kEnableBrowserSideNavigation));
1895 1897
1896 ResourceType resource_type = info.is_main_frame ? 1898 ResourceType resource_type = info.is_main_frame ?
1897 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; 1899 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME;
1898 1900
1899 if (is_shutdown_ || 1901 if (is_shutdown_ ||
1900 // TODO(davidben): Check ShouldServiceRequest here. This is important; it 1902 // TODO(davidben): Check ShouldServiceRequest here. This is important; it
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 } 1947 }
1946 1948
1947 SetReferrerForRequest(new_request.get(), info.common_params.referrer); 1949 SetReferrerForRequest(new_request.get(), info.common_params.referrer);
1948 1950
1949 net::HttpRequestHeaders headers; 1951 net::HttpRequestHeaders headers;
1950 headers.AddHeadersFromString(info.begin_params.headers); 1952 headers.AddHeadersFromString(info.begin_params.headers);
1951 new_request->SetExtraRequestHeaders(headers); 1953 new_request->SetExtraRequestHeaders(headers);
1952 1954
1953 new_request->SetLoadFlags(load_flags); 1955 new_request->SetLoadFlags(load_flags);
1954 1956
1957 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1958 GetChromeBlobStorageContextForResourceContext(resource_context));
1955 // Resolve elements from request_body and prepare upload data. 1959 // Resolve elements from request_body and prepare upload data.
1956 if (info.request_body.get()) { 1960 if (info.request_body.get()) {
1957 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
1958 GetChromeBlobStorageContextForResourceContext(resource_context));
1959 AttachRequestBodyBlobDataHandles( 1961 AttachRequestBodyBlobDataHandles(
1960 info.request_body.get(), 1962 info.request_body.get(),
1961 blob_context); 1963 blob_context);
1962 // TODO(davidben): The FileSystemContext is null here. In the case where 1964 // TODO(davidben): The FileSystemContext is null here. In the case where
1963 // another renderer requested this navigation, this should be the same 1965 // another renderer requested this navigation, this should be the same
1964 // FileSystemContext passed into ShouldServiceRequest. 1966 // FileSystemContext passed into ShouldServiceRequest.
1965 new_request->set_upload(UploadDataStreamBuilder::Build( 1967 new_request->set_upload(UploadDataStreamBuilder::Build(
1966 info.request_body.get(), 1968 info.request_body.get(),
1967 blob_context, 1969 blob_context,
1968 nullptr, // file_system_context 1970 nullptr, // file_system_context
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2015 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2014 // Hang on to a reference to ensure the blob is not released prior 2016 // Hang on to a reference to ensure the blob is not released prior
2015 // to the job being started. 2017 // to the job being started.
2016 ChromeBlobStorageContext* blob_context = 2018 ChromeBlobStorageContext* blob_context =
2017 GetChromeBlobStorageContextForResourceContext(resource_context); 2019 GetChromeBlobStorageContextForResourceContext(resource_context);
2018 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2020 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2019 new_request.get(), 2021 new_request.get(),
2020 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); 2022 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
2021 } 2023 }
2022 2024
2023 // TODO(davidben): Attach ServiceWorkerRequestHandler. 2025 ServiceWorkerRequestHandler::InitializeHandler(
2024 // TODO(michaeln): Help out with this and that. 2026 new_request.get(),
2027 service_worker_context,
2028 blob_context,
2029 (filter_ != nullptr) ? filter_->child_id() : -1,
2030 info.common_params.service_worker_provider_id,
2031 info.begin_params.skip_service_worker,
2032 info.begin_params.fetch_request_mode,
2033 info.begin_params.fetch_credentials_mode,
2034 info.begin_params.fetch_redirect_mode,
2035 info.is_main_frame ? RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME,
2036 info.begin_params.request_context_type,
2037 info.begin_params.frame_type,
2038 info.request_body,
2039 loader);
2040
2025 // TODO(davidben): Attach AppCacheInterceptor. 2041 // TODO(davidben): Attach AppCacheInterceptor.
2026 2042
2027 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2043 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2028 new_request.get(), loader)); 2044 new_request.get(), loader));
2029 2045
2030 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2046 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2031 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2047 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2032 // currently it's a no-op. 2048 // currently it's a no-op.
2033 handler = AddStandardHandlers(new_request.get(), resource_type, 2049 handler = AddStandardHandlers(new_request.get(), resource_type,
2034 resource_context, 2050 resource_context,
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 2382 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
2367 && !policy->CanReadRawCookies(child_id)) { 2383 && !policy->CanReadRawCookies(child_id)) {
2368 VLOG(1) << "Denied unauthorized request for raw headers"; 2384 VLOG(1) << "Denied unauthorized request for raw headers";
2369 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 2385 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
2370 } 2386 }
2371 2387
2372 return load_flags; 2388 return load_flags;
2373 } 2389 }
2374 2390
2375 } // namespace content 2391 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698