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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 case ResourceType::PREFETCH: | 254 case ResourceType::PREFETCH: |
255 return net::IDLE; | 255 return net::IDLE; |
256 | 256 |
257 default: | 257 default: |
258 // When new resource types are added, their priority must be considered. | 258 // When new resource types are added, their priority must be considered. |
259 NOTREACHED(); | 259 NOTREACHED(); |
260 return net::LOW; | 260 return net::LOW; |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 void OnSwapOutACKHelper(int render_process_id, int render_view_id) { | 264 void OnSwapOutACKHelper(int render_process_id, |
| 265 int render_view_id, |
| 266 bool timed_out) { |
265 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, | 267 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, |
266 render_view_id); | 268 render_view_id); |
267 if (rvh) | 269 if (rvh) |
268 rvh->OnSwapOutACK(); | 270 rvh->OnSwapOutACK(timed_out); |
269 } | 271 } |
270 | 272 |
271 net::Error CallbackAndReturn( | 273 net::Error CallbackAndReturn( |
272 const DownloadResourceHandler::OnStartedCallback& started_cb, | 274 const DownloadResourceHandler::OnStartedCallback& started_cb, |
273 net::Error net_error) { | 275 net::Error net_error) { |
274 if (started_cb.is_null()) | 276 if (started_cb.is_null()) |
275 return net_error; | 277 return net_error; |
276 BrowserThread::PostTask( | 278 BrowserThread::PostTask( |
277 BrowserThread::UI, FROM_HERE, | 279 BrowserThread::UI, FROM_HERE, |
278 base::Bind(started_cb, DownloadId::Invalid(), net_error)); | 280 base::Bind(started_cb, DownloadId::Invalid(), net_error)); |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 -1, // parent_frame_id | 1179 -1, // parent_frame_id |
1178 ResourceType::SUB_RESOURCE, | 1180 ResourceType::SUB_RESOURCE, |
1179 PAGE_TRANSITION_LINK, | 1181 PAGE_TRANSITION_LINK, |
1180 download, // is_download | 1182 download, // is_download |
1181 download, // allow_download | 1183 download, // allow_download |
1182 false, // has_user_gesture | 1184 false, // has_user_gesture |
1183 WebKit::WebReferrerPolicyDefault, | 1185 WebKit::WebReferrerPolicyDefault, |
1184 context); | 1186 context); |
1185 } | 1187 } |
1186 | 1188 |
| 1189 |
1187 void ResourceDispatcherHostImpl::OnSwapOutACK( | 1190 void ResourceDispatcherHostImpl::OnSwapOutACK( |
| 1191 const ViewMsg_SwapOut_Params& params) { |
| 1192 HandleSwapOutACK(params, false); |
| 1193 } |
| 1194 |
| 1195 void ResourceDispatcherHostImpl::OnSimulateSwapOutACK( |
1188 const ViewMsg_SwapOut_Params& params) { | 1196 const ViewMsg_SwapOut_Params& params) { |
| 1197 // Call the real implementation with true, which means that we timed out. |
| 1198 HandleSwapOutACK(params, true); |
| 1199 } |
| 1200 |
| 1201 void ResourceDispatcherHostImpl::HandleSwapOutACK( |
| 1202 const ViewMsg_SwapOut_Params& params, bool timed_out) { |
1189 // Closes for cross-site transitions are handled such that the cross-site | 1203 // Closes for cross-site transitions are handled such that the cross-site |
1190 // transition continues. | 1204 // transition continues. |
1191 ResourceLoader* loader = GetLoader(params.new_render_process_host_id, | 1205 ResourceLoader* loader = GetLoader(params.new_render_process_host_id, |
1192 params.new_request_id); | 1206 params.new_request_id); |
1193 if (loader) { | 1207 if (loader) { |
1194 // The response we were meant to resume could have already been canceled. | 1208 // The response we were meant to resume could have already been canceled. |
1195 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1209 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
1196 if (info->cross_site_handler()) | 1210 if (info->cross_site_handler()) |
1197 info->cross_site_handler()->ResumeResponse(); | 1211 info->cross_site_handler()->ResumeResponse(); |
1198 } | 1212 } |
1199 | 1213 |
1200 // Update the RenderViewHost's internal state after the ACK. | 1214 // Update the RenderViewHost's internal state after the ACK. |
1201 BrowserThread::PostTask( | 1215 BrowserThread::PostTask( |
1202 BrowserThread::UI, | 1216 BrowserThread::UI, |
1203 FROM_HERE, | 1217 FROM_HERE, |
1204 base::Bind(&OnSwapOutACKHelper, | 1218 base::Bind(&OnSwapOutACKHelper, |
1205 params.closing_process_id, | 1219 params.closing_process_id, |
1206 params.closing_route_id)); | 1220 params.closing_route_id, |
| 1221 timed_out)); |
1207 } | 1222 } |
1208 | 1223 |
1209 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( | 1224 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( |
1210 const GURL& url, | 1225 const GURL& url, |
1211 const std::string& security_info, | 1226 const std::string& security_info, |
1212 const std::string& http_method, | 1227 const std::string& http_method, |
1213 const std::string& mime_type, | 1228 const std::string& mime_type, |
1214 ResourceType::Type resource_type) { | 1229 ResourceType::Type resource_type) { |
1215 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) | 1230 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) |
1216 return; | 1231 return; |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 | 1735 |
1721 return i->second.get(); | 1736 return i->second.get(); |
1722 } | 1737 } |
1723 | 1738 |
1724 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, | 1739 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, |
1725 int request_id) const { | 1740 int request_id) const { |
1726 return GetLoader(GlobalRequestID(child_id, request_id)); | 1741 return GetLoader(GlobalRequestID(child_id, request_id)); |
1727 } | 1742 } |
1728 | 1743 |
1729 } // namespace content | 1744 } // namespace content |
OLD | NEW |