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 int new_cert_id) { | |
428 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
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) | |
437 return; | |
438 | |
439 navigation_handle->UpdateSSLCertId(new_cert_id); | |
nasko
2016/08/25 18:09:48
I think it is still possible to have race conditio
jam
2016/08/25 21:56:46
this method is just for one case (cross-site trans
clamy
2016/08/25 23:25:14
Regarding the possible race condition, the issue c
clamy
2016/08/26 00:06:57
Looking at the code some more, I'm wondering if it
jam
2016/08/26 03:36:43
The first paragraph makes it sound like there's a
jam
2016/08/26 03:36:43
which method are you referring to?
clamy
2016/08/26 18:14:30
Hmm my first paragraph is not very clear. What I m
clamy
2016/08/26 18:14:30
It was just an optimization to avoid thread hops,.
| |
440 } | |
441 | |
424 } // namespace | 442 } // namespace |
425 | 443 |
426 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {} | 444 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {} |
427 | 445 |
428 ResourceDispatcherHostImpl::HeaderInterceptorInfo::~HeaderInterceptorInfo() {} | 446 ResourceDispatcherHostImpl::HeaderInterceptorInfo::~HeaderInterceptorInfo() {} |
429 | 447 |
430 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo( | 448 ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo( |
431 const HeaderInterceptorInfo& other) {} | 449 const HeaderInterceptorInfo& other) {} |
432 | 450 |
433 // static | 451 // 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 | 1217 // ResourceRequestInfo rather than caching it locally. This lets us update |
1200 // the info object when a transfer occurs. | 1218 // the info object when a transfer occurs. |
1201 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, | 1219 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, |
1202 request_data.origin_pid, request_id, | 1220 request_data.origin_pid, request_id, |
1203 filter_->GetWeakPtr()); | 1221 filter_->GetWeakPtr()); |
1204 | 1222 |
1205 // If a certificate is stored with the ResourceResponse, it has to be | 1223 // If a certificate is stored with the ResourceResponse, it has to be |
1206 // updated to be associated with the new process. | 1224 // updated to be associated with the new process. |
1207 if (loader->transferring_response()) { | 1225 if (loader->transferring_response()) { |
1208 UpdateResponseCertificateForTransfer(loader->transferring_response(), | 1226 UpdateResponseCertificateForTransfer(loader->transferring_response(), |
1209 loader->request()->ssl_info(), | 1227 loader->request(), |
1210 child_id); | 1228 info); |
1211 } | 1229 } |
1212 | 1230 |
1213 // Update maps that used the old IDs, if necessary. Some transfers in tests | 1231 // 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. | 1232 // do not actually use a different ID, so not all maps need to be updated. |
1215 pending_loaders_[new_request_id] = std::move(loader); | 1233 pending_loaders_[new_request_id] = std::move(loader); |
1216 IncrementOutstandingRequestsMemory(1, *info); | 1234 IncrementOutstandingRequestsMemory(1, *info); |
1217 if (should_update_count) | 1235 if (should_update_count) |
1218 IncrementOutstandingRequestsCount(1, info); | 1236 IncrementOutstandingRequestsCount(1, info); |
1219 if (old_routing_id != new_routing_id) { | 1237 if (old_routing_id != new_routing_id) { |
1220 if (blocked_loaders_map_.find(old_routing_id) != | 1238 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, | 1719 handler.reset(new MimeTypeResourceHandler(std::move(handler), this, |
1702 plugin_service, request)); | 1720 plugin_service, request)); |
1703 | 1721 |
1704 ScopedVector<ResourceThrottle> throttles; | 1722 ScopedVector<ResourceThrottle> throttles; |
1705 | 1723 |
1706 // Add a NavigationResourceThrottle for navigations. | 1724 // Add a NavigationResourceThrottle for navigations. |
1707 // PlzNavigate: the throttle is unnecessary as communication with the UI | 1725 // PlzNavigate: the throttle is unnecessary as communication with the UI |
1708 // thread is handled by the NavigationURLloader. | 1726 // thread is handled by the NavigationURLloader. |
1709 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) { | 1727 if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) { |
1710 throttles.push_back(new NavigationResourceThrottle( | 1728 throttles.push_back(new NavigationResourceThrottle( |
1711 request, delegate(), fetch_request_context_type)); | 1729 request, delegate_, GetCertStore(), fetch_request_context_type)); |
1712 } | 1730 } |
1713 | 1731 |
1714 if (delegate_) { | 1732 if (delegate_) { |
1715 delegate_->RequestBeginning(request, | 1733 delegate_->RequestBeginning(request, |
1716 resource_context, | 1734 resource_context, |
1717 appcache_service, | 1735 appcache_service, |
1718 resource_type, | 1736 resource_type, |
1719 &throttles); | 1737 &throttles); |
1720 } | 1738 } |
1721 | 1739 |
(...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 | 2308 // Hang on to a reference to ensure the blob is not released prior |
2291 // to the job being started. | 2309 // to the job being started. |
2292 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2310 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2293 new_request.get(), | 2311 new_request.get(), |
2294 blob_context->GetBlobDataFromPublicURL(new_request->url())); | 2312 blob_context->GetBlobDataFromPublicURL(new_request->url())); |
2295 } | 2313 } |
2296 | 2314 |
2297 // TODO(davidben): Attach AppCacheInterceptor. | 2315 // TODO(davidben): Attach AppCacheInterceptor. |
2298 | 2316 |
2299 std::unique_ptr<ResourceHandler> handler( | 2317 std::unique_ptr<ResourceHandler> handler( |
2300 new NavigationResourceHandler(new_request.get(), loader, delegate())); | 2318 new NavigationResourceHandler(new_request.get(), loader, delegate(), |
2319 GetCertStore())); | |
2301 | 2320 |
2302 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the | 2321 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the |
2303 // dependency on child_id/route_id. Those are used by the ResourceScheduler; | 2322 // dependency on child_id/route_id. Those are used by the ResourceScheduler; |
2304 // currently it's a no-op. | 2323 // currently it's a no-op. |
2305 handler = | 2324 handler = |
2306 AddStandardHandlers(new_request.get(), resource_type, resource_context, | 2325 AddStandardHandlers(new_request.get(), resource_type, resource_context, |
2307 info.begin_params.request_context_type, | 2326 info.begin_params.request_context_type, |
2308 nullptr, // appcache_service | 2327 nullptr, // appcache_service |
2309 -1, // child_id | 2328 -1, // child_id |
2310 -1, // route_id | 2329 -1, // route_id |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2638 } | 2657 } |
2639 | 2658 |
2640 if (is_sync_load) | 2659 if (is_sync_load) |
2641 load_flags |= net::LOAD_IGNORE_LIMITS; | 2660 load_flags |= net::LOAD_IGNORE_LIMITS; |
2642 | 2661 |
2643 return load_flags; | 2662 return load_flags; |
2644 } | 2663 } |
2645 | 2664 |
2646 void ResourceDispatcherHostImpl::UpdateResponseCertificateForTransfer( | 2665 void ResourceDispatcherHostImpl::UpdateResponseCertificateForTransfer( |
2647 ResourceResponse* response, | 2666 ResourceResponse* response, |
2648 const net::SSLInfo& ssl_info, | 2667 net::URLRequest* request, |
2649 int child_id) { | 2668 ResourceRequestInfoImpl* info) { |
2669 const net::SSLInfo& ssl_info = request->ssl_info(); | |
2650 if (!ssl_info.cert) | 2670 if (!ssl_info.cert) |
2651 return; | 2671 return; |
2652 SSLStatus ssl; | 2672 SSLStatus ssl; |
2653 // DeserializeSecurityInfo() often takes security info sent by a | 2673 // DeserializeSecurityInfo() often takes security info sent by a |
2654 // renderer as input, in which case it's important to check that the | 2674 // renderer as input, in which case it's important to check that the |
2655 // security info deserializes properly and kill the renderer if | 2675 // security info deserializes properly and kill the renderer if |
2656 // not. In this case, however, the security info has been provided by | 2676 // 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 | 2677 // the ResourceLoader, so it does not need to be treated as untrusted |
2658 // data. | 2678 // data. |
2659 bool deserialized = | 2679 bool deserialized = |
2660 DeserializeSecurityInfo(response->head.security_info, &ssl); | 2680 DeserializeSecurityInfo(response->head.security_info, &ssl); |
2661 DCHECK(deserialized); | 2681 DCHECK(deserialized); |
2662 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2682 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), |
2683 info->GetChildID()); | |
2663 response->head.security_info = SerializeSecurityInfo(ssl); | 2684 response->head.security_info = SerializeSecurityInfo(ssl); |
2685 | |
2686 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) { | |
2687 int render_process_id, render_frame_id; | |
2688 if (info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) { | |
2689 BrowserThread::PostTask(BrowserThread::UI, | |
2690 FROM_HERE, | |
2691 base::Bind(UpdateSSLStatus, | |
2692 render_process_id, | |
2693 render_frame_id, | |
2694 ssl.cert_id)); | |
2695 } | |
2696 } | |
2664 } | 2697 } |
2665 | 2698 |
2666 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2699 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2667 return cert_store_for_testing_ ? cert_store_for_testing_ | 2700 return cert_store_for_testing_ ? cert_store_for_testing_ |
2668 : CertStore::GetInstance(); | 2701 : CertStore::GetInstance(); |
2669 } | 2702 } |
2670 | 2703 |
2671 bool ResourceDispatcherHostImpl::ShouldServiceRequest( | 2704 bool ResourceDispatcherHostImpl::ShouldServiceRequest( |
2672 int process_type, | 2705 int process_type, |
2673 int child_id, | 2706 int child_id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2719 << iter->filesystem_url().spec(); | 2752 << iter->filesystem_url().spec(); |
2720 return false; | 2753 return false; |
2721 } | 2754 } |
2722 } | 2755 } |
2723 } | 2756 } |
2724 } | 2757 } |
2725 return true; | 2758 return true; |
2726 } | 2759 } |
2727 | 2760 |
2728 } // namespace content | 2761 } // namespace content |
OLD | NEW |