| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 } | 1552 } |
| 1557 | 1553 |
| 1558 // Prefetches and <a ping> requests outlive their child process. | 1554 // Prefetches and <a ping> requests outlive their child process. |
| 1559 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { | 1555 if (!sync_result && IsDetachableResourceType(request_data.resource_type)) { |
| 1560 handler.reset(new DetachableResourceHandler( | 1556 handler.reset(new DetachableResourceHandler( |
| 1561 request, | 1557 request, |
| 1562 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1558 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
| 1563 std::move(handler))); | 1559 std::move(handler))); |
| 1564 } | 1560 } |
| 1565 | 1561 |
| 1566 // PlzNavigate: If using --enable-browser-side-navigation, the | |
| 1567 // CrossSiteResourceHandler is not needed. This codepath is not used for the | |
| 1568 // actual navigation request, but only the subsequent blob URL load. This does | |
| 1569 // not require request transfers. | |
| 1570 if (!IsBrowserSideNavigationEnabled()) { | |
| 1571 // Install a CrossSiteResourceHandler for all main frame requests. This will | |
| 1572 // check whether a transfer is required and, if so, pause for the UI thread | |
| 1573 // to drive the transfer. | |
| 1574 bool is_swappable_navigation = | |
| 1575 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; | |
| 1576 // If out-of-process iframes are possible, then all subframe requests need | |
| 1577 // to go through the CrossSiteResourceHandler to enforce the site isolation | |
| 1578 // policy. | |
| 1579 if (!is_swappable_navigation && | |
| 1580 SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | |
| 1581 is_swappable_navigation = | |
| 1582 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | |
| 1583 } | |
| 1584 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
| 1585 handler.reset(new CrossSiteResourceHandler(std::move(handler), request)); | |
| 1586 } | |
| 1587 | |
| 1588 return AddStandardHandlers( | 1562 return AddStandardHandlers( |
| 1589 request, request_data.resource_type, resource_context, | 1563 request, request_data.resource_type, resource_context, |
| 1590 request_data.fetch_request_context_type, filter_->appcache_service(), | 1564 request_data.fetch_request_context_type, filter_->appcache_service(), |
| 1591 child_id, route_id, std::move(handler)); | 1565 child_id, route_id, std::move(handler)); |
| 1592 } | 1566 } |
| 1593 | 1567 |
| 1594 std::unique_ptr<ResourceHandler> | 1568 std::unique_ptr<ResourceHandler> |
| 1595 ResourceDispatcherHostImpl::AddStandardHandlers( | 1569 ResourceDispatcherHostImpl::AddStandardHandlers( |
| 1596 net::URLRequest* request, | 1570 net::URLRequest* request, |
| 1597 ResourceType resource_type, | 1571 ResourceType resource_type, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 } | 1796 } |
| 1823 | 1797 |
| 1824 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, | 1798 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, |
| 1825 int route_id, | 1799 int route_id, |
| 1826 bool is_loading) { | 1800 bool is_loading) { |
| 1827 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); | 1801 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); |
| 1828 } | 1802 } |
| 1829 | 1803 |
| 1830 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( | 1804 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( |
| 1831 const GlobalRequestID& id, | 1805 const GlobalRequestID& id, |
| 1832 const scoped_refptr<ResourceResponse>& response) { | 1806 const base::Closure& on_transfer_complete_callback) { |
| 1833 GetLoader(id)->MarkAsTransferring(response); | 1807 GetLoader(id)->MarkAsTransferring(on_transfer_complete_callback); |
| 1834 } | 1808 } |
| 1835 | 1809 |
| 1836 void ResourceDispatcherHostImpl::CancelTransferringNavigation( | 1810 void ResourceDispatcherHostImpl::CancelTransferringNavigation( |
| 1837 const GlobalRequestID& id) { | 1811 const GlobalRequestID& id) { |
| 1838 // Request should still exist and be in the middle of a transfer. | 1812 // Request should still exist and be in the middle of a transfer. |
| 1839 DCHECK(IsTransferredNavigation(id)); | 1813 DCHECK(IsTransferredNavigation(id)); |
| 1840 RemovePendingRequest(id.child_id, id.request_id); | 1814 RemovePendingRequest(id.child_id, id.request_id); |
| 1841 } | 1815 } |
| 1842 | 1816 |
| 1843 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( | 1817 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2664 request_info->GetRouteID(), is_content_initiated, true, &throttles); | 2638 request_info->GetRouteID(), is_content_initiated, true, &throttles); |
| 2665 if (!throttles.empty()) { | 2639 if (!throttles.empty()) { |
| 2666 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2640 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
| 2667 std::move(throttles))); | 2641 std::move(throttles))); |
| 2668 } | 2642 } |
| 2669 } | 2643 } |
| 2670 return handler; | 2644 return handler; |
| 2671 } | 2645 } |
| 2672 | 2646 |
| 2673 } // namespace content | 2647 } // namespace content |
| OLD | NEW |