Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2321543002: Merge CrossSiteResourceHandler and NavigationResourceThrottle (Closed)
Patch Set: Fixed test compilation error Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
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/frame_host/frame_tree.h" 42 #include "content/browser/frame_host/frame_tree.h"
43 #include "content/browser/frame_host/navigation_handle_impl.h" 43 #include "content/browser/frame_host/navigation_handle_impl.h"
44 #include "content/browser/frame_host/navigation_request_info.h" 44 #include "content/browser/frame_host/navigation_request_info.h"
45 #include "content/browser/frame_host/navigator.h" 45 #include "content/browser/frame_host/navigator.h"
46 #include "content/browser/loader/async_resource_handler.h" 46 #include "content/browser/loader/async_resource_handler.h"
47 #include "content/browser/loader/async_revalidation_manager.h" 47 #include "content/browser/loader/async_revalidation_manager.h"
48 #include "content/browser/loader/cross_site_resource_handler.h"
49 #include "content/browser/loader/detachable_resource_handler.h" 48 #include "content/browser/loader/detachable_resource_handler.h"
50 #include "content/browser/loader/intercepting_resource_handler.h" 49 #include "content/browser/loader/intercepting_resource_handler.h"
51 #include "content/browser/loader/loader_delegate.h" 50 #include "content/browser/loader/loader_delegate.h"
52 #include "content/browser/loader/mime_sniffing_resource_handler.h" 51 #include "content/browser/loader/mime_sniffing_resource_handler.h"
53 #include "content/browser/loader/mojo_async_resource_handler.h" 52 #include "content/browser/loader/mojo_async_resource_handler.h"
54 #include "content/browser/loader/navigation_resource_handler.h" 53 #include "content/browser/loader/navigation_resource_handler.h"
55 #include "content/browser/loader/navigation_resource_throttle.h" 54 #include "content/browser/loader/navigation_resource_throttle.h"
56 #include "content/browser/loader/navigation_url_loader_impl_core.h" 55 #include "content/browser/loader/navigation_url_loader_impl_core.h"
57 #include "content/browser/loader/power_save_block_resource_throttle.h" 56 #include "content/browser/loader/power_save_block_resource_throttle.h"
58 #include "content/browser/loader/redirect_to_file_resource_handler.h" 57 #include "content/browser/loader/redirect_to_file_resource_handler.h"
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 1142
1144 // ResourceHandlers should always get state related to the request from the 1143 // ResourceHandlers should always get state related to the request from the
1145 // ResourceRequestInfo rather than caching it locally. This lets us update 1144 // ResourceRequestInfo rather than caching it locally. This lets us update
1146 // the info object when a transfer occurs. 1145 // the info object when a transfer occurs.
1147 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, 1146 info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id,
1148 request_data.origin_pid, request_id, 1147 request_data.origin_pid, request_id,
1149 filter_->GetWeakPtr()); 1148 filter_->GetWeakPtr());
1150 1149
1151 // If a certificate is stored with the ResourceResponse, it has to be 1150 // If a certificate is stored with the ResourceResponse, it has to be
1152 // updated to be associated with the new process. 1151 // updated to be associated with the new process.
1153 if (loader->transferring_response()) { 1152 if (loader->response()) {
1154 UpdateResponseCertificateForTransfer(loader->transferring_response(), 1153 UpdateResponseCertificateForTransfer(loader->response(),
1155 loader->request(), 1154 loader->request(),
1156 info); 1155 info);
1157 } 1156 }
1158 1157
1159 // Update maps that used the old IDs, if necessary. Some transfers in tests 1158 // Update maps that used the old IDs, if necessary. Some transfers in tests
1160 // do not actually use a different ID, so not all maps need to be updated. 1159 // do not actually use a different ID, so not all maps need to be updated.
1161 pending_loaders_[new_request_id] = std::move(loader); 1160 pending_loaders_[new_request_id] = std::move(loader);
1162 IncrementOutstandingRequestsMemory(1, *info); 1161 IncrementOutstandingRequestsMemory(1, *info);
1163 if (should_update_count) 1162 if (should_update_count)
1164 IncrementOutstandingRequestsCount(1, info); 1163 IncrementOutstandingRequestsCount(1, info);
(...skipping 30 matching lines...) Expand all
1195 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); 1194 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request());
1196 if (handler) { 1195 if (handler) {
1197 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { 1196 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) {
1198 bad_message::ReceivedBadMessage( 1197 bad_message::ReceivedBadMessage(
1199 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); 1198 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION);
1200 } else { 1199 } else {
1201 handler->CompleteCrossSiteTransfer( 1200 handler->CompleteCrossSiteTransfer(
1202 child_id, request_data.service_worker_provider_id); 1201 child_id, request_data.service_worker_provider_id);
1203 } 1202 }
1204 } 1203 }
1205
1206 // We should have a CrossSiteResourceHandler to finish the transfer.
1207 DCHECK(info->cross_site_handler());
1208 } 1204 }
1209 1205
1210 void ResourceDispatcherHostImpl::BeginRequest( 1206 void ResourceDispatcherHostImpl::BeginRequest(
1211 int request_id, 1207 int request_id,
1212 const ResourceRequest& request_data, 1208 const ResourceRequest& request_data,
1213 IPC::Message* sync_result, // only valid for sync 1209 IPC::Message* sync_result, // only valid for sync
1214 int route_id, 1210 int route_id,
1215 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1211 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
1216 mojom::URLLoaderClientPtr url_loader_client) { 1212 mojom::URLLoaderClientPtr url_loader_client) {
1217 int process_type = filter_->process_type(); 1213 int process_type = filter_->process_type();
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 } 1584 }
1589 1585
1590 // Prefetches and <a ping> requests outlive their child process. 1586 // Prefetches and <a ping> requests outlive their child process.
1591 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { 1587 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) {
1592 handler.reset(new DetachableResourceHandler( 1588 handler.reset(new DetachableResourceHandler(
1593 request, 1589 request,
1594 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), 1590 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1595 std::move(handler))); 1591 std::move(handler)));
1596 } 1592 }
1597 1593
1598 // PlzNavigate: If using --enable-browser-side-navigation, the
1599 // CrossSiteResourceHandler is not needed. This codepath is not used for the
1600 // actual navigation request, but only the subsequent blob URL load. This does
1601 // not require request transfers.
1602 if (!IsBrowserSideNavigationEnabled()) {
1603 // Install a CrossSiteResourceHandler for all main frame requests. This will
1604 // check whether a transfer is required and, if so, pause for the UI thread
1605 // to drive the transfer.
1606 bool is_swappable_navigation =
1607 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME;
1608 // If out-of-process iframes are possible, then all subframe requests need
1609 // to go through the CrossSiteResourceHandler to enforce the site isolation
1610 // policy.
1611 if (!is_swappable_navigation &&
1612 SiteIsolationPolicy::AreCrossProcessFramesPossible()) {
1613 is_swappable_navigation =
1614 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME;
1615 }
1616 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER)
1617 handler.reset(new CrossSiteResourceHandler(std::move(handler), request));
1618 }
1619
1620 return AddStandardHandlers( 1594 return AddStandardHandlers(
1621 request, request_data.resource_type, resource_context, 1595 request, request_data.resource_type, resource_context,
1622 request_data.fetch_request_context_type, filter_->appcache_service(), 1596 request_data.fetch_request_context_type, filter_->appcache_service(),
1623 child_id, route_id, std::move(handler)); 1597 child_id, route_id, std::move(handler));
1624 } 1598 }
1625 1599
1626 std::unique_ptr<ResourceHandler> 1600 std::unique_ptr<ResourceHandler>
1627 ResourceDispatcherHostImpl::AddStandardHandlers( 1601 ResourceDispatcherHostImpl::AddStandardHandlers(
1628 net::URLRequest* request, 1602 net::URLRequest* request,
1629 ResourceType resource_type, 1603 ResourceType resource_type,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 } 1828 }
1855 1829
1856 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, 1830 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id,
1857 int route_id, 1831 int route_id,
1858 bool is_loading) { 1832 bool is_loading) {
1859 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); 1833 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading);
1860 } 1834 }
1861 1835
1862 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( 1836 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
1863 const GlobalRequestID& id, 1837 const GlobalRequestID& id,
1864 const scoped_refptr<ResourceResponse>& response) { 1838 const base::Closure& on_transfer_complete_callback) {
1865 GetLoader(id)->MarkAsTransferring(response); 1839 GetLoader(id)->MarkAsTransferring(on_transfer_complete_callback);
1866 } 1840 }
1867 1841
1868 void ResourceDispatcherHostImpl::CancelTransferringNavigation( 1842 void ResourceDispatcherHostImpl::CancelTransferringNavigation(
1869 const GlobalRequestID& id) { 1843 const GlobalRequestID& id) {
1870 // Request should still exist and be in the middle of a transfer. 1844 // Request should still exist and be in the middle of a transfer.
1871 DCHECK(IsTransferredNavigation(id)); 1845 DCHECK(IsTransferredNavigation(id));
1872 RemovePendingRequest(id.child_id, id.request_id); 1846 RemovePendingRequest(id.child_id, id.request_id);
1873 } 1847 }
1874 1848
1875 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( 1849 void ResourceDispatcherHostImpl::ResumeDeferredNavigation(
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 request_info->GetRouteID(), is_content_initiated, true, &throttles); 2711 request_info->GetRouteID(), is_content_initiated, true, &throttles);
2738 if (!throttles.empty()) { 2712 if (!throttles.empty()) {
2739 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2713 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2740 std::move(throttles))); 2714 std::move(throttles)));
2741 } 2715 }
2742 } 2716 }
2743 return handler; 2717 return handler;
2744 } 2718 }
2745 2719
2746 } // namespace content 2720 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698