| 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); | 1165 ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); |
| 1167 if (handler) { | 1166 if (handler) { |
| 1168 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { | 1167 if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { |
| 1169 bad_message::ReceivedBadMessage( | 1168 bad_message::ReceivedBadMessage( |
| 1170 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); | 1169 filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); |
| 1171 } else { | 1170 } else { |
| 1172 handler->CompleteCrossSiteTransfer( | 1171 handler->CompleteCrossSiteTransfer( |
| 1173 child_id, request_data.service_worker_provider_id); | 1172 child_id, request_data.service_worker_provider_id); |
| 1174 } | 1173 } |
| 1175 } | 1174 } |
| 1176 | |
| 1177 // We should have a CrossSiteResourceHandler to finish the transfer. | |
| 1178 DCHECK(info->cross_site_handler()); | |
| 1179 } | 1175 } |
| 1180 | 1176 |
| 1181 void ResourceDispatcherHostImpl::BeginRequest( | 1177 void ResourceDispatcherHostImpl::BeginRequest( |
| 1182 int request_id, | 1178 int request_id, |
| 1183 const ResourceRequest& request_data, | 1179 const ResourceRequest& request_data, |
| 1184 IPC::Message* sync_result, // only valid for sync | 1180 IPC::Message* sync_result, // only valid for sync |
| 1185 int route_id, | 1181 int route_id, |
| 1186 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 1182 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, |
| 1187 mojom::URLLoaderClientPtr url_loader_client) { | 1183 mojom::URLLoaderClientPtr url_loader_client) { |
| 1188 int process_type = filter_->process_type(); | 1184 int process_type = filter_->process_type(); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 std::unique_ptr<DetachableResourceHandler> detachable_handler = | 1570 std::unique_ptr<DetachableResourceHandler> detachable_handler = |
| 1575 base::MakeUnique<DetachableResourceHandler>( | 1571 base::MakeUnique<DetachableResourceHandler>( |
| 1576 request, | 1572 request, |
| 1577 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1573 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
| 1578 std::move(handler)); | 1574 std::move(handler)); |
| 1579 if (start_detached) | 1575 if (start_detached) |
| 1580 detachable_handler->Detach(); | 1576 detachable_handler->Detach(); |
| 1581 handler = std::move(detachable_handler); | 1577 handler = std::move(detachable_handler); |
| 1582 } | 1578 } |
| 1583 | 1579 |
| 1584 // PlzNavigate: If using --enable-browser-side-navigation, the | |
| 1585 // CrossSiteResourceHandler is not needed. This codepath is not used for the | |
| 1586 // actual navigation request, but only the subsequent blob URL load. This does | |
| 1587 // not require request transfers. | |
| 1588 if (!IsBrowserSideNavigationEnabled()) { | |
| 1589 // Install a CrossSiteResourceHandler for all main frame requests. This will | |
| 1590 // check whether a transfer is required and, if so, pause for the UI thread | |
| 1591 // to drive the transfer. | |
| 1592 bool is_swappable_navigation = | |
| 1593 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; | |
| 1594 // If out-of-process iframes are possible, then all subframe requests need | |
| 1595 // to go through the CrossSiteResourceHandler to enforce the site isolation | |
| 1596 // policy. | |
| 1597 if (!is_swappable_navigation && | |
| 1598 SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | |
| 1599 is_swappable_navigation = | |
| 1600 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | |
| 1601 } | |
| 1602 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
| 1603 handler.reset(new CrossSiteResourceHandler(std::move(handler), request)); | |
| 1604 } | |
| 1605 | |
| 1606 return AddStandardHandlers( | 1580 return AddStandardHandlers( |
| 1607 request, request_data.resource_type, resource_context, | 1581 request, request_data.resource_type, resource_context, |
| 1608 request_data.fetch_request_context_type, filter_->appcache_service(), | 1582 request_data.fetch_request_context_type, filter_->appcache_service(), |
| 1609 child_id, route_id, std::move(handler)); | 1583 child_id, route_id, std::move(handler)); |
| 1610 } | 1584 } |
| 1611 | 1585 |
| 1612 std::unique_ptr<ResourceHandler> | 1586 std::unique_ptr<ResourceHandler> |
| 1613 ResourceDispatcherHostImpl::AddStandardHandlers( | 1587 ResourceDispatcherHostImpl::AddStandardHandlers( |
| 1614 net::URLRequest* request, | 1588 net::URLRequest* request, |
| 1615 ResourceType resource_type, | 1589 ResourceType resource_type, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 } | 1815 } |
| 1842 | 1816 |
| 1843 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, | 1817 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, |
| 1844 int route_id, | 1818 int route_id, |
| 1845 bool is_loading) { | 1819 bool is_loading) { |
| 1846 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); | 1820 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); |
| 1847 } | 1821 } |
| 1848 | 1822 |
| 1849 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( | 1823 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( |
| 1850 const GlobalRequestID& id, | 1824 const GlobalRequestID& id, |
| 1851 const scoped_refptr<ResourceResponse>& response) { | 1825 const base::Closure& on_transfer_complete_callback) { |
| 1852 GetLoader(id)->MarkAsTransferring(response); | 1826 GetLoader(id)->MarkAsTransferring(on_transfer_complete_callback); |
| 1853 } | 1827 } |
| 1854 | 1828 |
| 1855 void ResourceDispatcherHostImpl::CancelTransferringNavigation( | 1829 void ResourceDispatcherHostImpl::CancelTransferringNavigation( |
| 1856 const GlobalRequestID& id) { | 1830 const GlobalRequestID& id) { |
| 1857 // Request should still exist and be in the middle of a transfer. | 1831 // Request should still exist and be in the middle of a transfer. |
| 1858 DCHECK(IsTransferredNavigation(id)); | 1832 DCHECK(IsTransferredNavigation(id)); |
| 1859 RemovePendingRequest(id.child_id, id.request_id); | 1833 RemovePendingRequest(id.child_id, id.request_id); |
| 1860 } | 1834 } |
| 1861 | 1835 |
| 1862 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( | 1836 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2729 &throttles); | 2703 &throttles); |
| 2730 if (!throttles.empty()) { | 2704 if (!throttles.empty()) { |
| 2731 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2705 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
| 2732 std::move(throttles))); | 2706 std::move(throttles))); |
| 2733 } | 2707 } |
| 2734 } | 2708 } |
| 2735 return handler; | 2709 return handler; |
| 2736 } | 2710 } |
| 2737 | 2711 |
| 2738 } // namespace content | 2712 } // namespace content |
| OLD | NEW |