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 24 matching lines...) Expand all Loading... | |
35 #include "base/time/time.h" | 35 #include "base/time/time.h" |
36 #include "content/browser/appcache/appcache_interceptor.h" | 36 #include "content/browser/appcache/appcache_interceptor.h" |
37 #include "content/browser/appcache/chrome_appcache_service.h" | 37 #include "content/browser/appcache/chrome_appcache_service.h" |
38 #include "content/browser/bad_message.h" | 38 #include "content/browser/bad_message.h" |
39 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 39 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
40 #include "content/browser/cert_store_impl.h" | 40 #include "content/browser/cert_store_impl.h" |
41 #include "content/browser/child_process_security_policy_impl.h" | 41 #include "content/browser/child_process_security_policy_impl.h" |
42 #include "content/browser/download/download_resource_handler.h" | 42 #include "content/browser/download/download_resource_handler.h" |
43 #include "content/browser/download/save_file_resource_handler.h" | 43 #include "content/browser/download/save_file_resource_handler.h" |
44 #include "content/browser/frame_host/frame_tree.h" | 44 #include "content/browser/frame_host/frame_tree.h" |
45 #include "content/browser/frame_host/navigation_handle_impl.h" | |
45 #include "content/browser/frame_host/navigation_request_info.h" | 46 #include "content/browser/frame_host/navigation_request_info.h" |
46 #include "content/browser/frame_host/navigator.h" | 47 #include "content/browser/frame_host/navigator.h" |
47 #include "content/browser/loader/async_resource_handler.h" | 48 #include "content/browser/loader/async_resource_handler.h" |
48 #include "content/browser/loader/async_revalidation_manager.h" | 49 #include "content/browser/loader/async_revalidation_manager.h" |
49 #include "content/browser/loader/cross_site_resource_handler.h" | 50 #include "content/browser/loader/cross_site_resource_handler.h" |
50 #include "content/browser/loader/detachable_resource_handler.h" | 51 #include "content/browser/loader/detachable_resource_handler.h" |
51 #include "content/browser/loader/loader_delegate.h" | 52 #include "content/browser/loader/loader_delegate.h" |
52 #include "content/browser/loader/mime_type_resource_handler.h" | 53 #include "content/browser/loader/mime_type_resource_handler.h" |
53 #include "content/browser/loader/mojo_async_resource_handler.h" | 54 #include "content/browser/loader/mojo_async_resource_handler.h" |
54 #include "content/browser/loader/navigation_resource_handler.h" | 55 #include "content/browser/loader/navigation_resource_handler.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 if (frame_host) | 415 if (frame_host) |
415 routing_ids->insert(frame_host->GetGlobalFrameRoutingId()); | 416 routing_ids->insert(frame_host->GetGlobalFrameRoutingId()); |
416 if (pending_frame_host) | 417 if (pending_frame_host) |
417 routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId()); | 418 routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId()); |
418 } | 419 } |
419 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 420 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
420 base::Bind(&NotifyForRouteSetOnIO, frame_callback, | 421 base::Bind(&NotifyForRouteSetOnIO, frame_callback, |
421 base::Passed(std::move(routing_ids)))); | 422 base::Passed(std::move(routing_ids)))); |
422 } | 423 } |
423 | 424 |
425 void UpdateSSLStatus(int render_process_id, | |
426 int render_frame_host_id, | |
427 const GURL& url, | |
428 int new_cert_id) { | |
429 RenderFrameHostImpl* render_frame_host = | |
430 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id); | |
431 if (!render_frame_host) | |
432 return; | |
433 | |
434 NavigationHandleImpl* navigation_handle = | |
435 render_frame_host->navigation_handle(); | |
436 if (navigation_handle && navigation_handle->GetURL() == url) | |
437 navigation_handle->UpdateSSLCertId(new_cert_id); | |
438 } | |
439 | |
424 } // namespace | 440 } // namespace |
425 | 441 |
426 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {} | 442 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {} |
427 | 443 |
428 ResourceDispatcherHostImpl::HeaderInterceptorInfo::~HeaderInterceptorInfo() {} | 444 ResourceDispatcherHostImpl::HeaderInterceptorInfo::~HeaderInterceptorInfo() {} |
429 | 445 |
430 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo( | 446 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo( |
431 const HeaderInterceptorInfo& other) {} | 447 const HeaderInterceptorInfo& other) {} |
432 | 448 |
433 // static | 449 // static |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1199 // ResourceRequestInfo rather than caching it locally. This lets us update | 1215 // ResourceRequestInfo rather than caching it locally. This lets us update |
1200 // the info object when a transfer occurs. | 1216 // the info object when a transfer occurs. |
1201 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, | 1217 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, |
1202 request_data.origin_pid, request_id, | 1218 request_data.origin_pid, request_id, |
1203 filter_->GetWeakPtr()); | 1219 filter_->GetWeakPtr()); |
1204 | 1220 |
1205 // If a certificate is stored with the ResourceResponse, it has to be | 1221 // If a certificate is stored with the ResourceResponse, it has to be |
1206 // updated to be associated with the new process. | 1222 // updated to be associated with the new process. |
1207 if (loader->transferring_response()) { | 1223 if (loader->transferring_response()) { |
1208 UpdateResponseCertificateForTransfer(loader->transferring_response(), | 1224 UpdateResponseCertificateForTransfer(loader->transferring_response(), |
1209 loader->request()->ssl_info(), | 1225 loader->request(), |
1210 child_id); | 1226 info); |
1211 } | 1227 } |
1212 | 1228 |
1213 // Update maps that used the old IDs, if necessary. Some transfers in tests | 1229 // Update maps that used the old IDs, if necessary. Some transfers in tests |
1214 // do not actually use a different ID, so not all maps need to be updated. | 1230 // do not actually use a different ID, so not all maps need to be updated. |
1215 pending_loaders_[new_request_id] = std::move(loader); | 1231 pending_loaders_[new_request_id] = std::move(loader); |
1216 IncrementOutstandingRequestsMemory(1, *info); | 1232 IncrementOutstandingRequestsMemory(1, *info); |
1217 if (should_update_count) | 1233 if (should_update_count) |
1218 IncrementOutstandingRequestsCount(1, info); | 1234 IncrementOutstandingRequestsCount(1, info); |
1219 if (old_routing_id != new_routing_id) { | 1235 if (old_routing_id != new_routing_id) { |
1220 if (blocked_loaders_map_.find(old_routing_id) != | 1236 if (blocked_loaders_map_.find(old_routing_id) != |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1701 handler.reset(new MimeTypeResourceHandler(std::move(handler), this, | 1717 handler.reset(new MimeTypeResourceHandler(std::move(handler), this, |
1702 plugin_service, request)); | 1718 plugin_service, request)); |
1703 | 1719 |
1704 ScopedVector<ResourceThrottle> throttles; | 1720 ScopedVector<ResourceThrottle> throttles; |
1705 | 1721 |
1706 // Add a NavigationResourceThrottle for navigations. | 1722 // Add a NavigationResourceThrottle for navigations. |
1707 // PlzNavigate: the throttle is unnecessary as communication with the UI | 1723 // PlzNavigate: the throttle is unnecessary as communication with the UI |
1708 // thread is handled by the NavigationURLloader. | 1724 // thread is handled by the NavigationURLloader. |
1709 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) { | 1725 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) { |
1710 throttles.push_back(new NavigationResourceThrottle( | 1726 throttles.push_back(new NavigationResourceThrottle( |
1711 request, delegate(), fetch_request_context_type)); | 1727 request, delegate_, GetCertStore(), fetch_request_context_type)); |
1712 } | 1728 } |
1713 | 1729 |
1714 if (delegate_) { | 1730 if (delegate_) { |
1715 delegate_->RequestBeginning(request, | 1731 delegate_->RequestBeginning(request, |
1716 resource_context, | 1732 resource_context, |
1717 appcache_service, | 1733 appcache_service, |
1718 resource_type, | 1734 resource_type, |
1719 &throttles); | 1735 &throttles); |
1720 } | 1736 } |
1721 | 1737 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2290 // Hang on to a reference to ensure the blob is not released prior | 2306 // Hang on to a reference to ensure the blob is not released prior |
2291 // to the job being started. | 2307 // to the job being started. |
2292 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2308 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2293 new_request.get(), | 2309 new_request.get(), |
2294 blob_context->GetBlobDataFromPublicURL(new_request->url())); | 2310 blob_context->GetBlobDataFromPublicURL(new_request->url())); |
2295 } | 2311 } |
2296 | 2312 |
2297 // TODO(davidben): Attach AppCacheInterceptor. | 2313 // TODO(davidben): Attach AppCacheInterceptor. |
2298 | 2314 |
2299 std::unique_ptr<ResourceHandler> handler( | 2315 std::unique_ptr<ResourceHandler> handler( |
2300 new NavigationResourceHandler(new_request.get(), loader, delegate())); | 2316 new NavigationResourceHandler(new_request.get(), loader, delegate(), |
2317 GetCertStore())); | |
2301 | 2318 |
2302 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2319 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
2303 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2320 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
2304 // currently it's a no-op. | 2321 // currently it's a no-op. |
2305 handler = | 2322 handler = |
2306 AddStandardHandlers(new_request.get(), resource_type, resource_context, | 2323 AddStandardHandlers(new_request.get(), resource_type, resource_context, |
2307 info.begin_params.request_context_type, | 2324 info.begin_params.request_context_type, |
2308 nullptr, // appcache_service | 2325 nullptr, // appcache_service |
2309 -1, // child_id | 2326 -1, // child_id |
2310 -1, // route_id | 2327 -1, // route_id |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2638 } | 2655 } |
2639 | 2656 |
2640 if (is_sync_load) | 2657 if (is_sync_load) |
2641 load_flags |= net::LOAD_IGNORE_LIMITS; | 2658 load_flags |= net::LOAD_IGNORE_LIMITS; |
2642 | 2659 |
2643 return load_flags; | 2660 return load_flags; |
2644 } | 2661 } |
2645 | 2662 |
2646 void ResourceDispatcherHostImpl::UpdateResponseCertificateForTransfer( | 2663 void ResourceDispatcherHostImpl::UpdateResponseCertificateForTransfer( |
2647 ResourceResponse* response, | 2664 ResourceResponse* response, |
2648 const net::SSLInfo& ssl_info, | 2665 net::URLRequest* request, |
2649 int child_id) { | 2666 ResourceRequestInfoImpl* info) { |
2667 const net::SSLInfo& ssl_info = request->ssl_info(); | |
2650 if (!ssl_info.cert) | 2668 if (!ssl_info.cert) |
2651 return; | 2669 return; |
2652 SSLStatus ssl; | 2670 SSLStatus ssl; |
2653 // DeserializeSecurityInfo() often takes security info sent by a | 2671 // DeserializeSecurityInfo() often takes security info sent by a |
2654 // renderer as input, in which case it's important to check that the | 2672 // renderer as input, in which case it's important to check that the |
2655 // security info deserializes properly and kill the renderer if | 2673 // security info deserializes properly and kill the renderer if |
2656 // not. In this case, however, the security info has been provided by | 2674 // not. In this case, however, the security info has been provided by |
2657 // the ResourceLoader, so it does not need to be treated as untrusted | 2675 // the ResourceLoader, so it does not need to be treated as untrusted |
2658 // data. | 2676 // data. |
2659 bool deserialized = | 2677 bool deserialized = |
2660 DeserializeSecurityInfo(response->head.security_info, &ssl); | 2678 DeserializeSecurityInfo(response->head.security_info, &ssl); |
2661 DCHECK(deserialized); | 2679 DCHECK(deserialized); |
2662 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2680 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), |
2681 info->GetChildID()); | |
2663 response->head.security_info = SerializeSecurityInfo(ssl); | 2682 response->head.security_info = SerializeSecurityInfo(ssl); |
2683 | |
2684 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) { | |
2685 int render_process_id, render_frame_id; | |
clamy
2016/08/26 18:14:30
nit: Maybe we should mention somewhere that the pr
| |
2686 if (info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) { | |
2687 BrowserThread::PostTask(BrowserThread::UI, | |
2688 FROM_HERE, | |
2689 base::Bind(UpdateSSLStatus, | |
2690 render_process_id, | |
2691 render_frame_id, | |
2692 request->url(), | |
2693 ssl.cert_id)); | |
2694 } | |
2695 } | |
2664 } | 2696 } |
2665 | 2697 |
2666 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2698 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2667 return cert_store_for_testing_ ? cert_store_for_testing_ | 2699 return cert_store_for_testing_ ? cert_store_for_testing_ |
2668 : CertStore::GetInstance(); | 2700 : CertStore::GetInstance(); |
2669 } | 2701 } |
2670 | 2702 |
2671 bool ResourceDispatcherHostImpl::ShouldServiceRequest( | 2703 bool ResourceDispatcherHostImpl::ShouldServiceRequest( |
2672 int process_type, | 2704 int process_type, |
2673 int child_id, | 2705 int child_id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2719 << iter->filesystem_url().spec(); | 2751 << iter->filesystem_url().spec(); |
2720 return false; | 2752 return false; |
2721 } | 2753 } |
2722 } | 2754 } |
2723 } | 2755 } |
2724 } | 2756 } |
2725 return true; | 2757 return true; |
2726 } | 2758 } |
2727 | 2759 |
2728 } // namespace content | 2760 } // namespace content |
OLD | NEW |