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 26 matching lines...) Expand all Loading... |
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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); | 1162 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); |
1164 if (handler) { | 1163 if (handler) { |
1165 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { | 1164 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { |
1166 bad_message::ReceivedBadMessage( | 1165 bad_message::ReceivedBadMessage( |
1167 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); | 1166 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); |
1168 } else { | 1167 } else { |
1169 handler->CompleteCrossSiteTransfer( | 1168 handler->CompleteCrossSiteTransfer( |
1170 child_id, request_data.service_worker_provider_id); | 1169 child_id, request_data.service_worker_provider_id); |
1171 } | 1170 } |
1172 } | 1171 } |
1173 | |
1174 // We should have a CrossSiteResourceHandler to finish the transfer. | |
1175 DCHECK(info->cross_site_handler()); | |
1176 } | 1172 } |
1177 | 1173 |
1178 void ResourceDispatcherHostImpl::BeginRequest( | 1174 void ResourceDispatcherHostImpl::BeginRequest( |
1179 int request_id, | 1175 int request_id, |
1180 const ResourceRequest& request_data, | 1176 const ResourceRequest& request_data, |
1181 IPC::Message* sync_result, // only valid for sync | 1177 IPC::Message* sync_result, // only valid for sync |
1182 int route_id, | 1178 int route_id, |
1183 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 1179 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
1184 mojom::URLLoaderClientPtr url_loader_client) { | 1180 mojom::URLLoaderClientPtr url_loader_client) { |
1185 int process_type = filter_->process_type(); | 1181 int process_type = filter_->process_type(); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 std::unique_ptr<DetachableResourceHandler> detachable_handler = | 1567 std::unique_ptr<DetachableResourceHandler> detachable_handler = |
1572 base::MakeUnique<DetachableResourceHandler>( | 1568 base::MakeUnique<DetachableResourceHandler>( |
1573 request, | 1569 request, |
1574 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1570 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
1575 std::move(handler)); | 1571 std::move(handler)); |
1576 if (start_detached) | 1572 if (start_detached) |
1577 detachable_handler->Detach(); | 1573 detachable_handler->Detach(); |
1578 handler = std::move(detachable_handler); | 1574 handler = std::move(detachable_handler); |
1579 } | 1575 } |
1580 | 1576 |
1581 // PlzNavigate: If using --enable-browser-side-navigation, the | |
1582 // CrossSiteResourceHandler is not needed. This codepath is not used for the | |
1583 // actual navigation request, but only the subsequent blob URL load. This does | |
1584 // not require request transfers. | |
1585 if (!IsBrowserSideNavigationEnabled()) { | |
1586 // Install a CrossSiteResourceHandler for all main frame requests. This will | |
1587 // check whether a transfer is required and, if so, pause for the UI thread | |
1588 // to drive the transfer. | |
1589 bool is_swappable_navigation = | |
1590 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; | |
1591 // If out-of-process iframes are possible, then all subframe requests need | |
1592 // to go through the CrossSiteResourceHandler to enforce the site isolation | |
1593 // policy. | |
1594 if (!is_swappable_navigation && | |
1595 SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | |
1596 is_swappable_navigation = | |
1597 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | |
1598 } | |
1599 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
1600 handler.reset(new CrossSiteResourceHandler(std::move(handler), request)); | |
1601 } | |
1602 | |
1603 return AddStandardHandlers( | 1577 return AddStandardHandlers( |
1604 request, request_data.resource_type, resource_context, | 1578 request, request_data.resource_type, resource_context, |
1605 request_data.fetch_request_context_type, filter_->appcache_service(), | 1579 request_data.fetch_request_context_type, filter_->appcache_service(), |
1606 child_id, route_id, std::move(handler)); | 1580 child_id, route_id, std::move(handler)); |
1607 } | 1581 } |
1608 | 1582 |
1609 std::unique_ptr<ResourceHandler> | 1583 std::unique_ptr<ResourceHandler> |
1610 ResourceDispatcherHostImpl::AddStandardHandlers( | 1584 ResourceDispatcherHostImpl::AddStandardHandlers( |
1611 net::URLRequest* request, | 1585 net::URLRequest* request, |
1612 ResourceType resource_type, | 1586 ResourceType resource_type, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 &throttles); | 2694 &throttles); |
2721 if (!throttles.empty()) { | 2695 if (!throttles.empty()) { |
2722 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2696 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2723 std::move(throttles))); | 2697 std::move(throttles))); |
2724 } | 2698 } |
2725 } | 2699 } |
2726 return handler; | 2700 return handler; |
2727 } | 2701 } |
2728 | 2702 |
2729 } // namespace content | 2703 } // namespace content |
OLD | NEW |