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 1951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 | 1962 |
1963 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( | 1963 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( |
1964 net::URLRequest* request) { | 1964 net::URLRequest* request) { |
1965 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1965 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
1966 IncrementOutstandingRequestsCount(-1, info); | 1966 IncrementOutstandingRequestsCount(-1, info); |
1967 } | 1967 } |
1968 | 1968 |
1969 void ResourceDispatcherHostImpl::BeginNavigationRequest( | 1969 void ResourceDispatcherHostImpl::BeginNavigationRequest( |
1970 ResourceContext* resource_context, | 1970 ResourceContext* resource_context, |
1971 const NavigationRequestInfo& info, | 1971 const NavigationRequestInfo& info, |
1972 NavigationURLLoaderImplCore* loader) { | 1972 NavigationURLLoaderImplCore* loader, |
| 1973 ServiceWorkerNavigationHandleCore* service_worker_handle_core) { |
1973 // PlzNavigate: BeginNavigationRequest currently should only be used for the | 1974 // PlzNavigate: BeginNavigationRequest currently should only be used for the |
1974 // browser-side navigations project. | 1975 // browser-side navigations project. |
1975 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1976 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
1976 switches::kEnableBrowserSideNavigation)); | 1977 switches::kEnableBrowserSideNavigation)); |
1977 | 1978 |
1978 ResourceType resource_type = info.is_main_frame ? | 1979 ResourceType resource_type = info.is_main_frame ? |
1979 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; | 1980 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
1980 | 1981 |
1981 if (is_shutdown_ || | 1982 if (is_shutdown_ || |
1982 // TODO(davidben): Check ShouldServiceRequest here. This is important; it | 1983 // TODO(davidben): Check ShouldServiceRequest here. This is important; it |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 } | 2028 } |
2028 | 2029 |
2029 SetReferrerForRequest(new_request.get(), info.common_params.referrer); | 2030 SetReferrerForRequest(new_request.get(), info.common_params.referrer); |
2030 | 2031 |
2031 net::HttpRequestHeaders headers; | 2032 net::HttpRequestHeaders headers; |
2032 headers.AddHeadersFromString(info.begin_params.headers); | 2033 headers.AddHeadersFromString(info.begin_params.headers); |
2033 new_request->SetExtraRequestHeaders(headers); | 2034 new_request->SetExtraRequestHeaders(headers); |
2034 | 2035 |
2035 new_request->SetLoadFlags(load_flags); | 2036 new_request->SetLoadFlags(load_flags); |
2036 | 2037 |
| 2038 storage::BlobStorageContext* blob_context = GetBlobStorageContext( |
| 2039 GetChromeBlobStorageContextForResourceContext(resource_context)); |
| 2040 |
2037 // Resolve elements from request_body and prepare upload data. | 2041 // Resolve elements from request_body and prepare upload data. |
2038 if (info.request_body.get()) { | 2042 if (info.request_body.get()) { |
2039 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
2040 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
2041 AttachRequestBodyBlobDataHandles( | 2043 AttachRequestBodyBlobDataHandles( |
2042 info.request_body.get(), | 2044 info.request_body.get(), |
2043 blob_context); | 2045 blob_context); |
2044 // TODO(davidben): The FileSystemContext is null here. In the case where | 2046 // TODO(davidben): The FileSystemContext is null here. In the case where |
2045 // another renderer requested this navigation, this should be the same | 2047 // another renderer requested this navigation, this should be the same |
2046 // FileSystemContext passed into ShouldServiceRequest. | 2048 // FileSystemContext passed into ShouldServiceRequest. |
2047 new_request->set_upload(UploadDataStreamBuilder::Build( | 2049 new_request->set_upload(UploadDataStreamBuilder::Build( |
2048 info.request_body.get(), | 2050 info.request_body.get(), |
2049 blob_context, | 2051 blob_context, |
2050 nullptr, // file_system_context | 2052 nullptr, // file_system_context |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 false, // request_data.report_raw_headers | 2089 false, // request_data.report_raw_headers |
2088 true, | 2090 true, |
2089 IsUsingLoFi(info.common_params.lofi_state, delegate_, | 2091 IsUsingLoFi(info.common_params.lofi_state, delegate_, |
2090 *new_request, resource_context)); | 2092 *new_request, resource_context)); |
2091 // Request takes ownership. | 2093 // Request takes ownership. |
2092 extra_info->AssociateWithRequest(new_request.get()); | 2094 extra_info->AssociateWithRequest(new_request.get()); |
2093 | 2095 |
2094 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2096 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
2095 // Hang on to a reference to ensure the blob is not released prior | 2097 // Hang on to a reference to ensure the blob is not released prior |
2096 // to the job being started. | 2098 // to the job being started. |
2097 ChromeBlobStorageContext* blob_context = | |
2098 GetChromeBlobStorageContextForResourceContext(resource_context); | |
2099 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2099 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2100 new_request.get(), | 2100 new_request.get(), |
2101 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | 2101 blob_context->GetBlobDataFromPublicURL(new_request->url())); |
2102 } | 2102 } |
2103 | 2103 |
2104 // TODO(davidben): Attach ServiceWorkerRequestHandler. | 2104 RequestContextFrameType frame_type = |
2105 // TODO(michaeln): Help out with this and that. | 2105 info.is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL |
| 2106 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; |
| 2107 ServiceWorkerRequestHandler::InitializeForNavigation( |
| 2108 new_request.get(), service_worker_handle_core, blob_context, |
| 2109 info.begin_params.skip_service_worker, resource_type, |
| 2110 info.begin_params.request_context_type, frame_type, info.request_body); |
| 2111 |
2106 // TODO(davidben): Attach AppCacheInterceptor. | 2112 // TODO(davidben): Attach AppCacheInterceptor. |
2107 | 2113 |
2108 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | 2114 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( |
2109 new_request.get(), loader)); | 2115 new_request.get(), loader)); |
2110 | 2116 |
2111 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2117 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
2112 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2118 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
2113 // currently it's a no-op. | 2119 // currently it's a no-op. |
2114 handler = AddStandardHandlers(new_request.get(), resource_type, | 2120 handler = AddStandardHandlers(new_request.get(), resource_type, |
2115 resource_context, | 2121 resource_context, |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2436 load_flags |= net::LOAD_PREFETCH; | 2442 load_flags |= net::LOAD_PREFETCH; |
2437 } | 2443 } |
2438 | 2444 |
2439 if (is_sync_load) | 2445 if (is_sync_load) |
2440 load_flags |= net::LOAD_IGNORE_LIMITS; | 2446 load_flags |= net::LOAD_IGNORE_LIMITS; |
2441 | 2447 |
2442 return load_flags; | 2448 return load_flags; |
2443 } | 2449 } |
2444 | 2450 |
2445 } // namespace content | 2451 } // namespace content |
OLD | NEW |