Chromium Code Reviews| 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 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "base/time/time.h" | 32 #include "base/time/time.h" |
| 33 #include "content/browser/appcache/appcache_interceptor.h" | 33 #include "content/browser/appcache/appcache_interceptor.h" |
| 34 #include "content/browser/appcache/chrome_appcache_service.h" | 34 #include "content/browser/appcache/chrome_appcache_service.h" |
| 35 #include "content/browser/bad_message.h" | 35 #include "content/browser/bad_message.h" |
| 36 #include "content/browser/cert_store_impl.h" | 36 #include "content/browser/cert_store_impl.h" |
| 37 #include "content/browser/child_process_security_policy_impl.h" | 37 #include "content/browser/child_process_security_policy_impl.h" |
| 38 #include "content/browser/download/download_resource_handler.h" | 38 #include "content/browser/download/download_resource_handler.h" |
| 39 #include "content/browser/download/save_file_manager.h" | 39 #include "content/browser/download/save_file_manager.h" |
| 40 #include "content/browser/download/save_file_resource_handler.h" | 40 #include "content/browser/download/save_file_resource_handler.h" |
| 41 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 41 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 42 #include "content/browser/frame_host/frame_tree.h" | |
| 42 #include "content/browser/frame_host/navigation_request_info.h" | 43 #include "content/browser/frame_host/navigation_request_info.h" |
| 43 #include "content/browser/frame_host/navigator.h" | 44 #include "content/browser/frame_host/navigator.h" |
| 44 #include "content/browser/loader/async_resource_handler.h" | 45 #include "content/browser/loader/async_resource_handler.h" |
| 45 #include "content/browser/loader/async_revalidation_manager.h" | 46 #include "content/browser/loader/async_revalidation_manager.h" |
| 46 #include "content/browser/loader/cross_site_resource_handler.h" | 47 #include "content/browser/loader/cross_site_resource_handler.h" |
| 47 #include "content/browser/loader/detachable_resource_handler.h" | 48 #include "content/browser/loader/detachable_resource_handler.h" |
| 48 #include "content/browser/loader/mime_type_resource_handler.h" | 49 #include "content/browser/loader/mime_type_resource_handler.h" |
| 49 #include "content/browser/loader/navigation_resource_handler.h" | 50 #include "content/browser/loader/navigation_resource_handler.h" |
| 50 #include "content/browser/loader/navigation_resource_throttle.h" | 51 #include "content/browser/loader/navigation_resource_throttle.h" |
| 51 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 52 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 pending_loaders_.erase(i++); | 564 pending_loaders_.erase(i++); |
| 564 } else { | 565 } else { |
| 565 ++i; | 566 ++i; |
| 566 } | 567 } |
| 567 } | 568 } |
| 568 | 569 |
| 569 for (BlockedLoadersMap::iterator i = blocked_loaders_map_.begin(); | 570 for (BlockedLoadersMap::iterator i = blocked_loaders_map_.begin(); |
| 570 i != blocked_loaders_map_.end();) { | 571 i != blocked_loaders_map_.end();) { |
| 571 BlockedLoadersList* loaders = i->second; | 572 BlockedLoadersList* loaders = i->second; |
| 572 if (loaders->empty()) { | 573 if (loaders->empty()) { |
| 573 // This can happen if BlockRequestsForRoute() has been called for a route, | 574 // This can happen if BlockRequestsForFrame() has been called for a route, |
| 574 // but we haven't blocked any matching requests yet. | 575 // but we haven't blocked any matching requests yet. |
| 575 ++i; | 576 ++i; |
| 576 continue; | 577 continue; |
| 577 } | 578 } |
| 578 ResourceRequestInfoImpl* info = loaders->front()->GetRequestInfo(); | 579 ResourceRequestInfoImpl* info = loaders->front()->GetRequestInfo(); |
| 579 if (info->GetContext() == context) { | 580 if (info->GetContext() == context) { |
| 580 blocked_loaders_map_.erase(i++); | 581 blocked_loaders_map_.erase(i++); |
| 581 for (BlockedLoadersList::const_iterator it = loaders->begin(); | 582 for (BlockedLoadersList::const_iterator it = loaders->begin(); |
| 582 it != loaders->end(); ++it) { | 583 it != loaders->end(); ++it) { |
| 583 linked_ptr<ResourceLoader> loader = *it; | 584 linked_ptr<ResourceLoader> loader = *it; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1046 is_shutdown_ = true; | 1047 is_shutdown_ = true; |
| 1047 pending_loaders_.clear(); | 1048 pending_loaders_.clear(); |
| 1048 | 1049 |
| 1049 // Make sure we shutdown the timer now, otherwise by the time our destructor | 1050 // Make sure we shutdown the timer now, otherwise by the time our destructor |
| 1050 // runs if the timer is still running the Task is deleted twice (once by | 1051 // runs if the timer is still running the Task is deleted twice (once by |
| 1051 // the MessageLoop and the second time by RepeatingTimer). | 1052 // the MessageLoop and the second time by RepeatingTimer). |
| 1052 update_load_states_timer_.reset(); | 1053 update_load_states_timer_.reset(); |
| 1053 | 1054 |
| 1054 // Clear blocked requests if any left. | 1055 // Clear blocked requests if any left. |
| 1055 // Note that we have to do this in 2 passes as we cannot call | 1056 // Note that we have to do this in 2 passes as we cannot call |
| 1056 // CancelBlockedRequestsForRoute while iterating over | 1057 // CancelBlockedRequestsForFrame while iterating over |
| 1057 // blocked_loaders_map_, as it modifies it. | 1058 // blocked_loaders_map_, as it modifies it. |
| 1058 std::set<GlobalRoutingID> ids; | 1059 std::set<GlobalFrameRoutingId> ids; |
| 1059 for (BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.begin(); | 1060 for (BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.begin(); |
| 1060 iter != blocked_loaders_map_.end(); ++iter) { | 1061 iter != blocked_loaders_map_.end(); ++iter) { |
| 1061 std::pair<std::set<GlobalRoutingID>::iterator, bool> result = | 1062 std::pair<std::set<GlobalFrameRoutingId>::iterator, bool> result = |
| 1062 ids.insert(iter->first); | 1063 ids.insert(iter->first); |
| 1063 // We should not have duplicates. | 1064 // We should not have duplicates. |
| 1064 DCHECK(result.second); | 1065 DCHECK(result.second); |
| 1065 } | 1066 } |
| 1066 for (std::set<GlobalRoutingID>::const_iterator iter = ids.begin(); | 1067 for (std::set<GlobalFrameRoutingId>::const_iterator iter = ids.begin(); |
| 1067 iter != ids.end(); ++iter) { | 1068 iter != ids.end(); ++iter) { |
| 1068 CancelBlockedRequestsForRoute(iter->child_id, iter->route_id); | 1069 CancelBlockedRequestsForFrame(*iter); |
| 1069 } | 1070 } |
| 1070 | 1071 |
| 1071 scheduler_.reset(); | 1072 scheduler_.reset(); |
| 1072 } | 1073 } |
| 1073 | 1074 |
| 1074 bool ResourceDispatcherHostImpl::OnMessageReceived( | 1075 bool ResourceDispatcherHostImpl::OnMessageReceived( |
| 1075 const IPC::Message& message, | 1076 const IPC::Message& message, |
| 1076 ResourceMessageFilter* filter) { | 1077 ResourceMessageFilter* filter) { |
| 1077 filter_ = filter; | 1078 filter_ = filter; |
| 1078 bool handled = true; | 1079 bool handled = true; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 sync_result->routing_id()); | 1155 sync_result->routing_id()); |
| 1155 } | 1156 } |
| 1156 | 1157 |
| 1157 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( | 1158 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( |
| 1158 int child_id, | 1159 int child_id, |
| 1159 int route_id, | 1160 int route_id, |
| 1160 int request_id, | 1161 int request_id, |
| 1161 const ResourceHostMsg_Request& request_data, | 1162 const ResourceHostMsg_Request& request_data, |
| 1162 const linked_ptr<ResourceLoader>& loader) { | 1163 const linked_ptr<ResourceLoader>& loader) { |
| 1163 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1164 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 1164 GlobalRoutingID old_routing_id( | 1165 GlobalFrameRoutingId old_routing_id(request_data.transferred_request_child_id, |
| 1165 request_data.transferred_request_child_id, info->GetRouteID()); | 1166 info->GetRenderFrameID()); |
| 1166 GlobalRequestID old_request_id(request_data.transferred_request_child_id, | 1167 GlobalRequestID old_request_id(request_data.transferred_request_child_id, |
| 1167 request_data.transferred_request_request_id); | 1168 request_data.transferred_request_request_id); |
| 1168 GlobalRoutingID new_routing_id(child_id, route_id); | 1169 GlobalFrameRoutingId new_routing_id(child_id, request_data.render_frame_id); |
| 1169 GlobalRequestID new_request_id(child_id, request_id); | 1170 GlobalRequestID new_request_id(child_id, request_id); |
| 1170 | 1171 |
| 1171 // Clear out data that depends on |info| before updating it. | 1172 // Clear out data that depends on |info| before updating it. |
| 1172 // We always need to move the memory stats to the new process. In contrast, | 1173 // We always need to move the memory stats to the new process. In contrast, |
| 1173 // stats.num_requests is only tracked for some requests (those that require | 1174 // stats.num_requests is only tracked for some requests (those that require |
| 1174 // file descriptors for their shared memory buffer). | 1175 // file descriptors for their shared memory buffer). |
| 1175 IncrementOutstandingRequestsMemory(-1, *info); | 1176 IncrementOutstandingRequestsMemory(-1, *info); |
| 1176 bool should_update_count = info->counted_as_in_flight_request(); | 1177 bool should_update_count = info->counted_as_in_flight_request(); |
| 1177 if (should_update_count) | 1178 if (should_update_count) |
| 1178 IncrementOutstandingRequestsCount(-1, info); | 1179 IncrementOutstandingRequestsCount(-1, info); |
| 1179 pending_loaders_.erase(old_request_id); | 1180 pending_loaders_.erase(old_request_id); |
| 1180 | 1181 |
| 1181 // ResourceHandlers should always get state related to the request from the | 1182 // ResourceHandlers should always get state related to the request from the |
| 1182 // ResourceRequestInfo rather than caching it locally. This lets us update | 1183 // ResourceRequestInfo rather than caching it locally. This lets us update |
| 1183 // the info object when a transfer occurs. | 1184 // the info object when a transfer occurs. |
| 1184 info->UpdateForTransfer(child_id, route_id, request_data.origin_pid, | 1185 info->UpdateForTransfer(child_id, route_id, request_data.origin_pid, |
| 1185 request_id, request_data.parent_render_frame_id, | 1186 request_id, request_data.render_frame_id, |
| 1187 request_data.parent_render_frame_id, | |
| 1186 filter_->GetWeakPtr()); | 1188 filter_->GetWeakPtr()); |
| 1187 | 1189 |
| 1188 // Update maps that used the old IDs, if necessary. Some transfers in tests | 1190 // Update maps that used the old IDs, if necessary. Some transfers in tests |
| 1189 // do not actually use a different ID, so not all maps need to be updated. | 1191 // do not actually use a different ID, so not all maps need to be updated. |
| 1190 pending_loaders_[new_request_id] = loader; | 1192 pending_loaders_[new_request_id] = loader; |
| 1191 IncrementOutstandingRequestsMemory(1, *info); | 1193 IncrementOutstandingRequestsMemory(1, *info); |
| 1192 if (should_update_count) | 1194 if (should_update_count) |
| 1193 IncrementOutstandingRequestsCount(1, info); | 1195 IncrementOutstandingRequestsCount(1, info); |
| 1194 if (old_routing_id != new_routing_id) { | 1196 if (old_routing_id != new_routing_id) { |
| 1195 if (blocked_loaders_map_.find(old_routing_id) != | 1197 if (blocked_loaders_map_.find(old_routing_id) != |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1726 blink::WebReferrerPolicyDefault, | 1728 blink::WebReferrerPolicyDefault, |
| 1727 blink::WebPageVisibilityStateVisible, | 1729 blink::WebPageVisibilityStateVisible, |
| 1728 context, | 1730 context, |
| 1729 base::WeakPtr<ResourceMessageFilter>(), // filter | 1731 base::WeakPtr<ResourceMessageFilter>(), // filter |
| 1730 false, // report_raw_headers | 1732 false, // report_raw_headers |
| 1731 true, // is_async | 1733 true, // is_async |
| 1732 false, // is_using_lofi | 1734 false, // is_using_lofi |
| 1733 std::string()); // original_headers | 1735 std::string()); // original_headers |
| 1734 } | 1736 } |
| 1735 | 1737 |
| 1738 void ResourceDispatcherHostImpl::OnRenderFrameHostDeleted( | |
| 1739 const GlobalFrameRoutingId& routing_id) { | |
| 1740 CancelRequestsForFrame(routing_id); | |
| 1741 } | |
| 1742 | |
| 1736 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, | 1743 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, |
| 1737 int route_id, | 1744 int route_id, |
| 1738 bool is_visible, | 1745 bool is_visible, |
| 1739 bool is_audible) { | 1746 bool is_audible) { |
| 1740 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); | 1747 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); |
| 1741 } | 1748 } |
| 1742 | 1749 |
| 1743 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( | 1750 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, |
| 1744 int child_id, | 1751 int route_id) { |
| 1745 int route_id) { | |
| 1746 scheduler_->OnClientDeleted(child_id, route_id); | 1752 scheduler_->OnClientDeleted(child_id, route_id); |
| 1747 CancelRequestsForRoute(child_id, route_id); | |
| 1748 } | 1753 } |
| 1749 | 1754 |
| 1750 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, | 1755 void ResourceDispatcherHostImpl::OnRenderViewHostSetIsLoading(int child_id, |
| 1751 int route_id, | 1756 int route_id, |
| 1752 bool is_loading) { | 1757 bool is_loading) { |
| 1753 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); | 1758 scheduler_->OnLoadingStateChanged(child_id, route_id, !is_loading); |
| 1754 } | 1759 } |
| 1755 | 1760 |
| 1756 void ResourceDispatcherHostImpl::OnRenderViewHostWasHidden( | 1761 void ResourceDispatcherHostImpl::OnRenderViewHostWasHidden( |
| 1757 int child_id, | 1762 int child_id, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1846 ResourceLoader* loader = GetLoader(id); | 1851 ResourceLoader* loader = GetLoader(id); |
| 1847 // The response we were meant to resume could have already been canceled. | 1852 // The response we were meant to resume could have already been canceled. |
| 1848 if (loader) | 1853 if (loader) |
| 1849 loader->CompleteTransfer(); | 1854 loader->CompleteTransfer(); |
| 1850 } | 1855 } |
| 1851 | 1856 |
| 1852 // The object died, so cancel and detach all requests associated with it except | 1857 // The object died, so cancel and detach all requests associated with it except |
| 1853 // for downloads and detachable resources, which belong to the browser process | 1858 // for downloads and detachable resources, which belong to the browser process |
| 1854 // even if initiated via a renderer. | 1859 // even if initiated via a renderer. |
| 1855 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { | 1860 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { |
| 1856 CancelRequestsForRoute(child_id, -1 /* cancel all */); | 1861 CancelRequestsForFrame(GlobalFrameRoutingId(child_id, -1 /* cancel all */)); |
|
nasko
2016/01/07 19:58:39
-1 is not a valid routing id. MSG_ROUTING_NONE?
Charlie Harrison
2016/01/07 22:47:05
Done.
| |
| 1857 registered_temp_files_.erase(child_id); | 1862 registered_temp_files_.erase(child_id); |
| 1858 } | 1863 } |
| 1859 | 1864 |
| 1860 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, | 1865 void ResourceDispatcherHostImpl::CancelRequestsForFrame( |
| 1861 int route_id) { | 1866 const GlobalFrameRoutingId& routing_id) { |
| 1862 // Since pending_requests_ is a map, we first build up a list of all of the | 1867 // Since pending_requests_ is a map, we first build up a list of all of the |
| 1863 // matching requests to be cancelled, and then we cancel them. Since there | 1868 // matching requests to be cancelled, and then we cancel them. Since there |
| 1864 // may be more than one request to cancel, we cannot simply hold onto the map | 1869 // may be more than one request to cancel, we cannot simply hold onto the map |
| 1865 // iterators found in the first loop. | 1870 // iterators found in the first loop. |
| 1866 | 1871 |
| 1867 // Find the global ID of all matching elements. | 1872 // Find the global ID of all matching elements. |
| 1873 int child_id = routing_id.child_id; | |
| 1874 int route_id = routing_id.route_id; | |
| 1875 | |
| 1868 bool any_requests_transferring = false; | 1876 bool any_requests_transferring = false; |
| 1869 std::vector<GlobalRequestID> matching_requests; | 1877 std::vector<GlobalRequestID> matching_requests; |
| 1870 for (LoaderMap::const_iterator i = pending_loaders_.begin(); | 1878 for (LoaderMap::const_iterator i = pending_loaders_.begin(); |
| 1871 i != pending_loaders_.end(); ++i) { | 1879 i != pending_loaders_.end(); ++i) { |
| 1872 if (i->first.child_id != child_id) | 1880 if (i->first.child_id != child_id) |
| 1873 continue; | 1881 continue; |
| 1874 | 1882 |
| 1875 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | 1883 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); |
| 1876 | 1884 |
| 1877 GlobalRequestID id(child_id, i->first.request_id); | 1885 GlobalRequestID id(child_id, i->first.request_id); |
| 1878 DCHECK(id == i->first); | 1886 DCHECK(id == i->first); |
| 1879 // Don't cancel navigations that are expected to live beyond this process. | 1887 // Don't cancel navigations that are expected to live beyond this process. |
| 1880 if (IsTransferredNavigation(id)) | 1888 if (IsTransferredNavigation(id)) |
| 1881 any_requests_transferring = true; | 1889 any_requests_transferring = true; |
| 1882 if (info->detachable_handler()) { | 1890 if (info->detachable_handler()) { |
| 1883 info->detachable_handler()->Detach(); | 1891 info->detachable_handler()->Detach(); |
| 1884 } else if (!info->IsDownload() && !info->is_stream() && | 1892 } else if (!info->IsDownload() && !info->is_stream() && |
| 1885 !IsTransferredNavigation(id) && | 1893 !IsTransferredNavigation(id) && |
| 1886 (route_id == -1 || route_id == info->GetRouteID())) { | 1894 (route_id == -1 || route_id == info->GetRenderFrameID())) { |
| 1887 matching_requests.push_back(id); | 1895 matching_requests.push_back(id); |
| 1888 } | 1896 } |
| 1889 } | 1897 } |
| 1890 | 1898 |
| 1891 // Remove matches. | 1899 // Remove matches. |
| 1892 for (size_t i = 0; i < matching_requests.size(); ++i) { | 1900 for (size_t i = 0; i < matching_requests.size(); ++i) { |
| 1893 LoaderMap::iterator iter = pending_loaders_.find(matching_requests[i]); | 1901 LoaderMap::iterator iter = pending_loaders_.find(matching_requests[i]); |
| 1894 // Although every matching request was in pending_requests_ when we built | 1902 // Although every matching request was in pending_requests_ when we built |
| 1895 // matching_requests, it is normal for a matching request to be not found | 1903 // matching_requests, it is normal for a matching request to be not found |
| 1896 // in pending_requests_ after we have removed some matching requests from | 1904 // in pending_requests_ after we have removed some matching requests from |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1907 // Don't clear the blocked loaders or offline policy maps if any of the | 1915 // Don't clear the blocked loaders or offline policy maps if any of the |
| 1908 // requests in route_id are being transferred to a new process, since those | 1916 // requests in route_id are being transferred to a new process, since those |
| 1909 // maps will be updated with the new route_id after the transfer. Otherwise | 1917 // maps will be updated with the new route_id after the transfer. Otherwise |
| 1910 // we will lose track of this info when the old route goes away, before the | 1918 // we will lose track of this info when the old route goes away, before the |
| 1911 // new one is created. | 1919 // new one is created. |
| 1912 if (any_requests_transferring) | 1920 if (any_requests_transferring) |
| 1913 return; | 1921 return; |
| 1914 | 1922 |
| 1915 // Now deal with blocked requests if any. | 1923 // Now deal with blocked requests if any. |
| 1916 if (route_id != -1) { | 1924 if (route_id != -1) { |
| 1917 if (blocked_loaders_map_.find(GlobalRoutingID(child_id, route_id)) != | 1925 if (blocked_loaders_map_.find(routing_id) != blocked_loaders_map_.end()) { |
| 1918 blocked_loaders_map_.end()) { | 1926 CancelBlockedRequestsForFrame(routing_id); |
| 1919 CancelBlockedRequestsForRoute(child_id, route_id); | |
| 1920 } | 1927 } |
| 1921 } else { | 1928 } else { |
| 1922 // We have to do all render views for the process |child_id|. | 1929 // We have to do all render frames for the process |child_id|. |
| 1923 // Note that we have to do this in 2 passes as we cannot call | 1930 // Note that we have to do this in 2 passes as we cannot call |
| 1924 // CancelBlockedRequestsForRoute while iterating over | 1931 // CancelBlockedRequestsForFrame while iterating over |
| 1925 // blocked_loaders_map_, as it modifies it. | 1932 // blocked_loaders_map_, as blocking requests modifies the map. |
| 1926 std::set<int> route_ids; | 1933 std::set<GlobalFrameRoutingId> routing_ids; |
| 1927 for (BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.begin(); | 1934 for (BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.begin(); |
| 1928 iter != blocked_loaders_map_.end(); ++iter) { | 1935 iter != blocked_loaders_map_.end(); ++iter) { |
| 1929 if (iter->first.child_id == child_id) | 1936 if (iter->first.child_id == child_id) |
| 1930 route_ids.insert(iter->first.route_id); | 1937 routing_ids.insert(iter->first); |
| 1931 } | 1938 } |
| 1932 for (std::set<int>::const_iterator iter = route_ids.begin(); | 1939 for (std::set<GlobalFrameRoutingId>::const_iterator iter = |
| 1933 iter != route_ids.end(); ++iter) { | 1940 routing_ids.begin(); |
| 1934 CancelBlockedRequestsForRoute(child_id, *iter); | 1941 iter != routing_ids.end(); ++iter) { |
| 1942 CancelBlockedRequestsForFrame(*iter); | |
| 1935 } | 1943 } |
| 1936 } | 1944 } |
| 1937 } | 1945 } |
| 1938 | 1946 |
| 1939 // Cancels the request and removes it from the list. | 1947 // Cancels the request and removes it from the list. |
| 1940 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id, | 1948 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id, |
| 1941 int request_id) { | 1949 int request_id) { |
| 1942 LoaderMap::iterator i = pending_loaders_.find( | 1950 LoaderMap::iterator i = pending_loaders_.find( |
| 1943 GlobalRequestID(child_id, request_id)); | 1951 GlobalRequestID(child_id, request_id)); |
| 1944 if (i == pending_loaders_.end()) { | 1952 if (i == pending_loaders_.end()) { |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2271 IncrementOutstandingRequestsMemory(-1, *info); | 2279 IncrementOutstandingRequestsMemory(-1, *info); |
| 2272 | 2280 |
| 2273 // A ResourceHandler must not outlive its associated URLRequest. | 2281 // A ResourceHandler must not outlive its associated URLRequest. |
| 2274 handler.reset(); | 2282 handler.reset(); |
| 2275 return; | 2283 return; |
| 2276 } | 2284 } |
| 2277 | 2285 |
| 2278 linked_ptr<ResourceLoader> loader( | 2286 linked_ptr<ResourceLoader> loader( |
| 2279 new ResourceLoader(std::move(request), std::move(handler), this)); | 2287 new ResourceLoader(std::move(request), std::move(handler), this)); |
| 2280 | 2288 |
| 2281 GlobalRoutingID id(info->GetGlobalRoutingID()); | 2289 GlobalFrameRoutingId id(info->GetChildID(), info->GetRenderFrameID()); |
| 2282 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); | 2290 BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(id); |
| 2283 if (iter != blocked_loaders_map_.end()) { | 2291 if (iter != blocked_loaders_map_.end()) { |
| 2284 // The request should be blocked. | 2292 // The request should be blocked. |
| 2285 iter->second->push_back(loader); | 2293 iter->second->push_back(loader); |
| 2286 return; | 2294 return; |
| 2287 } | 2295 } |
| 2288 | 2296 |
| 2289 StartLoading(info, loader); | 2297 StartLoading(info, loader); |
| 2290 } | 2298 } |
| 2291 | 2299 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2393 update_load_states_timer_->Stop(); | 2401 update_load_states_timer_->Stop(); |
| 2394 return; | 2402 return; |
| 2395 } | 2403 } |
| 2396 | 2404 |
| 2397 BrowserThread::PostTask( | 2405 BrowserThread::PostTask( |
| 2398 BrowserThread::UI, FROM_HERE, | 2406 BrowserThread::UI, FROM_HERE, |
| 2399 base::Bind(&ResourceDispatcherHostImpl::UpdateLoadInfoOnUIThread, | 2407 base::Bind(&ResourceDispatcherHostImpl::UpdateLoadInfoOnUIThread, |
| 2400 base::Passed(&info_map))); | 2408 base::Passed(&info_map))); |
| 2401 } | 2409 } |
| 2402 | 2410 |
| 2403 void ResourceDispatcherHostImpl::BlockRequestsForRoute(int child_id, | 2411 void ResourceDispatcherHostImpl::BlockRequestsForFrame( |
| 2404 int route_id) { | 2412 const GlobalFrameRoutingId& routing_id) { |
| 2405 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2413 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2406 GlobalRoutingID key(child_id, route_id); | 2414 DCHECK(blocked_loaders_map_.find(routing_id) == blocked_loaders_map_.end()) |
| 2407 DCHECK(blocked_loaders_map_.find(key) == blocked_loaders_map_.end()) << | 2415 << "BlockRequestsForFrame called multiple time for the same RVH"; |
| 2408 "BlockRequestsForRoute called multiple time for the same RVH"; | 2416 blocked_loaders_map_[routing_id] = new BlockedLoadersList(); |
| 2409 blocked_loaders_map_[key] = new BlockedLoadersList(); | |
| 2410 } | 2417 } |
| 2411 | 2418 |
| 2412 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute(int child_id, | 2419 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForFrame( |
| 2413 int route_id) { | 2420 const GlobalFrameRoutingId& routing_id) { |
| 2414 ProcessBlockedRequestsForRoute(child_id, route_id, false); | 2421 ProcessBlockedRequestsForFrame(routing_id, false); |
| 2415 } | 2422 } |
| 2416 | 2423 |
| 2417 void ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute(int child_id, | 2424 void ResourceDispatcherHostImpl::CancelBlockedRequestsForFrame( |
| 2418 int route_id) { | 2425 const GlobalFrameRoutingId& routing_id) { |
| 2419 ProcessBlockedRequestsForRoute(child_id, route_id, true); | 2426 ProcessBlockedRequestsForFrame(routing_id, true); |
| 2420 } | 2427 } |
| 2421 | 2428 |
| 2422 void ResourceDispatcherHostImpl::ProcessBlockedRequestsForRoute( | 2429 void ResourceDispatcherHostImpl::ProcessBlockedRequestsForFrame( |
| 2423 int child_id, | 2430 const GlobalFrameRoutingId& routing_id, |
| 2424 int route_id, | |
| 2425 bool cancel_requests) { | 2431 bool cancel_requests) { |
| 2426 BlockedLoadersMap::iterator iter = blocked_loaders_map_.find( | 2432 BlockedLoadersMap::iterator iter = blocked_loaders_map_.find(routing_id); |
| 2427 GlobalRoutingID(child_id, route_id)); | |
| 2428 if (iter == blocked_loaders_map_.end()) { | 2433 if (iter == blocked_loaders_map_.end()) { |
| 2429 // It's possible to reach here if the renderer crashed while an interstitial | 2434 // It's possible to reach here if the renderer crashed while an interstitial |
| 2430 // page was showing. | 2435 // page was showing. |
| 2431 return; | 2436 return; |
| 2432 } | 2437 } |
| 2433 | 2438 |
| 2434 BlockedLoadersList* loaders = iter->second; | 2439 BlockedLoadersList* loaders = iter->second; |
| 2435 | 2440 |
| 2436 // Removing the vector from the map unblocks any subsequent requests. | 2441 // Removing the vector from the map unblocks any subsequent requests. |
| 2437 blocked_loaders_map_.erase(iter); | 2442 blocked_loaders_map_.erase(iter); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2536 load_flags |= net::LOAD_PREFETCH; | 2541 load_flags |= net::LOAD_PREFETCH; |
| 2537 } | 2542 } |
| 2538 | 2543 |
| 2539 if (is_sync_load) | 2544 if (is_sync_load) |
| 2540 load_flags |= net::LOAD_IGNORE_LIMITS; | 2545 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 2541 | 2546 |
| 2542 return load_flags; | 2547 return load_flags; |
| 2543 } | 2548 } |
| 2544 | 2549 |
| 2545 } // namespace content | 2550 } // namespace content |
| OLD | NEW |