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, int render_view_id) { | 291 void OnSwapOutACKHelper(int render_process_id, |
| 292 int render_view_id, |
| 293 bool timed_out) { |
292 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, | 294 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, |
293 render_view_id); | 295 render_view_id); |
294 if (rvh) | 296 if (rvh) |
295 rvh->OnSwapOutACK(); | 297 rvh->OnSwapOutACK(timed_out); |
296 } | 298 } |
297 | 299 |
298 net::Error CallbackAndReturn( | 300 net::Error CallbackAndReturn( |
299 const DownloadResourceHandler::OnStartedCallback& started_cb, | 301 const DownloadResourceHandler::OnStartedCallback& started_cb, |
300 net::Error net_error) { | 302 net::Error net_error) { |
301 if (started_cb.is_null()) | 303 if (started_cb.is_null()) |
302 return net_error; | 304 return net_error; |
303 BrowserThread::PostTask( | 305 BrowserThread::PostTask( |
304 BrowserThread::UI, FROM_HERE, | 306 BrowserThread::UI, FROM_HERE, |
305 base::Bind(started_cb, content::DownloadId::Invalid(), net_error)); | 307 base::Bind(started_cb, content::DownloadId::Invalid(), net_error)); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 ResourceType::SUB_RESOURCE, | 1078 ResourceType::SUB_RESOURCE, |
1077 PAGE_TRANSITION_LINK, | 1079 PAGE_TRANSITION_LINK, |
1078 0, // upload_size | 1080 0, // upload_size |
1079 download, // is_download | 1081 download, // is_download |
1080 download, // allow_download | 1082 download, // allow_download |
1081 false, // has_user_gesture | 1083 false, // has_user_gesture |
1082 WebKit::WebReferrerPolicyDefault, | 1084 WebKit::WebReferrerPolicyDefault, |
1083 context); | 1085 context); |
1084 } | 1086 } |
1085 | 1087 |
| 1088 |
1086 void ResourceDispatcherHostImpl::OnSwapOutACK( | 1089 void ResourceDispatcherHostImpl::OnSwapOutACK( |
| 1090 const ViewMsg_SwapOut_Params& params) { |
| 1091 HandleSwapOutACK(params, false); |
| 1092 } |
| 1093 |
| 1094 void ResourceDispatcherHostImpl::OnSimulateSwapOutACK( |
1087 const ViewMsg_SwapOut_Params& params) { | 1095 const ViewMsg_SwapOut_Params& params) { |
| 1096 // Call the real implementation with true, which means that we timed out. |
| 1097 HandleSwapOutACK(params, true); |
| 1098 } |
| 1099 |
| 1100 void ResourceDispatcherHostImpl::HandleSwapOutACK( |
| 1101 const ViewMsg_SwapOut_Params& params, bool timed_out) { |
1088 // Closes for cross-site transitions are handled such that the cross-site | 1102 // Closes for cross-site transitions are handled such that the cross-site |
1089 // transition continues. | 1103 // transition continues. |
1090 GlobalRequestID global_id(params.new_render_process_host_id, | 1104 GlobalRequestID global_id(params.new_render_process_host_id, |
1091 params.new_request_id); | 1105 params.new_request_id); |
1092 PendingRequestList::iterator i = pending_requests_.find(global_id); | 1106 PendingRequestList::iterator i = pending_requests_.find(global_id); |
1093 if (i != pending_requests_.end()) { | 1107 if (i != pending_requests_.end()) { |
1094 // The response we were meant to resume could have already been canceled. | 1108 // The response we were meant to resume could have already been canceled. |
1095 ResourceRequestInfoImpl* info = | 1109 ResourceRequestInfoImpl* info = |
1096 ResourceRequestInfoImpl::ForRequest(i->second); | 1110 ResourceRequestInfoImpl::ForRequest(i->second); |
1097 if (info->cross_site_handler()) | 1111 if (info->cross_site_handler()) |
1098 info->cross_site_handler()->ResumeResponse(); | 1112 info->cross_site_handler()->ResumeResponse(); |
1099 } | 1113 } |
1100 // Update the RenderViewHost's internal state after the ACK. | 1114 // Update the RenderViewHost's internal state after the ACK. |
1101 BrowserThread::PostTask( | 1115 BrowserThread::PostTask( |
1102 BrowserThread::UI, | 1116 BrowserThread::UI, |
1103 FROM_HERE, | 1117 FROM_HERE, |
1104 base::Bind(&OnSwapOutACKHelper, | 1118 base::Bind(&OnSwapOutACKHelper, |
1105 params.closing_process_id, | 1119 params.closing_process_id, |
1106 params.closing_route_id)); | 1120 params.closing_route_id, |
| 1121 timed_out)); |
1107 } | 1122 } |
1108 | 1123 |
1109 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( | 1124 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( |
1110 const GURL& url, | 1125 const GURL& url, |
1111 const std::string& security_info, | 1126 const std::string& security_info, |
1112 const std::string& http_method, | 1127 const std::string& http_method, |
1113 ResourceType::Type resource_type) { | 1128 ResourceType::Type resource_type) { |
1114 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) | 1129 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) |
1115 return; | 1130 return; |
1116 | 1131 |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 return allow_cross_origin_auth_prompt_; | 2308 return allow_cross_origin_auth_prompt_; |
2294 } | 2309 } |
2295 | 2310 |
2296 bool ResourceDispatcherHostImpl::IsTransferredNavigation( | 2311 bool ResourceDispatcherHostImpl::IsTransferredNavigation( |
2297 const GlobalRequestID& transferred_request_id) const { | 2312 const GlobalRequestID& transferred_request_id) const { |
2298 return transferred_navigations_.find(transferred_request_id) != | 2313 return transferred_navigations_.find(transferred_request_id) != |
2299 transferred_navigations_.end(); | 2314 transferred_navigations_.end(); |
2300 } | 2315 } |
2301 | 2316 |
2302 } // namespace content | 2317 } // namespace content |
OLD | NEW |