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 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 | 1362 |
1362 // Initialize the service worker handler for the request. We don't use | 1363 // Initialize the service worker handler for the request. We don't use |
1363 // ServiceWorker for synchronous loads to avoid renderer deadlocks. | 1364 // ServiceWorker for synchronous loads to avoid renderer deadlocks. |
1364 ServiceWorkerRequestHandler::InitializeHandler( | 1365 ServiceWorkerRequestHandler::InitializeHandler( |
1365 new_request.get(), filter_->service_worker_context(), blob_context, | 1366 new_request.get(), filter_->service_worker_context(), blob_context, |
1366 child_id, request_data.service_worker_provider_id, | 1367 child_id, request_data.service_worker_provider_id, |
1367 request_data.skip_service_worker || is_sync_load, | 1368 request_data.skip_service_worker || is_sync_load, |
1368 request_data.fetch_request_mode, request_data.fetch_credentials_mode, | 1369 request_data.fetch_request_mode, request_data.fetch_credentials_mode, |
1369 request_data.fetch_redirect_mode, request_data.resource_type, | 1370 request_data.fetch_redirect_mode, request_data.resource_type, |
1370 request_data.fetch_request_context_type, request_data.fetch_frame_type, | 1371 request_data.fetch_request_context_type, request_data.fetch_frame_type, |
1371 request_data.request_body); | 1372 request_data.request_body, nullptr); |
1372 | 1373 |
1373 // Have the appcache associate its extra info with the request. | 1374 // Have the appcache associate its extra info with the request. |
1374 AppCacheInterceptor::SetExtraRequestInfo( | 1375 AppCacheInterceptor::SetExtraRequestInfo( |
1375 new_request.get(), filter_->appcache_service(), child_id, | 1376 new_request.get(), filter_->appcache_service(), child_id, |
1376 request_data.appcache_host_id, request_data.resource_type, | 1377 request_data.appcache_host_id, request_data.resource_type, |
1377 request_data.should_reset_appcache); | 1378 request_data.should_reset_appcache); |
1378 | 1379 |
1379 scoped_ptr<ResourceHandler> handler( | 1380 scoped_ptr<ResourceHandler> handler( |
1380 CreateResourceHandler( | 1381 CreateResourceHandler( |
1381 new_request.get(), | 1382 new_request.get(), |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( | 1942 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( |
1942 net::URLRequest* request) { | 1943 net::URLRequest* request) { |
1943 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1944 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
1944 IncrementOutstandingRequestsCount(-1, info); | 1945 IncrementOutstandingRequestsCount(-1, info); |
1945 } | 1946 } |
1946 | 1947 |
1947 void ResourceDispatcherHostImpl::BeginNavigationRequest( | 1948 void ResourceDispatcherHostImpl::BeginNavigationRequest( |
1948 ResourceContext* resource_context, | 1949 ResourceContext* resource_context, |
1949 int frame_tree_node_id, | 1950 int frame_tree_node_id, |
1950 const NavigationRequestInfo& info, | 1951 const NavigationRequestInfo& info, |
1951 NavigationURLLoaderImplCore* loader) { | 1952 NavigationURLLoaderImplCore* loader, |
| 1953 ServiceWorkerContextWrapper* service_worker_context) { |
1952 // PlzNavigate: BeginNavigationRequest currently should only be used for the | 1954 // PlzNavigate: BeginNavigationRequest currently should only be used for the |
1953 // browser-side navigations project. | 1955 // browser-side navigations project. |
1954 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1956 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
1955 switches::kEnableBrowserSideNavigation)); | 1957 switches::kEnableBrowserSideNavigation)); |
1956 | 1958 |
1957 ResourceType resource_type = info.is_main_frame ? | 1959 ResourceType resource_type = info.is_main_frame ? |
1958 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; | 1960 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
1959 | 1961 |
1960 if (is_shutdown_ || | 1962 if (is_shutdown_ || |
1961 // TODO(davidben): Check ShouldServiceRequest here. This is important; it | 1963 // TODO(davidben): Check ShouldServiceRequest here. This is important; it |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 } | 2008 } |
2007 | 2009 |
2008 SetReferrerForRequest(new_request.get(), info.common_params.referrer); | 2010 SetReferrerForRequest(new_request.get(), info.common_params.referrer); |
2009 | 2011 |
2010 net::HttpRequestHeaders headers; | 2012 net::HttpRequestHeaders headers; |
2011 headers.AddHeadersFromString(info.begin_params.headers); | 2013 headers.AddHeadersFromString(info.begin_params.headers); |
2012 new_request->SetExtraRequestHeaders(headers); | 2014 new_request->SetExtraRequestHeaders(headers); |
2013 | 2015 |
2014 new_request->SetLoadFlags(load_flags); | 2016 new_request->SetLoadFlags(load_flags); |
2015 | 2017 |
| 2018 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
| 2019 GetChromeBlobStorageContextForResourceContext(resource_context)); |
| 2020 |
2016 // Resolve elements from request_body and prepare upload data. | 2021 // Resolve elements from request_body and prepare upload data. |
2017 if (info.request_body.get()) { | 2022 if (info.request_body.get()) { |
2018 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
2019 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
2020 AttachRequestBodyBlobDataHandles( | 2023 AttachRequestBodyBlobDataHandles( |
2021 info.request_body.get(), | 2024 info.request_body.get(), |
2022 blob_context); | 2025 blob_context); |
2023 // TODO(davidben): The FileSystemContext is null here. In the case where | 2026 // TODO(davidben): The FileSystemContext is null here. In the case where |
2024 // another renderer requested this navigation, this should be the same | 2027 // another renderer requested this navigation, this should be the same |
2025 // FileSystemContext passed into ShouldServiceRequest. | 2028 // FileSystemContext passed into ShouldServiceRequest. |
2026 new_request->set_upload(UploadDataStreamBuilder::Build( | 2029 new_request->set_upload(UploadDataStreamBuilder::Build( |
2027 info.request_body.get(), | 2030 info.request_body.get(), |
2028 blob_context, | 2031 blob_context, |
2029 nullptr, // file_system_context | 2032 nullptr, // file_system_context |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2078 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
2076 // Hang on to a reference to ensure the blob is not released prior | 2079 // Hang on to a reference to ensure the blob is not released prior |
2077 // to the job being started. | 2080 // to the job being started. |
2078 ChromeBlobStorageContext* blob_context = | 2081 ChromeBlobStorageContext* blob_context = |
2079 GetChromeBlobStorageContextForResourceContext(resource_context); | 2082 GetChromeBlobStorageContextForResourceContext(resource_context); |
2080 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2083 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2081 new_request.get(), | 2084 new_request.get(), |
2082 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | 2085 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); |
2083 } | 2086 } |
2084 | 2087 |
2085 // TODO(davidben): Attach ServiceWorkerRequestHandler. | 2088 RequestContextFrameType frame_type = info.is_main_frame ? |
2086 // TODO(michaeln): Help out with this and that. | 2089 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL : |
| 2090 REQUEST_CONTEXT_FRAME_TYPE_NESTED; |
| 2091 // TODO: sync loads should set skip_service_worker to true. |
| 2092 ServiceWorkerRequestHandler::InitializeHandler( |
| 2093 new_request.get(), |
| 2094 service_worker_context, |
| 2095 blob_context, |
| 2096 (filter_ != nullptr) ? filter_->child_id() : -1, |
| 2097 info.common_params.service_worker_provider_id, |
| 2098 info.begin_params.skip_service_worker, |
| 2099 FETCH_REQUEST_MODE_SAME_ORIGIN, |
| 2100 FETCH_CREDENTIALS_MODE_INCLUDE, |
| 2101 FetchRedirectMode::MANUAL_MODE, |
| 2102 resource_type, |
| 2103 info.begin_params.request_context_type, |
| 2104 frame_type, |
| 2105 info.request_body, |
| 2106 loader); |
| 2107 |
2087 // TODO(davidben): Attach AppCacheInterceptor. | 2108 // TODO(davidben): Attach AppCacheInterceptor. |
2088 | 2109 |
2089 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | 2110 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( |
2090 new_request.get(), loader)); | 2111 new_request.get(), loader)); |
2091 | 2112 |
2092 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2113 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
2093 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2114 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
2094 // currently it's a no-op. | 2115 // currently it's a no-op. |
2095 handler = AddStandardHandlers(new_request.get(), resource_type, | 2116 handler = AddStandardHandlers(new_request.get(), resource_type, |
2096 resource_context, | 2117 resource_context, |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 load_flags |= net::LOAD_PREFETCH; | 2438 load_flags |= net::LOAD_PREFETCH; |
2418 } | 2439 } |
2419 | 2440 |
2420 if (is_sync_load) | 2441 if (is_sync_load) |
2421 load_flags |= net::LOAD_IGNORE_LIMITS; | 2442 load_flags |= net::LOAD_IGNORE_LIMITS; |
2422 | 2443 |
2423 return load_flags; | 2444 return load_flags; |
2424 } | 2445 } |
2425 | 2446 |
2426 } // namespace content | 2447 } // namespace content |
OLD | NEW |