Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "content/browser/appcache/appcache_interceptor.h" | 28 #include "content/browser/appcache/appcache_interceptor.h" |
| 29 #include "content/browser/appcache/chrome_appcache_service.h" | 29 #include "content/browser/appcache/chrome_appcache_service.h" |
| 30 #include "content/browser/bad_message.h" | 30 #include "content/browser/bad_message.h" |
| 31 #include "content/browser/cert_store_impl.h" | 31 #include "content/browser/cert_store_impl.h" |
| 32 #include "content/browser/child_process_security_policy_impl.h" | 32 #include "content/browser/child_process_security_policy_impl.h" |
| 33 #include "content/browser/download/download_resource_handler.h" | 33 #include "content/browser/download/download_resource_handler.h" |
| 34 #include "content/browser/download/save_file_manager.h" | 34 #include "content/browser/download/save_file_manager.h" |
| 35 #include "content/browser/download/save_file_resource_handler.h" | 35 #include "content/browser/download/save_file_resource_handler.h" |
| 36 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 36 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 37 #include "content/browser/frame_host/navigation_request.h" | |
| 37 #include "content/browser/frame_host/navigation_request_info.h" | 38 #include "content/browser/frame_host/navigation_request_info.h" |
| 38 #include "content/browser/frame_host/navigator.h" | 39 #include "content/browser/frame_host/navigator.h" |
| 39 #include "content/browser/loader/async_resource_handler.h" | 40 #include "content/browser/loader/async_resource_handler.h" |
| 40 #include "content/browser/loader/cross_site_resource_handler.h" | 41 #include "content/browser/loader/cross_site_resource_handler.h" |
| 41 #include "content/browser/loader/detachable_resource_handler.h" | 42 #include "content/browser/loader/detachable_resource_handler.h" |
| 42 #include "content/browser/loader/mime_type_resource_handler.h" | 43 #include "content/browser/loader/mime_type_resource_handler.h" |
| 43 #include "content/browser/loader/navigation_resource_handler.h" | 44 #include "content/browser/loader/navigation_resource_handler.h" |
| 44 #include "content/browser/loader/navigation_resource_throttle.h" | 45 #include "content/browser/loader/navigation_resource_throttle.h" |
| 45 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 46 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| 46 #include "content/browser/loader/power_save_block_resource_throttle.h" | 47 #include "content/browser/loader/power_save_block_resource_throttle.h" |
| 47 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 48 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
| 48 #include "content/browser/loader/resource_message_filter.h" | 49 #include "content/browser/loader/resource_message_filter.h" |
| 49 #include "content/browser/loader/resource_request_info_impl.h" | 50 #include "content/browser/loader/resource_request_info_impl.h" |
| 50 #include "content/browser/loader/stream_resource_handler.h" | 51 #include "content/browser/loader/stream_resource_handler.h" |
| 51 #include "content/browser/loader/sync_resource_handler.h" | 52 #include "content/browser/loader/sync_resource_handler.h" |
| 52 #include "content/browser/loader/throttling_resource_handler.h" | 53 #include "content/browser/loader/throttling_resource_handler.h" |
| 53 #include "content/browser/loader/upload_data_stream_builder.h" | 54 #include "content/browser/loader/upload_data_stream_builder.h" |
| 54 #include "content/browser/renderer_host/render_view_host_delegate.h" | 55 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 55 #include "content/browser/renderer_host/render_view_host_impl.h" | 56 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 56 #include "content/browser/resource_context_impl.h" | 57 #include "content/browser/resource_context_impl.h" |
| 58 #include "content/browser/service_worker/service_worker_provider_host.h" | |
| 57 #include "content/browser/service_worker/service_worker_request_handler.h" | 59 #include "content/browser/service_worker/service_worker_request_handler.h" |
| 58 #include "content/browser/streams/stream.h" | 60 #include "content/browser/streams/stream.h" |
| 59 #include "content/browser/streams/stream_context.h" | 61 #include "content/browser/streams/stream_context.h" |
| 60 #include "content/browser/streams/stream_registry.h" | 62 #include "content/browser/streams/stream_registry.h" |
| 61 #include "content/browser/web_contents/web_contents_impl.h" | 63 #include "content/browser/web_contents/web_contents_impl.h" |
| 62 #include "content/common/appcache_interfaces.h" | 64 #include "content/common/appcache_interfaces.h" |
| 63 #include "content/common/navigation_params.h" | 65 #include "content/common/navigation_params.h" |
| 64 #include "content/common/resource_messages.h" | 66 #include "content/common/resource_messages.h" |
| 65 #include "content/common/site_isolation_policy.h" | 67 #include "content/common/site_isolation_policy.h" |
| 66 #include "content/common/ssl_status_serialization.h" | 68 #include "content/common/ssl_status_serialization.h" |
| (...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1949 } | 1951 } |
| 1950 | 1952 |
| 1951 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( | 1953 void ResourceDispatcherHostImpl::FinishedWithResourcesForRequest( |
| 1952 net::URLRequest* request) { | 1954 net::URLRequest* request) { |
| 1953 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1955 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
| 1954 IncrementOutstandingRequestsCount(-1, info); | 1956 IncrementOutstandingRequestsCount(-1, info); |
| 1955 } | 1957 } |
| 1956 | 1958 |
| 1957 void ResourceDispatcherHostImpl::BeginNavigationRequest( | 1959 void ResourceDispatcherHostImpl::BeginNavigationRequest( |
| 1958 ResourceContext* resource_context, | 1960 ResourceContext* resource_context, |
| 1959 int frame_tree_node_id, | |
| 1960 const NavigationRequestInfo& info, | 1961 const NavigationRequestInfo& info, |
| 1961 NavigationURLLoaderImplCore* loader) { | 1962 NavigationURLLoaderImplCore* loader, |
| 1963 ServiceWorkerContextWrapper* service_worker_context) { | |
|
michaeln
2015/10/01 01:42:15
interesting failure mode potential, what if
servi
Fabrice (no longer in Chrome)
2015/10/01 18:29:55
I'm not sure I follow? This is called from the loa
| |
| 1962 // PlzNavigate: BeginNavigationRequest currently should only be used for the | 1964 // PlzNavigate: BeginNavigationRequest currently should only be used for the |
| 1963 // browser-side navigations project. | 1965 // browser-side navigations project. |
| 1964 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1966 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1965 switches::kEnableBrowserSideNavigation)); | 1967 switches::kEnableBrowserSideNavigation)); |
| 1966 | 1968 |
| 1967 ResourceType resource_type = info.is_main_frame ? | 1969 ResourceType resource_type = info.is_main_frame ? |
| 1968 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; | 1970 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
| 1969 | 1971 |
| 1970 if (is_shutdown_ || | 1972 if (is_shutdown_ || |
| 1971 // TODO(davidben): Check ShouldServiceRequest here. This is important; it | 1973 // TODO(davidben): Check ShouldServiceRequest here. This is important; it |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2016 } | 2018 } |
| 2017 | 2019 |
| 2018 SetReferrerForRequest(new_request.get(), info.common_params.referrer); | 2020 SetReferrerForRequest(new_request.get(), info.common_params.referrer); |
| 2019 | 2021 |
| 2020 net::HttpRequestHeaders headers; | 2022 net::HttpRequestHeaders headers; |
| 2021 headers.AddHeadersFromString(info.begin_params.headers); | 2023 headers.AddHeadersFromString(info.begin_params.headers); |
| 2022 new_request->SetExtraRequestHeaders(headers); | 2024 new_request->SetExtraRequestHeaders(headers); |
| 2023 | 2025 |
| 2024 new_request->SetLoadFlags(load_flags); | 2026 new_request->SetLoadFlags(load_flags); |
| 2025 | 2027 |
| 2028 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
| 2029 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
| 2030 | |
| 2026 // Resolve elements from request_body and prepare upload data. | 2031 // Resolve elements from request_body and prepare upload data. |
| 2027 if (info.request_body.get()) { | 2032 if (info.request_body.get()) { |
| 2028 storage::BlobStorageContext* blob_context = GetBlobStorageContext( | |
| 2029 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
| 2030 AttachRequestBodyBlobDataHandles( | 2033 AttachRequestBodyBlobDataHandles( |
| 2031 info.request_body.get(), | 2034 info.request_body.get(), |
| 2032 blob_context); | 2035 blob_context); |
| 2033 // TODO(davidben): The FileSystemContext is null here. In the case where | 2036 // TODO(davidben): The FileSystemContext is null here. In the case where |
| 2034 // another renderer requested this navigation, this should be the same | 2037 // another renderer requested this navigation, this should be the same |
| 2035 // FileSystemContext passed into ShouldServiceRequest. | 2038 // FileSystemContext passed into ShouldServiceRequest. |
| 2036 new_request->set_upload(UploadDataStreamBuilder::Build( | 2039 new_request->set_upload(UploadDataStreamBuilder::Build( |
| 2037 info.request_body.get(), | 2040 info.request_body.get(), |
| 2038 blob_context, | 2041 blob_context, |
| 2039 nullptr, // file_system_context | 2042 nullptr, // file_system_context |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2085 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2088 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
| 2086 // Hang on to a reference to ensure the blob is not released prior | 2089 // Hang on to a reference to ensure the blob is not released prior |
| 2087 // to the job being started. | 2090 // to the job being started. |
| 2088 ChromeBlobStorageContext* blob_context = | 2091 ChromeBlobStorageContext* blob_context = |
| 2089 GetChromeBlobStorageContextForResourceContext(resource_context); | 2092 GetChromeBlobStorageContextForResourceContext(resource_context); |
| 2090 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2093 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 2091 new_request.get(), | 2094 new_request.get(), |
| 2092 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); | 2095 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); |
| 2093 } | 2096 } |
| 2094 | 2097 |
| 2095 // TODO(davidben): Attach ServiceWorkerRequestHandler. | 2098 RequestContextFrameType frame_type = info.is_main_frame ? |
| 2096 // TODO(michaeln): Help out with this and that. | 2099 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL : |
| 2100 REQUEST_CONTEXT_FRAME_TYPE_NESTED; | |
| 2101 // TODO: sync loads should set skip_service_worker to true. | |
|
michaeln
2015/10/01 01:42:15
can there be a sync plznav load? if not probably s
Fabrice (no longer in Chrome)
2015/10/01 18:29:55
This is now taken care of, see comments in render_
| |
| 2102 ServiceWorkerRequestHandler::InitializeForNavigation( | |
| 2103 new_request.get(), | |
| 2104 service_worker_context, | |
| 2105 blob_context, | |
| 2106 info.request_params.service_worker_provider_id, | |
| 2107 info.begin_params.skip_service_worker, | |
| 2108 resource_type, | |
| 2109 info.begin_params.request_context_type, | |
| 2110 frame_type, | |
| 2111 info.request_body); | |
| 2112 | |
| 2097 // TODO(davidben): Attach AppCacheInterceptor. | 2113 // TODO(davidben): Attach AppCacheInterceptor. |
| 2098 | 2114 |
| 2099 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( | 2115 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( |
| 2100 new_request.get(), loader)); | 2116 new_request.get(), loader)); |
| 2101 | 2117 |
| 2102 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2118 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
| 2103 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2119 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
| 2104 // currently it's a no-op. | 2120 // currently it's a no-op. |
| 2105 handler = AddStandardHandlers(new_request.get(), resource_type, | 2121 handler = AddStandardHandlers(new_request.get(), resource_type, |
| 2106 resource_context, | 2122 resource_context, |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2427 load_flags |= net::LOAD_PREFETCH; | 2443 load_flags |= net::LOAD_PREFETCH; |
| 2428 } | 2444 } |
| 2429 | 2445 |
| 2430 if (is_sync_load) | 2446 if (is_sync_load) |
| 2431 load_flags |= net::LOAD_IGNORE_LIMITS; | 2447 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 2432 | 2448 |
| 2433 return load_flags; | 2449 return load_flags; |
| 2434 } | 2450 } |
| 2435 | 2451 |
| 2436 } // namespace content | 2452 } // namespace content |
| OLD | NEW |