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

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

Issue 2321543002: Merge CrossSiteResourceHandler and NavigationResourceThrottle (Closed)
Patch Set: Addressed comments 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 26 matching lines...) Expand all
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/child_process_security_policy_impl.h" 40 #include "content/browser/child_process_security_policy_impl.h"
41 #include "content/browser/frame_host/frame_tree.h" 41 #include "content/browser/frame_host/frame_tree.h"
42 #include "content/browser/frame_host/navigation_handle_impl.h" 42 #include "content/browser/frame_host/navigation_handle_impl.h"
43 #include "content/browser/frame_host/navigation_request_info.h" 43 #include "content/browser/frame_host/navigation_request_info.h"
44 #include "content/browser/frame_host/navigator.h" 44 #include "content/browser/frame_host/navigator.h"
45 #include "content/browser/loader/async_resource_handler.h" 45 #include "content/browser/loader/async_resource_handler.h"
46 #include "content/browser/loader/async_revalidation_manager.h" 46 #include "content/browser/loader/async_revalidation_manager.h"
47 #include "content/browser/loader/cross_site_resource_handler.h"
48 #include "content/browser/loader/detachable_resource_handler.h" 47 #include "content/browser/loader/detachable_resource_handler.h"
49 #include "content/browser/loader/intercepting_resource_handler.h" 48 #include "content/browser/loader/intercepting_resource_handler.h"
50 #include "content/browser/loader/loader_delegate.h" 49 #include "content/browser/loader/loader_delegate.h"
51 #include "content/browser/loader/mime_sniffing_resource_handler.h" 50 #include "content/browser/loader/mime_sniffing_resource_handler.h"
52 #include "content/browser/loader/mojo_async_resource_handler.h" 51 #include "content/browser/loader/mojo_async_resource_handler.h"
53 #include "content/browser/loader/navigation_resource_handler.h" 52 #include "content/browser/loader/navigation_resource_handler.h"
54 #include "content/browser/loader/navigation_resource_throttle.h" 53 #include "content/browser/loader/navigation_resource_throttle.h"
55 #include "content/browser/loader/navigation_url_loader_impl_core.h" 54 #include "content/browser/loader/navigation_url_loader_impl_core.h"
56 #include "content/browser/loader/power_save_block_resource_throttle.h" 55 #include "content/browser/loader/power_save_block_resource_throttle.h"
57 #include "content/browser/loader/redirect_to_file_resource_handler.h" 56 #include "content/browser/loader/redirect_to_file_resource_handler.h"
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); 1163 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request());
1165 if (handler) { 1164 if (handler) {
1166 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { 1165 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) {
1167 bad_message::ReceivedBadMessage( 1166 bad_message::ReceivedBadMessage(
1168 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); 1167 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION);
1169 } else { 1168 } else {
1170 handler->CompleteCrossSiteTransfer( 1169 handler->CompleteCrossSiteTransfer(
1171 child_id, request_data.service_worker_provider_id); 1170 child_id, request_data.service_worker_provider_id);
1172 } 1171 }
1173 } 1172 }
1174
1175 // We should have a CrossSiteResourceHandler to finish the transfer.
1176 DCHECK(info->cross_site_handler());
1177 } 1173 }
1178 1174
1179 void ResourceDispatcherHostImpl::BeginRequest( 1175 void ResourceDispatcherHostImpl::BeginRequest(
1180 int request_id, 1176 int request_id,
1181 const ResourceRequest& request_data, 1177 const ResourceRequest& request_data,
1182 IPC::Message* sync_result, // only valid for sync 1178 IPC::Message* sync_result, // only valid for sync
1183 int route_id, 1179 int route_id,
1184 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1180 mojo::InterfaceRequest<mojom::URLLoader> mojo_request,
1185 mojom::URLLoaderClientPtr url_loader_client) { 1181 mojom::URLLoaderClientPtr url_loader_client) {
1186 int process_type = filter_->process_type(); 1182 int process_type = filter_->process_type();
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 std::unique_ptr<DetachableResourceHandler> detachable_handler = 1568 std::unique_ptr<DetachableResourceHandler> detachable_handler =
1573 base::MakeUnique<DetachableResourceHandler>( 1569 base::MakeUnique<DetachableResourceHandler>(
1574 request, 1570 request,
1575 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), 1571 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs),
1576 std::move(handler)); 1572 std::move(handler));
1577 if (start_detached) 1573 if (start_detached)
1578 detachable_handler->Detach(); 1574 detachable_handler->Detach();
1579 handler = std::move(detachable_handler); 1575 handler = std::move(detachable_handler);
1580 } 1576 }
1581 1577
1582 // PlzNavigate: If using --enable-browser-side-navigation, the
1583 // CrossSiteResourceHandler is not needed. This codepath is not used for the
1584 // actual navigation request, but only the subsequent blob URL load. This does
1585 // not require request transfers.
1586 if (!IsBrowserSideNavigationEnabled()) {
1587 // Install a CrossSiteResourceHandler for all main frame requests. This will
1588 // check whether a transfer is required and, if so, pause for the UI thread
1589 // to drive the transfer.
1590 bool is_swappable_navigation =
1591 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME;
1592 // If out-of-process iframes are possible, then all subframe requests need
1593 // to go through the CrossSiteResourceHandler to enforce the site isolation
1594 // policy.
1595 if (!is_swappable_navigation &&
1596 SiteIsolationPolicy::AreCrossProcessFramesPossible()) {
1597 is_swappable_navigation =
1598 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME;
1599 }
1600 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER)
1601 handler.reset(new CrossSiteResourceHandler(std::move(handler), request));
1602 }
1603
1604 return AddStandardHandlers( 1578 return AddStandardHandlers(
1605 request, request_data.resource_type, resource_context, 1579 request, request_data.resource_type, resource_context,
1606 request_data.fetch_request_context_type, filter_->appcache_service(), 1580 request_data.fetch_request_context_type, filter_->appcache_service(),
1607 child_id, route_id, std::move(handler)); 1581 child_id, route_id, std::move(handler));
1608 } 1582 }
1609 1583
1610 std::unique_ptr<ResourceHandler> 1584 std::unique_ptr<ResourceHandler>
1611 ResourceDispatcherHostImpl::AddStandardHandlers( 1585 ResourceDispatcherHostImpl::AddStandardHandlers(
1612 net::URLRequest* request, 1586 net::URLRequest* request,
1613 ResourceType resource_type, 1587 ResourceType resource_type,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 } 1812 }
1839 1813
1840 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, 1814 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id,
1841 int route_id, 1815 int route_id,
1842 bool is_loading) { 1816 bool is_loading) {
1843 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); 1817 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading);
1844 } 1818 }
1845 1819
1846 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( 1820 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
1847 const GlobalRequestID& id, 1821 const GlobalRequestID& id,
1848 const scoped_refptr<ResourceResponse>& response) { 1822 const base::Closure& on_transfer_complete_callback) {
1849 GetLoader(id)->MarkAsTransferring(response); 1823 GetLoader(id)->MarkAsTransferring(on_transfer_complete_callback);
1850 } 1824 }
1851 1825
1852 void ResourceDispatcherHostImpl::CancelTransferringNavigation( 1826 void ResourceDispatcherHostImpl::CancelTransferringNavigation(
1853 const GlobalRequestID& id) { 1827 const GlobalRequestID& id) {
1854 // Request should still exist and be in the middle of a transfer. 1828 // Request should still exist and be in the middle of a transfer.
1855 DCHECK(IsTransferredNavigation(id)); 1829 DCHECK(IsTransferredNavigation(id));
1856 RemovePendingRequest(id.child_id, id.request_id); 1830 RemovePendingRequest(id.child_id, id.request_id);
1857 } 1831 }
1858 1832
1859 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( 1833 void ResourceDispatcherHostImpl::ResumeDeferredNavigation(
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 &throttles); 2684 &throttles);
2711 if (!throttles.empty()) { 2685 if (!throttles.empty()) {
2712 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2686 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2713 std::move(throttles))); 2687 std::move(throttles)));
2714 } 2688 }
2715 } 2689 }
2716 return handler; 2690 return handler;
2717 } 2691 }
2718 2692
2719 } // namespace content 2693 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698