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 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1950 | 1950 |
1951 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( | 1951 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( |
1952 net::URLRequest* request) { | 1952 net::URLRequest* request) { |
1953 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1953 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
1954 IncrementOutstandingRequestsCount(-1, info); | 1954 IncrementOutstandingRequestsCount(-1, info); |
1955 } | 1955 } |
1956 | 1956 |
1957 void ResourceDispatcherHostImpl::BeginNavigationRequest( | 1957 void ResourceDispatcherHostImpl::BeginNavigationRequest( |
1958 ResourceContext* resource_context, | 1958 ResourceContext* resource_context, |
1959 const NavigationRequestInfo& info, | 1959 const NavigationRequestInfo& info, |
1960 NavigationURLLoaderImplCore* loader) { | 1960 NavigationURLLoaderImplCore* loader, |
1961 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) { | |
1961 // PlzNavigate: BeginNavigationRequest currently should only be used for the | 1962 // PlzNavigate: BeginNavigationRequest currently should only be used for the |
1962 // browser-side navigations project. | 1963 // browser-side navigations project. |
1963 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1964 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
1964 switches::kEnableBrowserSideNavigation)); | 1965 switches::kEnableBrowserSideNavigation)); |
1965 | 1966 |
1966 ResourceType resource_type = info.is_main_frame ? | 1967 ResourceType resource_type = info.is_main_frame ? |
1967 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; | 1968 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
1968 | 1969 |
1969 if (is_shutdown_ || | 1970 if (is_shutdown_ || |
1970 // TODO(davidben): Check ShouldServiceRequest here. This is important; it | 1971 // TODO(davidben): Check ShouldServiceRequest here. This is important; it |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2015 } | 2016 } |
2016 | 2017 |
2017 SetReferrerForRequest(new_request.get(), info.common_params.referrer); | 2018 SetReferrerForRequest(new_request.get(), info.common_params.referrer); |
2018 | 2019 |
2019 net::HttpRequestHeaders headers; | 2020 net::HttpRequestHeaders headers; |
2020 headers.AddHeadersFromString(info.begin_params.headers); | 2021 headers.AddHeadersFromString(info.begin_params.headers); |
2021 new_request->SetExtraRequestHeaders(headers); | 2022 new_request->SetExtraRequestHeaders(headers); |
2022 | 2023 |
2023 new_request->SetLoadFlags(load_flags); | 2024 new_request->SetLoadFlags(load_flags); |
2024 | 2025 |
2026 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
2027 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
2028 | |
2025 // Resolve elements from request_body and prepare upload data. | 2029 // Resolve elements from request_body and prepare upload data. |
2026 if (info.request_body.get()) { | 2030 if (info.request_body.get()) { |
2027 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
2028 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
2029 AttachRequestBodyBlobDataHandles( | 2031 AttachRequestBodyBlobDataHandles( |
2030 info.request_body.get(), | 2032 info.request_body.get(), |
2031 blob_context); | 2033 blob_context); |
2032 // TODO(davidben): The FileSystemContext is null here. In the case where | 2034 // TODO(davidben): The FileSystemContext is null here. In the case where |
2033 // another renderer requested this navigation, this should be the same | 2035 // another renderer requested this navigation, this should be the same |
2034 // FileSystemContext passed into ShouldServiceRequest. | 2036 // FileSystemContext passed into ShouldServiceRequest. |
2035 new_request->set_upload(UploadDataStreamBuilder::Build( | 2037 new_request->set_upload(UploadDataStreamBuilder::Build( |
2036 info.request_body.get(), | 2038 info.request_body.get(), |
2037 blob_context, | 2039 blob_context, |
2038 nullptr, // file_system_context | 2040 nullptr, // file_system_context |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2077 resource_context, | 2079 resource_context, |
2078 base::WeakPtr<ResourceMessageFilter>(), // filter | 2080 base::WeakPtr<ResourceMessageFilter>(), // filter |
2079 false, // request_data.report_raw_headers | 2081 false, // request_data.report_raw_headers |
2080 true); | 2082 true); |
2081 // Request takes ownership. | 2083 // Request takes ownership. |
2082 extra_info->AssociateWithRequest(new_request.get()); | 2084 extra_info->AssociateWithRequest(new_request.get()); |
2083 | 2085 |
2084 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2086 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
2085 // Hang on to a reference to ensure the blob is not released prior | 2087 // Hang on to a reference to ensure the blob is not released prior |
2086 // to the job being started. | 2088 // to the job being started. |
2087 ChromeBlobStorageContext* blob_context = | 2089 ChromeBlobStorageContext* chrome_blob_context = |
2088 GetChromeBlobStorageContextForResourceContext(resource_context); | 2090 GetChromeBlobStorageContextForResourceContext(resource_context); |
2089 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2091 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2090 new_request.get(), | 2092 new_request.get(), |
2091 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | 2093 chrome_blob_context->context()->GetBlobDataFromPublicURL( |
michaeln
2015/10/07 01:16:44
you could directly use the existing local here
blo
Fabrice (no longer in Chrome)
2015/10/07 12:59:43
It seems like we should have been using the same t
| |
2094 new_request->url())); | |
2092 } | 2095 } |
2093 | 2096 |
2094 // TODO(davidben): Attach ServiceWorkerRequestHandler. | 2097 RequestContextFrameType frame_type = |
2095 // TODO(michaeln): Help out with this and that. | 2098 info.is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL |
2099 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; | |
2100 ServiceWorkerRequestHandler::InitializeForNavigation( | |
2101 new_request.get(), service_worker_context.get(), blob_context, | |
2102 info.service_worker_provider_id, info.begin_params.skip_service_worker, | |
2103 resource_type, info.begin_params.request_context_type, frame_type, | |
2104 info.request_body); | |
2105 | |
2096 // TODO(davidben): Attach AppCacheInterceptor. | 2106 // TODO(davidben): Attach AppCacheInterceptor. |
2097 | 2107 |
2098 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | 2108 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( |
2099 new_request.get(), loader)); | 2109 new_request.get(), loader)); |
2100 | 2110 |
2101 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2111 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
2102 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2112 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
2103 // currently it's a no-op. | 2113 // currently it's a no-op. |
2104 handler = AddStandardHandlers(new_request.get(), resource_type, | 2114 handler = AddStandardHandlers(new_request.get(), resource_type, |
2105 resource_context, | 2115 resource_context, |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2426 load_flags |= net::LOAD_PREFETCH; | 2436 load_flags |= net::LOAD_PREFETCH; |
2427 } | 2437 } |
2428 | 2438 |
2429 if (is_sync_load) | 2439 if (is_sync_load) |
2430 load_flags |= net::LOAD_IGNORE_LIMITS; | 2440 load_flags |= net::LOAD_IGNORE_LIMITS; |
2431 | 2441 |
2432 return load_flags; | 2442 return load_flags; |
2433 } | 2443 } |
2434 | 2444 |
2435 } // namespace content | 2445 } // namespace content |
OLD | NEW |