| 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/renderer_host/resource_dispatcher_host_impl.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 case ResourceType::PRERENDER: | 281 case ResourceType::PRERENDER: |
| 282 return net::IDLE; | 282 return net::IDLE; |
| 283 | 283 |
| 284 default: | 284 default: |
| 285 // When new resource types are added, their priority must be considered. | 285 // When new resource types are added, their priority must be considered. |
| 286 NOTREACHED(); | 286 NOTREACHED(); |
| 287 return net::LOW; | 287 return net::LOW; |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 void OnSwapOutACKHelper(int render_process_id, | 291 void OnSwapOutACKHelper(int render_process_id, int render_view_id) { |
| 292 int render_view_id, | |
| 293 bool timed_out) { | |
| 294 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, | 292 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, |
| 295 render_view_id); | 293 render_view_id); |
| 296 if (rvh) | 294 if (rvh) |
| 297 rvh->OnSwapOutACK(timed_out); | 295 rvh->OnSwapOutACK(); |
| 298 } | 296 } |
| 299 | 297 |
| 300 net::Error CallbackAndReturn( | 298 net::Error CallbackAndReturn( |
| 301 const DownloadResourceHandler::OnStartedCallback& started_cb, | 299 const DownloadResourceHandler::OnStartedCallback& started_cb, |
| 302 net::Error net_error) { | 300 net::Error net_error) { |
| 303 if (started_cb.is_null()) | 301 if (started_cb.is_null()) |
| 304 return net_error; | 302 return net_error; |
| 305 BrowserThread::PostTask( | 303 BrowserThread::PostTask( |
| 306 BrowserThread::UI, FROM_HERE, | 304 BrowserThread::UI, FROM_HERE, |
| 307 base::Bind(started_cb, content::DownloadId::Invalid(), net_error)); | 305 base::Bind(started_cb, content::DownloadId::Invalid(), net_error)); |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 ResourceType::SUB_RESOURCE, | 1091 ResourceType::SUB_RESOURCE, |
| 1094 PAGE_TRANSITION_LINK, | 1092 PAGE_TRANSITION_LINK, |
| 1095 0, // upload_size | 1093 0, // upload_size |
| 1096 download, // is_download | 1094 download, // is_download |
| 1097 download, // allow_download | 1095 download, // allow_download |
| 1098 false, // has_user_gesture | 1096 false, // has_user_gesture |
| 1099 WebKit::WebReferrerPolicyDefault, | 1097 WebKit::WebReferrerPolicyDefault, |
| 1100 context); | 1098 context); |
| 1101 } | 1099 } |
| 1102 | 1100 |
| 1103 | |
| 1104 void ResourceDispatcherHostImpl::OnSwapOutACK( | 1101 void ResourceDispatcherHostImpl::OnSwapOutACK( |
| 1105 const ViewMsg_SwapOut_Params& params) { | |
| 1106 HandleSwapOutACK(params, false); | |
| 1107 } | |
| 1108 | |
| 1109 void ResourceDispatcherHostImpl::OnSimulateSwapOutACK( | |
| 1110 const ViewMsg_SwapOut_Params& params) { | 1102 const ViewMsg_SwapOut_Params& params) { |
| 1111 // Call the real implementation with true, which means that we timed out. | |
| 1112 HandleSwapOutACK(params, true); | |
| 1113 } | |
| 1114 | |
| 1115 void ResourceDispatcherHostImpl::HandleSwapOutACK( | |
| 1116 const ViewMsg_SwapOut_Params& params, bool timed_out) { | |
| 1117 // Closes for cross-site transitions are handled such that the cross-site | 1103 // Closes for cross-site transitions are handled such that the cross-site |
| 1118 // transition continues. | 1104 // transition continues. |
| 1119 GlobalRequestID global_id(params.new_render_process_host_id, | 1105 GlobalRequestID global_id(params.new_render_process_host_id, |
| 1120 params.new_request_id); | 1106 params.new_request_id); |
| 1121 PendingRequestList::iterator i = pending_requests_.find(global_id); | 1107 PendingRequestList::iterator i = pending_requests_.find(global_id); |
| 1122 if (i != pending_requests_.end()) { | 1108 if (i != pending_requests_.end()) { |
| 1123 // The response we were meant to resume could have already been canceled. | 1109 // The response we were meant to resume could have already been canceled. |
| 1124 ResourceRequestInfoImpl* info = | 1110 ResourceRequestInfoImpl* info = |
| 1125 ResourceRequestInfoImpl::ForRequest(i->second); | 1111 ResourceRequestInfoImpl::ForRequest(i->second); |
| 1126 if (info->cross_site_handler()) | 1112 if (info->cross_site_handler()) |
| 1127 info->cross_site_handler()->ResumeResponse(); | 1113 info->cross_site_handler()->ResumeResponse(); |
| 1128 } | 1114 } |
| 1129 // Update the RenderViewHost's internal state after the ACK. | 1115 // Update the RenderViewHost's internal state after the ACK. |
| 1130 BrowserThread::PostTask( | 1116 BrowserThread::PostTask( |
| 1131 BrowserThread::UI, | 1117 BrowserThread::UI, |
| 1132 FROM_HERE, | 1118 FROM_HERE, |
| 1133 base::Bind(&OnSwapOutACKHelper, | 1119 base::Bind(&OnSwapOutACKHelper, |
| 1134 params.closing_process_id, | 1120 params.closing_process_id, |
| 1135 params.closing_route_id, | 1121 params.closing_route_id)); |
| 1136 timed_out)); | |
| 1137 } | 1122 } |
| 1138 | 1123 |
| 1139 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( | 1124 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( |
| 1140 const GURL& url, | 1125 const GURL& url, |
| 1141 const std::string& security_info, | 1126 const std::string& security_info, |
| 1142 const std::string& http_method, | 1127 const std::string& http_method, |
| 1143 ResourceType::Type resource_type) { | 1128 ResourceType::Type resource_type) { |
| 1144 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) | 1129 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) |
| 1145 return; | 1130 return; |
| 1146 | 1131 |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 return allow_cross_origin_auth_prompt_; | 2321 return allow_cross_origin_auth_prompt_; |
| 2337 } | 2322 } |
| 2338 | 2323 |
| 2339 bool ResourceDispatcherHostImpl::IsTransferredNavigation( | 2324 bool ResourceDispatcherHostImpl::IsTransferredNavigation( |
| 2340 const GlobalRequestID& transferred_request_id) const { | 2325 const GlobalRequestID& transferred_request_id) const { |
| 2341 return transferred_navigations_.find(transferred_request_id) != | 2326 return transferred_navigations_.find(transferred_request_id) != |
| 2342 transferred_navigations_.end(); | 2327 transferred_navigations_.end(); |
| 2343 } | 2328 } |
| 2344 | 2329 |
| 2345 } // namespace content | 2330 } // namespace content |
| OLD | NEW |