| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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)); |
| 2009 |
| 2005 // Resolve elements from request_body and prepare upload data. | 2010 // Resolve elements from request_body and prepare upload data. |
| 2006 if (info.request_body.get()) { | 2011 if (info.request_body.get()) { |
| 2007 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
| 2008 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
| 2009 AttachRequestBodyBlobDataHandles( | 2012 AttachRequestBodyBlobDataHandles( |
| 2010 info.request_body.get(), | 2013 info.request_body.get(), |
| 2011 blob_context); | 2014 blob_context); |
| 2012 // TODO(davidben): The FileSystemContext is null here. In the case where | 2015 // TODO(davidben): The FileSystemContext is null here. In the case where |
| 2013 // another renderer requested this navigation, this should be the same | 2016 // another renderer requested this navigation, this should be the same |
| 2014 // FileSystemContext passed into ShouldServiceRequest. | 2017 // FileSystemContext passed into ShouldServiceRequest. |
| 2015 new_request->set_upload(UploadDataStreamBuilder::Build( | 2018 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 2016 info.request_body.get(), | 2019 info.request_body.get(), |
| 2017 blob_context, | 2020 blob_context, |
| 2018 nullptr, // file_system_context | 2021 nullptr, // file_system_context |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2067 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
| 2065 // Hang on to a reference to ensure the blob is not released prior | 2068 // Hang on to a reference to ensure the blob is not released prior |
| 2066 // to the job being started. | 2069 // to the job being started. |
| 2067 ChromeBlobStorageContext* blob_context = | 2070 ChromeBlobStorageContext* blob_context = |
| 2068 GetChromeBlobStorageContextForResourceContext(resource_context); | 2071 GetChromeBlobStorageContextForResourceContext(resource_context); |
| 2069 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2072 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 2070 new_request.get(), | 2073 new_request.get(), |
| 2071 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | 2074 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); |
| 2072 } | 2075 } |
| 2073 | 2076 |
| 2074 // TODO(davidben): Attach ServiceWorkerRequestHandler. | 2077 RequestContextFrameType frame_type = info.is_main_frame ? |
| 2075 // TODO(michaeln): Help out with this and that. | 2078 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL : |
| 2079 REQUEST_CONTEXT_FRAME_TYPE_NESTED; |
| 2080 // TODO: sync loads should set skip_service_worker to true. |
| 2081 ServiceWorkerRequestHandler::InitializeHandler( |
| 2082 new_request.get(), |
| 2083 service_worker_context, |
| 2084 blob_context, |
| 2085 (filter_ != nullptr) ? filter_->child_id() : -1, |
| 2086 info.common_params.service_worker_provider_id, |
| 2087 info.begin_params.skip_service_worker, |
| 2088 FETCH_REQUEST_MODE_NO_CORS, |
| 2089 FETCH_CREDENTIALS_MODE_SAME_ORIGIN, |
| 2090 FetchRedirectMode::FOLLOW_MODE, |
| 2091 resource_type, |
| 2092 info.begin_params.request_context_type, |
| 2093 frame_type, |
| 2094 info.request_body, |
| 2095 loader); |
| 2096 |
| 2076 // TODO(davidben): Attach AppCacheInterceptor. | 2097 // TODO(davidben): Attach AppCacheInterceptor. |
| 2077 | 2098 |
| 2078 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | 2099 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( |
| 2079 new_request.get(), loader)); | 2100 new_request.get(), loader)); |
| 2080 | 2101 |
| 2081 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2102 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
| 2082 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2103 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
| 2083 // currently it's a no-op. | 2104 // currently it's a no-op. |
| 2084 handler = AddStandardHandlers(new_request.get(), resource_type, | 2105 handler = AddStandardHandlers(new_request.get(), resource_type, |
| 2085 resource_context, | 2106 resource_context, |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2406 load_flags |= net::LOAD_PREFETCH; | 2427 load_flags |= net::LOAD_PREFETCH; |
| 2407 } | 2428 } |
| 2408 | 2429 |
| 2409 if (is_sync_load) | 2430 if (is_sync_load) |
| 2410 load_flags |= net::LOAD_IGNORE_LIMITS; | 2431 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 2411 | 2432 |
| 2412 return load_flags; | 2433 return load_flags; |
| 2413 } | 2434 } |
| 2414 | 2435 |
| 2415 } // namespace content | 2436 } // namespace content |
| OLD | NEW |