Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 15682009: Eliminate SwapOut message parameters, keeping state in RVHM instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move pending_nav_params_ to RVHM Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 download, // is_download 1205 download, // is_download
1216 false, // is_stream 1206 false, // is_stream
1217 download, // allow_download 1207 download, // allow_download
1218 false, // has_user_gesture 1208 false, // has_user_gesture
1219 WebKit::WebReferrerPolicyDefault, 1209 WebKit::WebReferrerPolicyDefault,
1220 context, 1210 context,
1221 true); // is_async 1211 true); // is_async
1222 } 1212 }
1223 1213
1224 1214
1225 void ResourceDispatcherHostImpl::OnSwapOutACK(
1226 const ViewMsg_SwapOut_Params& params) {
1227 HandleSwapOutACK(params, false);
1228 }
1229
1230 void ResourceDispatcherHostImpl::OnSimulateSwapOutACK(
1231 const ViewMsg_SwapOut_Params& params) {
1232 // Call the real implementation with true, which means that we timed out.
1233 HandleSwapOutACK(params, true);
1234 }
1235
1236 void ResourceDispatcherHostImpl::HandleSwapOutACK(
1237 const ViewMsg_SwapOut_Params& params, bool timed_out) {
1238 // Closes for cross-site transitions are handled such that the cross-site
1239 // transition continues.
1240 ResourceLoader* loader = GetLoader(params.new_render_process_host_id,
1241 params.new_request_id);
1242 if (loader) {
1243 // The response we were meant to resume could have already been canceled.
1244 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
1245 if (info->cross_site_handler())
1246 info->cross_site_handler()->ResumeResponse();
1247 }
1248
1249 // Update the RenderViewHost's internal state after the ACK.
1250 BrowserThread::PostTask(
1251 BrowserThread::UI,
1252 FROM_HERE,
1253 base::Bind(&OnSwapOutACKHelper,
1254 params.closing_process_id,
1255 params.closing_route_id,
1256 timed_out));
1257 }
1258
1259 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache( 1215 void ResourceDispatcherHostImpl::OnDidLoadResourceFromMemoryCache(
1260 const GURL& url, 1216 const GURL& url,
1261 const std::string& security_info, 1217 const std::string& security_info,
1262 const std::string& http_method, 1218 const std::string& http_method,
1263 const std::string& mime_type, 1219 const std::string& mime_type,
1264 ResourceType::Type resource_type) { 1220 ResourceType::Type resource_type) {
1265 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) 1221 if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https")))
1266 return; 1222 return;
1267 1223
1268 filter_->GetURLRequestContext(resource_type)->http_transaction_factory()-> 1224 filter_->GetURLRequestContext(resource_type)->http_transaction_factory()->
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 1294 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
1339 1295
1340 BeginRequestInternal(request.Pass(), handler.Pass()); 1296 BeginRequestInternal(request.Pass(), handler.Pass());
1341 } 1297 }
1342 1298
1343 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation( 1299 void ResourceDispatcherHostImpl::MarkAsTransferredNavigation(
1344 const GlobalRequestID& id) { 1300 const GlobalRequestID& id) {
1345 GetLoader(id)->MarkAsTransferring(); 1301 GetLoader(id)->MarkAsTransferring();
1346 } 1302 }
1347 1303
1304 void ResourceDispatcherHostImpl::ResumeDeferredNavigation(
1305 const GlobalRequestID& id) {
1306 ResourceLoader* loader = GetLoader(id);
1307 if (loader) {
1308 // The response we were meant to resume could have already been canceled.
1309 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
1310 if (info->cross_site_handler())
1311 info->cross_site_handler()->ResumeResponse();
1312 }
1313 }
1314
1348 // The object died, so cancel and detach all requests associated with it except 1315 // The object died, so cancel and detach all requests associated with it except
1349 // for downloads, which belong to the browser process even if initiated via a 1316 // for downloads, which belong to the browser process even if initiated via a
1350 // renderer. 1317 // renderer.
1351 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { 1318 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) {
1352 CancelRequestsForRoute(child_id, -1 /* cancel all */); 1319 CancelRequestsForRoute(child_id, -1 /* cancel all */);
1353 registered_temp_files_.erase(child_id); 1320 registered_temp_files_.erase(child_id);
1354 } 1321 }
1355 1322
1356 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, 1323 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id,
1357 int route_id) { 1324 int route_id) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 DelegateMap::iterator it = delegate_map_.find(id); 1841 DelegateMap::iterator it = delegate_map_.find(id);
1875 DCHECK(it->second->HasObserver(delegate)); 1842 DCHECK(it->second->HasObserver(delegate));
1876 it->second->RemoveObserver(delegate); 1843 it->second->RemoveObserver(delegate);
1877 if (it->second->size() == 0) { 1844 if (it->second->size() == 0) {
1878 delete it->second; 1845 delete it->second;
1879 delegate_map_.erase(it); 1846 delegate_map_.erase(it);
1880 } 1847 }
1881 } 1848 }
1882 1849
1883 } // namespace content 1850 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698