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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 std::unique_ptr<DetachableResourceHandler> detachable_handler = | 1560 std::unique_ptr<DetachableResourceHandler> detachable_handler = |
1565 base::MakeUnique<DetachableResourceHandler>( | 1561 base::MakeUnique<DetachableResourceHandler>( |
1566 request, | 1562 request, |
1567 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), | 1563 base::TimeDelta::FromMilliseconds(kDefaultDetachableCancelDelayMs), |
1568 std::move(handler)); | 1564 std::move(handler)); |
1569 if (start_detached) | 1565 if (start_detached) |
1570 detachable_handler->Detach(); | 1566 detachable_handler->Detach(); |
1571 handler = std::move(detachable_handler); | 1567 handler = std::move(detachable_handler); |
1572 } | 1568 } |
1573 | 1569 |
1574 // PlzNavigate: If using --enable-browser-side-navigation, the | |
1575 // CrossSiteResourceHandler is not needed. This codepath is not used for the | |
1576 // actual navigation request, but only the subsequent blob URL load. This does | |
1577 // not require request transfers. | |
1578 if (!IsBrowserSideNavigationEnabled()) { | |
1579 // Install a CrossSiteResourceHandler for all main frame requests. This will | |
1580 // check whether a transfer is required and, if so, pause for the UI thread | |
1581 // to drive the transfer. | |
1582 bool is_swappable_navigation = | |
1583 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME; | |
1584 // If out-of-process iframes are possible, then all subframe requests need | |
1585 // to go through the CrossSiteResourceHandler to enforce the site isolation | |
1586 // policy. | |
1587 if (!is_swappable_navigation && | |
1588 SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | |
1589 is_swappable_navigation = | |
1590 request_data.resource_type == RESOURCE_TYPE_SUB_FRAME; | |
1591 } | |
1592 if (is_swappable_navigation && process_type == PROCESS_TYPE_RENDERER) | |
1593 handler.reset(new CrossSiteResourceHandler(std::move(handler), request)); | |
1594 } | |
1595 | |
1596 return AddStandardHandlers( | 1570 return AddStandardHandlers( |
1597 request, request_data.resource_type, resource_context, | 1571 request, request_data.resource_type, resource_context, |
1598 request_data.fetch_request_context_type, filter_->appcache_service(), | 1572 request_data.fetch_request_context_type, filter_->appcache_service(), |
1599 child_id, route_id, std::move(handler)); | 1573 child_id, route_id, std::move(handler)); |
1600 } | 1574 } |
1601 | 1575 |
1602 std::unique_ptr<ResourceHandler> | 1576 std::unique_ptr<ResourceHandler> |
1603 ResourceDispatcherHostImpl::AddStandardHandlers( | 1577 ResourceDispatcherHostImpl::AddStandardHandlers( |
1604 net::URLRequest* request, | 1578 net::URLRequest* request, |
1605 ResourceType resource_type, | 1579 ResourceType resource_type, |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 } | 1804 } |
1831 | 1805 |
1832 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, | 1806 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, |
1833 int route_id, | 1807 int route_id, |
1834 bool is_loading) { | 1808 bool is_loading) { |
1835 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); | 1809 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); |
1836 } | 1810 } |
1837 | 1811 |
1838 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( | 1812 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( |
1839 const GlobalRequestID& id, | 1813 const GlobalRequestID& id, |
1840 const scoped_refptr<ResourceResponse>& response) { | 1814 const base::Closure& on_transfer_complete_callback) { |
1841 GetLoader(id)->MarkAsTransferring(response); | 1815 GetLoader(id)->MarkAsTransferring(on_transfer_complete_callback); |
1842 } | 1816 } |
1843 | 1817 |
1844 void ResourceDispatcherHostImpl::CancelTransferringNavigation( | 1818 void ResourceDispatcherHostImpl::CancelTransferringNavigation( |
1845 const GlobalRequestID& id) { | 1819 const GlobalRequestID& id) { |
1846 // Request should still exist and be in the middle of a transfer. | 1820 // Request should still exist and be in the middle of a transfer. |
1847 DCHECK(IsTransferredNavigation(id)); | 1821 DCHECK(IsTransferredNavigation(id)); |
1848 RemovePendingRequest(id.child_id, id.request_id); | 1822 RemovePendingRequest(id.child_id, id.request_id); |
1849 } | 1823 } |
1850 | 1824 |
1851 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( | 1825 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2702 request_info->GetRouteID(), is_content_initiated, true, &throttles); | 2676 request_info->GetRouteID(), is_content_initiated, true, &throttles); |
2703 if (!throttles.empty()) { | 2677 if (!throttles.empty()) { |
2704 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2678 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2705 std::move(throttles))); | 2679 std::move(throttles))); |
2706 } | 2680 } |
2707 } | 2681 } |
2708 return handler; | 2682 return handler; |
2709 } | 2683 } |
2710 | 2684 |
2711 } // namespace content | 2685 } // namespace content |
OLD | NEW |