| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
| 209 #pragma warning(disable: 4748) | 209 #pragma warning(disable: 4748) |
| 210 #pragma optimize("", off) | 210 #pragma optimize("", off) |
| 211 #endif | 211 #endif |
| 212 | 212 |
| 213 #if defined(OS_WIN) | 213 #if defined(OS_WIN) |
| 214 #pragma optimize("", on) | 214 #pragma optimize("", on) |
| 215 #pragma warning(default: 4748) | 215 #pragma warning(default: 4748) |
| 216 #endif | 216 #endif |
| 217 | 217 |
| 218 void OnSwapOutACKHelper(int render_process_id, | |
| 219 int render_view_id, | |
| 220 bool timed_out) { | |
| 221 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(render_process_id, | |
| 222 render_view_id); | |
| 223 if (rvh) | |
| 224 rvh->OnSwapOutACK(timed_out); | |
| 225 } | |
| 226 | |
| 227 net::Error CallbackAndReturn( | 218 net::Error CallbackAndReturn( |
| 228 const DownloadResourceHandler::OnStartedCallback& started_cb, | 219 const DownloadResourceHandler::OnStartedCallback& started_cb, |
| 229 net::Error net_error) { | 220 net::Error net_error) { |
| 230 if (started_cb.is_null()) | 221 if (started_cb.is_null()) |
| 231 return net_error; | 222 return net_error; |
| 232 BrowserThread::PostTask( | 223 BrowserThread::PostTask( |
| 233 BrowserThread::UI, FROM_HERE, | 224 BrowserThread::UI, FROM_HERE, |
| 234 base::Bind(started_cb, static_cast<DownloadItem*>(NULL), net_error)); | 225 base::Bind(started_cb, static_cast<DownloadItem*>(NULL), net_error)); |
| 235 | 226 |
| 236 return net_error; | 227 return net_error; |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 filter_ = filter; | 836 filter_ = filter; |
| 846 bool handled = true; | 837 bool handled = true; |
| 847 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHostImpl, message, *message_was_ok) | 838 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHostImpl, message, *message_was_ok) |
| 848 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) | 839 IPC_MESSAGE_HANDLER(ResourceHostMsg_RequestResource, OnRequestResource) |
| 849 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) | 840 IPC_MESSAGE_HANDLER_DELAY_REPLY(ResourceHostMsg_SyncLoad, OnSyncLoad) |
| 850 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, | 841 IPC_MESSAGE_HANDLER(ResourceHostMsg_ReleaseDownloadedFile, |
| 851 OnReleaseDownloadedFile) | 842 OnReleaseDownloadedFile) |
| 852 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) | 843 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataDownloaded_ACK, OnDataDownloadedACK) |
| 853 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) | 844 IPC_MESSAGE_HANDLER(ResourceHostMsg_UploadProgress_ACK, OnUploadProgressACK) |
| 854 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) | 845 IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) |
| 855 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) | |
| 856 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, | 846 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 857 OnDidLoadResourceFromMemoryCache) | 847 OnDidLoadResourceFromMemoryCache) |
| 858 IPC_MESSAGE_UNHANDLED(handled = false) | 848 IPC_MESSAGE_UNHANDLED(handled = false) |
| 859 IPC_END_MESSAGE_MAP_EX() | 849 IPC_END_MESSAGE_MAP_EX() |
| 860 | 850 |
| 861 if (!handled && IPC_MESSAGE_ID_CLASS(message.type()) == ResourceMsgStart) { | 851 if (!handled && IPC_MESSAGE_ID_CLASS(message.type()) == ResourceMsgStart) { |
| 862 PickleIterator iter(message); | 852 PickleIterator iter(message); |
| 863 int request_id = -1; | 853 int request_id = -1; |
| 864 bool ok = iter.ReadInt(&request_id); | 854 bool ok = iter.ReadInt(&request_id); |
| 865 DCHECK(ok); | 855 DCHECK(ok); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 download, // is_download | 1206 download, // is_download |
| 1217 false, // is_stream | 1207 false, // is_stream |
| 1218 download, // allow_download | 1208 download, // allow_download |
| 1219 false, // has_user_gesture | 1209 false, // has_user_gesture |
| 1220 WebKit::WebReferrerPolicyDefault, | 1210 WebKit::WebReferrerPolicyDefault, |
| 1221 context, | 1211 context, |
| 1222 true); // is_async | 1212 true); // is_async |
| 1223 } | 1213 } |
| 1224 | 1214 |
| 1225 | 1215 |
| 1226 void ResourceDispatcherHostImpl::OnSwapOutACK( | |
| 1227 const ViewMsg_SwapOut_Params& params) { | |
| 1228 HandleSwapOutACK(params, false); | |
| 1229 } | |
| 1230 | |
| 1231 void ResourceDispatcherHostImpl::OnSimulateSwapOutACK( | |
| 1232 const ViewMsg_SwapOut_Params& params) { | |
| 1233 // Call the real implementation with true, which means that we timed out. | |
| 1234 HandleSwapOutACK(params, true); | |
| 1235 } | |
| 1236 | |
| 1237 void ResourceDispatcherHostImpl::HandleSwapOutACK( | |
| 1238 const ViewMsg_SwapOut_Params& params, bool timed_out) { | |
| 1239 // Closes for cross-site transitions are handled such that the cross-site | |
| 1240 // transition continues. | |
| 1241 ResourceLoader* loader = GetLoader(params.new_render_process_host_id, | |
| 1242 params.new_request_id); | |
| 1243 if (loader) { | |
| 1244 // The response we were meant to resume could have already been canceled. | |
| 1245 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | |
| 1246 if (info->cross_site_handler()) | |
| 1247 info->cross_site_handler()->ResumeResponse(); | |
| 1248 } | |
| 1249 | |
| 1250 // Update the RenderViewHost's internal state after the ACK. | |
| 1251 BrowserThread::PostTask( | |
| 1252 BrowserThread::UI, | |
| 1253 FROM_HERE, | |
| 1254 base::Bind(&OnSwapOutACKHelper, | |
| 1255 params.closing_process_id, | |
| 1256 params.closing_route_id, | |
| 1257 timed_out)); | |
| 1258 } | |
| 1259 | |
| 1260 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( | 1216 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( |
| 1261 const GURL& url, | 1217 const GURL& url, |
| 1262 const std::string& security_info, | 1218 const std::string& security_info, |
| 1263 const std::string& http_method, | 1219 const std::string& http_method, |
| 1264 const std::string& mime_type, | 1220 const std::string& mime_type, |
| 1265 ResourceType::Type resource_type) { | 1221 ResourceType::Type resource_type) { |
| 1266 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) | 1222 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) |
| 1267 return; | 1223 return; |
| 1268 | 1224 |
| 1269 filter_->GetURLRequestContext(resource_type)->http_transaction_factory()-> | 1225 filter_->GetURLRequestContext(resource_type)->http_transaction_factory()-> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | 1295 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
| 1340 | 1296 |
| 1341 BeginRequestInternal(request.Pass(), handler.Pass()); | 1297 BeginRequestInternal(request.Pass(), handler.Pass()); |
| 1342 } | 1298 } |
| 1343 | 1299 |
| 1344 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( | 1300 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( |
| 1345 const GlobalRequestID& id) { | 1301 const GlobalRequestID& id) { |
| 1346 GetLoader(id)->MarkAsTransferring(); | 1302 GetLoader(id)->MarkAsTransferring(); |
| 1347 } | 1303 } |
| 1348 | 1304 |
| 1305 void ResourceDispatcherHostImpl::ResumeDeferredNavigation( |
| 1306 const GlobalRequestID& id) { |
| 1307 ResourceLoader* loader = GetLoader(id); |
| 1308 if (loader) { |
| 1309 // The response we were meant to resume could have already been canceled. |
| 1310 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 1311 if (info->cross_site_handler()) |
| 1312 info->cross_site_handler()->ResumeResponse(); |
| 1313 } |
| 1314 } |
| 1315 |
| 1349 // The object died, so cancel and detach all requests associated with it except | 1316 // The object died, so cancel and detach all requests associated with it except |
| 1350 // for downloads, which belong to the browser process even if initiated via a | 1317 // for downloads, which belong to the browser process even if initiated via a |
| 1351 // renderer. | 1318 // renderer. |
| 1352 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { | 1319 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { |
| 1353 CancelRequestsForRoute(child_id, -1 /* cancel all */); | 1320 CancelRequestsForRoute(child_id, -1 /* cancel all */); |
| 1354 registered_temp_files_.erase(child_id); | 1321 registered_temp_files_.erase(child_id); |
| 1355 } | 1322 } |
| 1356 | 1323 |
| 1357 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, | 1324 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, |
| 1358 int route_id) { | 1325 int route_id) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 DelegateMap::iterator it = delegate_map_.find(id); | 1842 DelegateMap::iterator it = delegate_map_.find(id); |
| 1876 DCHECK(it->second->HasObserver(delegate)); | 1843 DCHECK(it->second->HasObserver(delegate)); |
| 1877 it->second->RemoveObserver(delegate); | 1844 it->second->RemoveObserver(delegate); |
| 1878 if (it->second->size() == 0) { | 1845 if (it->second->size() == 0) { |
| 1879 delete it->second; | 1846 delete it->second; |
| 1880 delegate_map_.erase(it); | 1847 delegate_map_.erase(it); |
| 1881 } | 1848 } |
| 1882 } | 1849 } |
| 1883 | 1850 |
| 1884 } // namespace content | 1851 } // namespace content |
| OLD | NEW |