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 <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "base/message_loop/message_loop.h" | 27 #include "base/message_loop/message_loop.h" |
28 #include "base/metrics/field_trial.h" | 28 #include "base/metrics/field_trial.h" |
29 #include "base/metrics/histogram_macros.h" | 29 #include "base/metrics/histogram_macros.h" |
30 #include "base/metrics/sparse_histogram.h" | 30 #include "base/metrics/sparse_histogram.h" |
31 #include "base/profiler/scoped_tracker.h" | 31 #include "base/profiler/scoped_tracker.h" |
32 #include "base/stl_util.h" | 32 #include "base/stl_util.h" |
33 #include "base/strings/string_util.h" | 33 #include "base/strings/string_util.h" |
34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
35 #include "base/timer/timer.h" | 35 #include "base/timer/timer.h" |
36 #include "content/browser/appcache/appcache_interceptor.h" | 36 #include "content/browser/appcache/appcache_interceptor.h" |
| 37 #include "content/browser/appcache/appcache_navigation_handle_core.h" |
37 #include "content/browser/appcache/chrome_appcache_service.h" | 38 #include "content/browser/appcache/chrome_appcache_service.h" |
38 #include "content/browser/bad_message.h" | 39 #include "content/browser/bad_message.h" |
39 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 40 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
40 #include "content/browser/child_process_security_policy_impl.h" | 41 #include "content/browser/child_process_security_policy_impl.h" |
41 #include "content/browser/frame_host/frame_tree.h" | 42 #include "content/browser/frame_host/frame_tree.h" |
42 #include "content/browser/frame_host/navigation_handle_impl.h" | 43 #include "content/browser/frame_host/navigation_handle_impl.h" |
43 #include "content/browser/frame_host/navigation_request_info.h" | 44 #include "content/browser/frame_host/navigation_request_info.h" |
44 #include "content/browser/frame_host/navigator.h" | 45 #include "content/browser/frame_host/navigator.h" |
45 #include "content/browser/loader/async_resource_handler.h" | 46 #include "content/browser/loader/async_resource_handler.h" |
46 #include "content/browser/loader/async_revalidation_manager.h" | 47 #include "content/browser/loader/async_revalidation_manager.h" |
(...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 net::URLRequest* request) { | 2106 net::URLRequest* request) { |
2106 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 2107 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
2107 IncrementOutstandingRequestsCount(-1, info); | 2108 IncrementOutstandingRequestsCount(-1, info); |
2108 } | 2109 } |
2109 | 2110 |
2110 void ResourceDispatcherHostImpl::BeginNavigationRequest( | 2111 void ResourceDispatcherHostImpl::BeginNavigationRequest( |
2111 ResourceContext* resource_context, | 2112 ResourceContext* resource_context, |
2112 const NavigationRequestInfo& info, | 2113 const NavigationRequestInfo& info, |
2113 std::unique_ptr<NavigationUIData> navigation_ui_data, | 2114 std::unique_ptr<NavigationUIData> navigation_ui_data, |
2114 NavigationURLLoaderImplCore* loader, | 2115 NavigationURLLoaderImplCore* loader, |
2115 ServiceWorkerNavigationHandleCore* service_worker_handle_core) { | 2116 ServiceWorkerNavigationHandleCore* service_worker_handle_core, |
| 2117 AppCacheNavigationHandleCore* appcache_handle_core) { |
2116 // PlzNavigate: BeginNavigationRequest currently should only be used for the | 2118 // PlzNavigate: BeginNavigationRequest currently should only be used for the |
2117 // browser-side navigations project. | 2119 // browser-side navigations project. |
2118 CHECK(IsBrowserSideNavigationEnabled()); | 2120 CHECK(IsBrowserSideNavigationEnabled()); |
2119 | 2121 |
2120 ResourceType resource_type = info.is_main_frame ? | 2122 ResourceType resource_type = info.is_main_frame ? |
2121 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; | 2123 RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME; |
2122 | 2124 |
2123 // Do not allow browser plugin guests to navigate to non-web URLs, since they | 2125 // Do not allow browser plugin guests to navigate to non-web URLs, since they |
2124 // cannot swap processes or grant bindings. Do not check external protocols | 2126 // cannot swap processes or grant bindings. Do not check external protocols |
2125 // here because they're checked in | 2127 // here because they're checked in |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2261 | 2263 |
2262 RequestContextFrameType frame_type = | 2264 RequestContextFrameType frame_type = |
2263 info.is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL | 2265 info.is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL |
2264 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; | 2266 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; |
2265 ServiceWorkerRequestHandler::InitializeForNavigation( | 2267 ServiceWorkerRequestHandler::InitializeForNavigation( |
2266 new_request.get(), service_worker_handle_core, blob_context, | 2268 new_request.get(), service_worker_handle_core, blob_context, |
2267 info.begin_params.skip_service_worker, resource_type, | 2269 info.begin_params.skip_service_worker, resource_type, |
2268 info.begin_params.request_context_type, frame_type, | 2270 info.begin_params.request_context_type, frame_type, |
2269 info.are_ancestors_secure, info.common_params.post_data); | 2271 info.are_ancestors_secure, info.common_params.post_data); |
2270 | 2272 |
2271 // TODO(davidben): Attach AppCacheInterceptor. | 2273 // Have the appcache associate its extra info with the request. |
| 2274 if (appcache_handle_core) { |
| 2275 AppCacheInterceptor::SetExtraRequestInfoForHost( |
| 2276 new_request.get(), appcache_handle_core->host(), resource_type, false); |
| 2277 } |
2272 | 2278 |
2273 std::unique_ptr<ResourceHandler> handler( | 2279 std::unique_ptr<ResourceHandler> handler( |
2274 new NavigationResourceHandler(new_request.get(), loader, delegate())); | 2280 new NavigationResourceHandler(new_request.get(), loader, delegate())); |
2275 | 2281 |
2276 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2282 // TODO(davidben): Fix the dependency on child_id/route_id. Those are used |
2277 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2283 // by the ResourceScheduler. currently it's a no-op. |
2278 // currently it's a no-op. | 2284 handler = AddStandardHandlers( |
2279 handler = | 2285 new_request.get(), resource_type, resource_context, |
2280 AddStandardHandlers(new_request.get(), resource_type, resource_context, | 2286 info.begin_params.request_context_type, |
2281 info.begin_params.request_context_type, | 2287 appcache_handle_core ? appcache_handle_core->GetAppCacheService() |
2282 nullptr, // appcache_service | 2288 : nullptr, |
2283 -1, // child_id | 2289 -1, // child_id |
2284 -1, // route_id | 2290 -1, // route_id |
2285 std::move(handler)); | 2291 std::move(handler)); |
2286 | 2292 |
2287 BeginRequestInternal(std::move(new_request), std::move(handler)); | 2293 BeginRequestInternal(std::move(new_request), std::move(handler)); |
2288 } | 2294 } |
2289 | 2295 |
2290 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { | 2296 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { |
2291 if (!async_revalidation_manager_) | 2297 if (!async_revalidation_manager_) |
2292 async_revalidation_manager_.reset(new AsyncRevalidationManager); | 2298 async_revalidation_manager_.reset(new AsyncRevalidationManager); |
2293 } | 2299 } |
2294 | 2300 |
2295 void ResourceDispatcherHostImpl::SetLoaderDelegate( | 2301 void ResourceDispatcherHostImpl::SetLoaderDelegate( |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 &throttles); | 2820 &throttles); |
2815 if (!throttles.empty()) { | 2821 if (!throttles.empty()) { |
2816 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2822 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2817 std::move(throttles))); | 2823 std::move(throttles))); |
2818 } | 2824 } |
2819 } | 2825 } |
2820 return handler; | 2826 return handler; |
2821 } | 2827 } |
2822 | 2828 |
2823 } // namespace content | 2829 } // namespace content |
OLD | NEW |