| 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 ServiceWorkerNavigationHandleCore* service_worker_handle_core) { |
| 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 = | |
| 2088 GetChromeBlobStorageContextForResourceContext(resource_context); | |
| 2089 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2089 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 2090 new_request.get(), | 2090 new_request.get(), |
| 2091 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | 2091 blob_context->GetBlobDataFromPublicURL(new_request->url())); |
| 2092 } | 2092 } |
| 2093 | 2093 |
| 2094 // TODO(davidben): Attach ServiceWorkerRequestHandler. | 2094 RequestContextFrameType frame_type = |
| 2095 // TODO(michaeln): Help out with this and that. | 2095 info.is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL |
| 2096 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; |
| 2097 ServiceWorkerRequestHandler::InitializeForNavigation( |
| 2098 new_request.get(), service_worker_handle_core, blob_context, |
| 2099 info.begin_params.skip_service_worker, resource_type, |
| 2100 info.begin_params.request_context_type, frame_type, info.request_body); |
| 2101 |
| 2096 // TODO(davidben): Attach AppCacheInterceptor. | 2102 // TODO(davidben): Attach AppCacheInterceptor. |
| 2097 | 2103 |
| 2098 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | 2104 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( |
| 2099 new_request.get(), loader)); | 2105 new_request.get(), loader)); |
| 2100 | 2106 |
| 2101 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2107 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
| 2102 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2108 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
| 2103 // currently it's a no-op. | 2109 // currently it's a no-op. |
| 2104 handler = AddStandardHandlers(new_request.get(), resource_type, | 2110 handler = AddStandardHandlers(new_request.get(), resource_type, |
| 2105 resource_context, | 2111 resource_context, |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 load_flags |= net::LOAD_PREFETCH; | 2432 load_flags |= net::LOAD_PREFETCH; |
| 2427 } | 2433 } |
| 2428 | 2434 |
| 2429 if (is_sync_load) | 2435 if (is_sync_load) |
| 2430 load_flags |= net::LOAD_IGNORE_LIMITS; | 2436 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 2431 | 2437 |
| 2432 return load_flags; | 2438 return load_flags; |
| 2433 } | 2439 } |
| 2434 | 2440 |
| 2435 } // namespace content | 2441 } // namespace content |
| OLD | NEW |