Chromium Code Reviews| 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 } | 350 } |
| 351 | 351 |
| 352 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 352 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
| 353 : save_file_manager_(new SaveFileManager()), | 353 : save_file_manager_(new SaveFileManager()), |
| 354 request_id_(-1), | 354 request_id_(-1), |
| 355 is_shutdown_(false), | 355 is_shutdown_(false), |
| 356 max_outstanding_requests_cost_per_process_( | 356 max_outstanding_requests_cost_per_process_( |
| 357 kMaxOutstandingRequestsCostPerProcess), | 357 kMaxOutstandingRequestsCostPerProcess), |
| 358 filter_(NULL), | 358 filter_(NULL), |
| 359 delegate_(NULL), | 359 delegate_(NULL), |
| 360 allow_cross_origin_auth_prompt_(false) { | 360 allow_cross_origin_auth_prompt_(false), |
| 361 resource_scheduler_(new ResourceScheduler()) { | |
| 361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 362 DCHECK(!g_resource_dispatcher_host); | 363 DCHECK(!g_resource_dispatcher_host); |
| 363 g_resource_dispatcher_host = this; | 364 g_resource_dispatcher_host = this; |
| 364 | 365 |
| 365 GetContentClient()->browser()->ResourceDispatcherHostCreated(); | 366 GetContentClient()->browser()->ResourceDispatcherHostCreated(); |
| 366 | 367 |
| 367 ANNOTATE_BENIGN_RACE( | 368 ANNOTATE_BENIGN_RACE( |
| 368 &last_user_gesture_time_, | 369 &last_user_gesture_time_, |
| 369 "We don't care about the precise value, see http://crbug.com/92889"); | 370 "We don't care about the precise value, see http://crbug.com/92889"); |
| 370 | 371 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 | 415 |
| 415 // Note that request cancellation has side effects. Therefore, we gather all | 416 // Note that request cancellation has side effects. Therefore, we gather all |
| 416 // the requests to cancel first, and then we start cancelling. We assert at | 417 // the requests to cancel first, and then we start cancelling. We assert at |
| 417 // the end that there are no more to cancel since the context is about to go | 418 // the end that there are no more to cancel since the context is about to go |
| 418 // away. | 419 // away. |
| 419 typedef std::vector<linked_ptr<ResourceLoader> > LoaderList; | 420 typedef std::vector<linked_ptr<ResourceLoader> > LoaderList; |
| 420 LoaderList loaders_to_cancel; | 421 LoaderList loaders_to_cancel; |
| 421 | 422 |
| 422 for (LoaderMap::iterator i = pending_loaders_.begin(); | 423 for (LoaderMap::iterator i = pending_loaders_.begin(); |
| 423 i != pending_loaders_.end();) { | 424 i != pending_loaders_.end();) { |
| 424 if (i->second->GetRequestInfo()->GetContext() == context) { | 425 if (i->second->loader()->GetRequestInfo()->GetContext() == context) { |
| 425 loaders_to_cancel.push_back(i->second); | 426 loaders_to_cancel.push_back(i->second->loader()); |
| 426 pending_loaders_.erase(i++); | 427 pending_loaders_.erase(i++); |
| 427 } else { | 428 } else { |
| 428 ++i; | 429 ++i; |
| 429 } | 430 } |
| 430 } | 431 } |
| 431 | 432 |
| 432 for (BlockedLoadersMap::iterator i = blocked_loaders_map_.begin(); | 433 for (BlockedLoadersMap::iterator i = blocked_loaders_map_.begin(); |
| 433 i != blocked_loaders_map_.end();) { | 434 i != blocked_loaders_map_.end();) { |
| 434 BlockedLoadersList* loaders = i->second; | 435 BlockedLoadersList* loaders = i->second; |
| 435 if (loaders->empty()) { | 436 if (loaders->empty()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 DCHECK((*i)->GetRequestInfo()->is_download() || (*i)->is_transferring()); | 470 DCHECK((*i)->GetRequestInfo()->is_download() || (*i)->is_transferring()); |
| 470 } | 471 } |
| 471 #endif | 472 #endif |
| 472 | 473 |
| 473 loaders_to_cancel.clear(); | 474 loaders_to_cancel.clear(); |
| 474 | 475 |
| 475 // Validate that no more requests for this context were added. | 476 // Validate that no more requests for this context were added. |
| 476 for (LoaderMap::const_iterator i = pending_loaders_.begin(); | 477 for (LoaderMap::const_iterator i = pending_loaders_.begin(); |
| 477 i != pending_loaders_.end(); ++i) { | 478 i != pending_loaders_.end(); ++i) { |
| 478 // http://crbug.com/90971 | 479 // http://crbug.com/90971 |
| 479 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context); | 480 CHECK_NE(i->second->loader()->GetRequestInfo()->GetContext(), context); |
| 480 } | 481 } |
| 481 | 482 |
| 482 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin(); | 483 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin(); |
| 483 i != blocked_loaders_map_.end(); ++i) { | 484 i != blocked_loaders_map_.end(); ++i) { |
| 484 BlockedLoadersList* loaders = i->second; | 485 BlockedLoadersList* loaders = i->second; |
| 485 if (!loaders->empty()) { | 486 if (!loaders->empty()) { |
| 486 ResourceRequestInfoImpl* info = loaders->front()->GetRequestInfo(); | 487 ResourceRequestInfoImpl* info = loaders->front()->GetRequestInfo(); |
| 487 // http://crbug.com/90971 | 488 // http://crbug.com/90971 |
| 488 CHECK_NE(info->GetContext(), context); | 489 CHECK_NE(info->GetContext(), context); |
| 489 } | 490 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 ResourceLoader* loader, | 650 ResourceLoader* loader, |
| 650 net::SSLCertRequestInfo* cert_info) { | 651 net::SSLCertRequestInfo* cert_info) { |
| 651 if (delegate_ && !delegate_->AcceptSSLClientCertificateRequest( | 652 if (delegate_ && !delegate_->AcceptSSLClientCertificateRequest( |
| 652 loader->request(), cert_info)) { | 653 loader->request(), cert_info)) { |
| 653 return false; | 654 return false; |
| 654 } | 655 } |
| 655 | 656 |
| 656 return true; | 657 return true; |
| 657 } | 658 } |
| 658 | 659 |
| 659 bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader, | 660 bool ResourceDispatcherHostImpl::HandleExternalProtocol( |
| 660 const GURL& url) { | 661 ResourceLoader* loader, |
| 662 const GURL& url) { | |
| 661 if (!delegate_) | 663 if (!delegate_) |
| 662 return false; | 664 return false; |
| 663 | 665 |
| 664 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 666 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 665 | 667 |
| 666 if (!ResourceType::IsFrame(info->GetResourceType())) | 668 if (!ResourceType::IsFrame(info->GetResourceType())) |
| 667 return false; | 669 return false; |
| 668 | 670 |
| 669 const net::URLRequestJobFactory* job_factory = | 671 const net::URLRequestJobFactory* job_factory = |
| 670 info->GetContext()->GetRequestContext()->job_factory(); | 672 info->GetContext()->GetRequestContext()->job_factory(); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 698 GetCertID(loader->request(), info->GetChildID()), | 700 GetCertID(loader->request(), info->GetChildID()), |
| 699 new_url)); | 701 new_url)); |
| 700 BrowserThread::PostTask( | 702 BrowserThread::PostTask( |
| 701 BrowserThread::UI, FROM_HERE, | 703 BrowserThread::UI, FROM_HERE, |
| 702 base::Bind( | 704 base::Bind( |
| 703 &NotifyOnUI<ResourceRedirectDetails>, | 705 &NotifyOnUI<ResourceRedirectDetails>, |
| 704 static_cast<int>(NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), | 706 static_cast<int>(NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), |
| 705 render_process_id, render_view_id, base::Passed(&detail))); | 707 render_process_id, render_view_id, base::Passed(&detail))); |
| 706 } | 708 } |
| 707 | 709 |
| 708 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { | 710 void ResourceDispatcherHostImpl::DidReceiveResponse( |
| 711 ResourceLoader* loader) { | |
|
willchan no longer on Chromium
2012/12/03 02:30:16
Not obvious to me why you made this change, but OK
James Simonsen
2012/12/05 01:52:45
Done.
| |
| 709 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 712 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 710 | 713 |
| 711 int render_process_id, render_view_id; | 714 int render_process_id, render_view_id; |
| 712 if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) | 715 if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) |
| 713 return; | 716 return; |
| 714 | 717 |
| 715 // Notify the observers on the UI thread. | 718 // Notify the observers on the UI thread. |
| 716 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( | 719 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( |
| 717 loader->request(), | 720 loader->request(), |
| 718 GetCertID(loader->request(), info->GetChildID()))); | 721 GetCertID(loader->request(), info->GetChildID()))); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 int child_id = filter_->child_id(); | 870 int child_id = filter_->child_id(); |
| 868 | 871 |
| 869 // If we crash here, figure out what URL the renderer was requesting. | 872 // If we crash here, figure out what URL the renderer was requesting. |
| 870 // http://crbug.com/91398 | 873 // http://crbug.com/91398 |
| 871 char url_buf[128]; | 874 char url_buf[128]; |
| 872 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); | 875 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); |
| 873 base::debug::Alias(url_buf); | 876 base::debug::Alias(url_buf); |
| 874 | 877 |
| 875 // If the request that's coming in is being transferred from another process, | 878 // If the request that's coming in is being transferred from another process, |
| 876 // we want to reuse and resume the old loader rather than start a new one. | 879 // we want to reuse and resume the old loader rather than start a new one. |
| 877 linked_ptr<ResourceLoader> deferred_loader; | 880 linked_ptr<ResourceLoader> deferred_loader; |
|
willchan no longer on Chromium
2012/12/03 02:30:16
All this linked_ptr stuff annoys me. I want scoped
James Simonsen
2012/12/05 01:52:45
Done. LoaderMap still uses them. We could conceiva
| |
| 878 { | 881 { |
| 879 LoaderMap::iterator it = pending_loaders_.find( | 882 LoaderMap::iterator it = pending_loaders_.find( |
| 880 GlobalRequestID(request_data.transferred_request_child_id, | 883 GlobalRequestID(request_data.transferred_request_child_id, |
| 881 request_data.transferred_request_request_id)); | 884 request_data.transferred_request_request_id)); |
| 882 if (it != pending_loaders_.end()) { | 885 if (it != pending_loaders_.end()) { |
| 883 if (it->second->is_transferring()) { | 886 if (it->second->loader()->is_transferring()) { |
| 884 deferred_loader = it->second; | 887 deferred_loader = it->second->loader(); |
| 885 pending_loaders_.erase(it); | 888 pending_loaders_.erase(it); |
| 886 } else { | 889 } else { |
| 887 RecordAction(UserMetricsAction("BadMessageTerminate_RDH")); | 890 RecordAction(UserMetricsAction("BadMessageTerminate_RDH")); |
| 888 filter_->BadMessageReceived(); | 891 filter_->BadMessageReceived(); |
| 889 return; | 892 return; |
| 890 } | 893 } |
| 891 } | 894 } |
| 892 } | 895 } |
| 893 | 896 |
| 894 ResourceContext* resource_context = filter_->resource_context(); | 897 ResourceContext* resource_context = filter_->resource_context(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 new TransferNavigationResourceThrottle(request)); | 1053 new TransferNavigationResourceThrottle(request)); |
| 1051 } | 1054 } |
| 1052 | 1055 |
| 1053 if (!throttles.empty()) { | 1056 if (!throttles.empty()) { |
| 1054 handler.reset( | 1057 handler.reset( |
| 1055 new ThrottlingResourceHandler(handler.Pass(), child_id, request_id, | 1058 new ThrottlingResourceHandler(handler.Pass(), child_id, request_id, |
| 1056 throttles.Pass())); | 1059 throttles.Pass())); |
| 1057 } | 1060 } |
| 1058 | 1061 |
| 1059 if (deferred_loader.get()) { | 1062 if (deferred_loader.get()) { |
| 1060 pending_loaders_[extra_info->GetGlobalRequestID()] = deferred_loader; | 1063 pending_loaders_[extra_info->GetGlobalRequestID()] = make_linked_ptr( |
| 1064 resource_scheduler_->ScheduleLoad(child_id, route_id, request_id, | |
| 1065 deferred_loader).release()); | |
| 1061 deferred_loader->CompleteTransfer(handler.Pass()); | 1066 deferred_loader->CompleteTransfer(handler.Pass()); |
| 1062 } else { | 1067 } else { |
| 1063 BeginRequestInternal(new_request.Pass(), handler.Pass()); | 1068 BeginRequestInternal(new_request.Pass(), handler.Pass()); |
| 1064 } | 1069 } |
| 1065 } | 1070 } |
| 1066 | 1071 |
| 1067 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { | 1072 void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
| 1068 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 1073 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
| 1069 } | 1074 } |
| 1070 | 1075 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 const ViewMsg_SwapOut_Params& params) { | 1186 const ViewMsg_SwapOut_Params& params) { |
| 1182 // Call the real implementation with true, which means that we timed out. | 1187 // Call the real implementation with true, which means that we timed out. |
| 1183 HandleSwapOutACK(params, true); | 1188 HandleSwapOutACK(params, true); |
| 1184 } | 1189 } |
| 1185 | 1190 |
| 1186 void ResourceDispatcherHostImpl::HandleSwapOutACK( | 1191 void ResourceDispatcherHostImpl::HandleSwapOutACK( |
| 1187 const ViewMsg_SwapOut_Params& params, bool timed_out) { | 1192 const ViewMsg_SwapOut_Params& params, bool timed_out) { |
| 1188 // Closes for cross-site transitions are handled such that the cross-site | 1193 // Closes for cross-site transitions are handled such that the cross-site |
| 1189 // transition continues. | 1194 // transition continues. |
| 1190 ResourceLoader* loader = GetLoader(params.new_render_process_host_id, | 1195 ResourceLoader* loader = GetLoader(params.new_render_process_host_id, |
| 1191 params.new_request_id); | 1196 params.new_request_id); |
| 1192 if (loader) { | 1197 if (loader) { |
| 1193 // The response we were meant to resume could have already been canceled. | 1198 // The response we were meant to resume could have already been canceled. |
| 1194 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 1199 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 1195 if (info->cross_site_handler()) | 1200 if (info->cross_site_handler()) |
| 1196 info->cross_site_handler()->ResumeResponse(); | 1201 info->cross_site_handler()->ResumeResponse(); |
| 1197 } | 1202 } |
| 1198 | 1203 |
| 1199 // Update the RenderViewHost's internal state after the ACK. | 1204 // Update the RenderViewHost's internal state after the ACK. |
| 1200 BrowserThread::PostTask( | 1205 BrowserThread::PostTask( |
| 1201 BrowserThread::UI, | 1206 BrowserThread::UI, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1280 int child_id) const { | 1285 int child_id) const { |
| 1281 OutstandingRequestsMemoryCostMap::const_iterator entry = | 1286 OutstandingRequestsMemoryCostMap::const_iterator entry = |
| 1282 outstanding_requests_memory_cost_map_.find(child_id); | 1287 outstanding_requests_memory_cost_map_.find(child_id); |
| 1283 return (entry == outstanding_requests_memory_cost_map_.end()) ? | 1288 return (entry == outstanding_requests_memory_cost_map_.end()) ? |
| 1284 0 : entry->second; | 1289 0 : entry->second; |
| 1285 } | 1290 } |
| 1286 | 1291 |
| 1287 // The object died, so cancel and detach all requests associated with it except | 1292 // The object died, so cancel and detach all requests associated with it except |
| 1288 // for downloads, which belong to the browser process even if initiated via a | 1293 // for downloads, which belong to the browser process even if initiated via a |
| 1289 // renderer. | 1294 // renderer. |
| 1290 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { | 1295 void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { |
|
willchan no longer on Chromium
2012/12/03 02:30:16
How does <a ping> work here? AFAICT, it's broken.
James Simonsen
2012/12/05 01:52:45
How so? They have a child_id, but no route_id. The
willchan no longer on Chromium
2012/12/05 03:44:28
Are you saying that we *want* to cancel <a ping> r
| |
| 1291 CancelRequestsForRoute(child_id, -1 /* cancel all */); | 1296 CancelRequestsForRoute(child_id, -1 /* cancel all */); |
| 1292 registered_temp_files_.erase(child_id); | 1297 registered_temp_files_.erase(child_id); |
| 1293 } | 1298 } |
| 1294 | 1299 |
| 1295 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, | 1300 void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, |
| 1296 int route_id) { | 1301 int route_id) { |
| 1297 // Since pending_requests_ is a map, we first build up a list of all of the | 1302 // Since pending_requests_ is a map, we first build up a list of all of the |
| 1298 // matching requests to be cancelled, and then we cancel them. Since there | 1303 // matching requests to be cancelled, and then we cancel them. Since there |
| 1299 // may be more than one request to cancel, we cannot simply hold onto the map | 1304 // may be more than one request to cancel, we cannot simply hold onto the map |
| 1300 // iterators found in the first loop. | 1305 // iterators found in the first loop. |
| 1301 | 1306 |
| 1302 // Find the global ID of all matching elements. | 1307 // Find the global ID of all matching elements. |
| 1303 std::vector<GlobalRequestID> matching_requests; | 1308 std::vector<GlobalRequestID> matching_requests; |
| 1304 for (LoaderMap::const_iterator i = pending_loaders_.begin(); | 1309 for (LoaderMap::const_iterator i = pending_loaders_.begin(); |
| 1305 i != pending_loaders_.end(); ++i) { | 1310 i != pending_loaders_.end(); ++i) { |
| 1306 if (i->first.child_id != child_id) | 1311 if (i->first.child_id != child_id) |
| 1307 continue; | 1312 continue; |
| 1308 | 1313 |
| 1309 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | 1314 ResourceRequestInfoImpl* info = i->second->loader()->GetRequestInfo(); |
| 1310 | 1315 |
| 1311 GlobalRequestID id(child_id, i->first.request_id); | 1316 GlobalRequestID id(child_id, i->first.request_id); |
| 1312 DCHECK(id == i->first); | 1317 DCHECK(id == i->first); |
| 1313 | 1318 |
| 1314 // Don't cancel navigations that are transferring to another process, | 1319 // Don't cancel navigations that are transferring to another process, |
| 1315 // since they belong to another process now. | 1320 // since they belong to another process now. |
| 1316 if (!info->is_download() && !IsTransferredNavigation(id) && | 1321 if (!info->is_download() && !IsTransferredNavigation(id) && |
| 1317 (route_id == -1 || route_id == info->GetRouteID())) { | 1322 (route_id == -1 || route_id == info->GetRouteID())) { |
| 1318 matching_requests.push_back(id); | 1323 matching_requests.push_back(id); |
| 1319 } | 1324 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1366 GlobalRequestID(child_id, request_id)); | 1371 GlobalRequestID(child_id, request_id)); |
| 1367 if (i == pending_loaders_.end()) { | 1372 if (i == pending_loaders_.end()) { |
| 1368 NOTREACHED() << "Trying to remove a request that's not here"; | 1373 NOTREACHED() << "Trying to remove a request that's not here"; |
| 1369 return; | 1374 return; |
| 1370 } | 1375 } |
| 1371 RemovePendingLoader(i); | 1376 RemovePendingLoader(i); |
| 1372 } | 1377 } |
| 1373 | 1378 |
| 1374 void ResourceDispatcherHostImpl::RemovePendingLoader( | 1379 void ResourceDispatcherHostImpl::RemovePendingLoader( |
| 1375 const LoaderMap::iterator& iter) { | 1380 const LoaderMap::iterator& iter) { |
| 1376 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); | 1381 ResourceRequestInfoImpl* info = iter->second->loader()->GetRequestInfo(); |
| 1377 | 1382 |
| 1378 // Remove the memory credit that we added when pushing the request onto | 1383 // Remove the memory credit that we added when pushing the request onto |
| 1379 // the pending list. | 1384 // the pending list. |
| 1380 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), | 1385 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
| 1381 info->GetChildID()); | 1386 info->GetChildID()); |
| 1382 | 1387 |
| 1383 pending_loaders_.erase(iter); | 1388 pending_loaders_.erase(iter); |
| 1384 | 1389 |
| 1385 // If we have no more pending requests, then stop the load state monitor | 1390 // If we have no more pending requests, then stop the load state monitor |
| 1386 if (pending_loaders_.empty() && update_load_states_timer_.get()) | 1391 if (pending_loaders_.empty() && update_load_states_timer_.get()) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1495 iter->second->push_back(loader); | 1500 iter->second->push_back(loader); |
| 1496 return; | 1501 return; |
| 1497 } | 1502 } |
| 1498 | 1503 |
| 1499 StartLoading(info, loader); | 1504 StartLoading(info, loader); |
| 1500 } | 1505 } |
| 1501 | 1506 |
| 1502 void ResourceDispatcherHostImpl::StartLoading( | 1507 void ResourceDispatcherHostImpl::StartLoading( |
| 1503 ResourceRequestInfoImpl* info, | 1508 ResourceRequestInfoImpl* info, |
| 1504 const linked_ptr<ResourceLoader>& loader) { | 1509 const linked_ptr<ResourceLoader>& loader) { |
| 1505 pending_loaders_[info->GetGlobalRequestID()] = loader; | 1510 pending_loaders_[info->GetGlobalRequestID()] = make_linked_ptr( |
| 1506 | 1511 resource_scheduler_->ScheduleLoad( |
| 1507 loader->StartRequest(); | 1512 info->GetChildID(), info->GetRouteID(), |
| 1513 info->GetRequestID(), loader).release()); | |
| 1508 } | 1514 } |
| 1509 | 1515 |
| 1510 void ResourceDispatcherHostImpl::OnUserGesture(WebContentsImpl* contents) { | 1516 void ResourceDispatcherHostImpl::OnUserGesture(WebContentsImpl* contents) { |
| 1511 last_user_gesture_time_ = TimeTicks::Now(); | 1517 last_user_gesture_time_ = TimeTicks::Now(); |
| 1512 } | 1518 } |
| 1513 | 1519 |
| 1514 net::URLRequest* ResourceDispatcherHostImpl::GetURLRequest( | 1520 net::URLRequest* ResourceDispatcherHostImpl::GetURLRequest( |
| 1515 const GlobalRequestID& id) { | 1521 const GlobalRequestID& id) { |
| 1516 ResourceLoader* loader = GetLoader(id); | 1522 ResourceLoader* loader = GetLoader(id); |
| 1517 if (!loader) | 1523 if (!loader) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1574 // Populate this map with load state changes, and then send them on to the UI | 1580 // Populate this map with load state changes, and then send them on to the UI |
| 1575 // thread where they can be passed along to the respective RVHs. | 1581 // thread where they can be passed along to the respective RVHs. |
| 1576 LoadInfoMap info_map; | 1582 LoadInfoMap info_map; |
| 1577 | 1583 |
| 1578 LoaderMap::const_iterator i; | 1584 LoaderMap::const_iterator i; |
| 1579 | 1585 |
| 1580 // Determine the largest upload size of all requests | 1586 // Determine the largest upload size of all requests |
| 1581 // in each View (good chance it's zero). | 1587 // in each View (good chance it's zero). |
| 1582 std::map<std::pair<int, int>, uint64> largest_upload_size; | 1588 std::map<std::pair<int, int>, uint64> largest_upload_size; |
| 1583 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { | 1589 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { |
| 1584 net::URLRequest* request = i->second->request(); | 1590 net::URLRequest* request = i->second->loader()->request(); |
| 1585 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | 1591 ResourceRequestInfoImpl* info = i->second->loader()->GetRequestInfo(); |
| 1586 uint64 upload_size = request->GetUploadProgress().size(); | 1592 uint64 upload_size = request->GetUploadProgress().size(); |
| 1587 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) | 1593 if (request->GetLoadState().state != net::LOAD_STATE_SENDING_REQUEST) |
| 1588 upload_size = 0; | 1594 upload_size = 0; |
| 1589 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); | 1595 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); |
| 1590 if (upload_size && largest_upload_size[key] < upload_size) | 1596 if (upload_size && largest_upload_size[key] < upload_size) |
| 1591 largest_upload_size[key] = upload_size; | 1597 largest_upload_size[key] = upload_size; |
| 1592 } | 1598 } |
| 1593 | 1599 |
| 1594 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { | 1600 for (i = pending_loaders_.begin(); i != pending_loaders_.end(); ++i) { |
| 1595 net::URLRequest* request = i->second->request(); | 1601 net::URLRequest* request = i->second->loader()->request(); |
| 1596 ResourceRequestInfoImpl* info = i->second->GetRequestInfo(); | 1602 ResourceRequestInfoImpl* info = i->second->loader()->GetRequestInfo(); |
| 1597 net::LoadStateWithParam load_state = request->GetLoadState(); | 1603 net::LoadStateWithParam load_state = request->GetLoadState(); |
| 1598 net::UploadProgress progress = request->GetUploadProgress(); | 1604 net::UploadProgress progress = request->GetUploadProgress(); |
| 1599 | 1605 |
| 1600 // We also poll for upload progress on this timer and send upload | 1606 // We also poll for upload progress on this timer and send upload |
| 1601 // progress ipc messages to the plugin process. | 1607 // progress ipc messages to the plugin process. |
| 1602 i->second->ReportUploadProgress(); | 1608 i->second->loader()->ReportUploadProgress(); |
| 1603 | 1609 |
| 1604 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); | 1610 std::pair<int, int> key(info->GetChildID(), info->GetRouteID()); |
| 1605 | 1611 |
| 1606 // If a request is uploading data, ignore all other requests so that the | 1612 // If a request is uploading data, ignore all other requests so that the |
| 1607 // upload progress takes priority for being shown in the status bar. | 1613 // upload progress takes priority for being shown in the status bar. |
| 1608 if (largest_upload_size.find(key) != largest_upload_size.end() && | 1614 if (largest_upload_size.find(key) != largest_upload_size.end() && |
| 1609 progress.size() < largest_upload_size[key]) | 1615 progress.size() < largest_upload_size[key]) |
| 1610 continue; | 1616 continue; |
| 1611 | 1617 |
| 1612 net::LoadStateWithParam to_insert = load_state; | 1618 net::LoadStateWithParam to_insert = load_state; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1711 } | 1717 } |
| 1712 | 1718 |
| 1713 ResourceLoader* ResourceDispatcherHostImpl::GetLoader( | 1719 ResourceLoader* ResourceDispatcherHostImpl::GetLoader( |
| 1714 const GlobalRequestID& id) const { | 1720 const GlobalRequestID& id) const { |
| 1715 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1721 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1716 | 1722 |
| 1717 LoaderMap::const_iterator i = pending_loaders_.find(id); | 1723 LoaderMap::const_iterator i = pending_loaders_.find(id); |
| 1718 if (i == pending_loaders_.end()) | 1724 if (i == pending_loaders_.end()) |
| 1719 return NULL; | 1725 return NULL; |
| 1720 | 1726 |
| 1721 return i->second.get(); | 1727 return i->second->loader().get(); |
| 1722 } | 1728 } |
| 1723 | 1729 |
| 1724 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, | 1730 ResourceLoader* ResourceDispatcherHostImpl::GetLoader( |
| 1725 int request_id) const { | 1731 int child_id, int request_id) const { |
| 1726 return GetLoader(GlobalRequestID(child_id, request_id)); | 1732 return GetLoader(GlobalRequestID(child_id, request_id)); |
| 1727 } | 1733 } |
| 1728 | 1734 |
| 1729 } // namespace content | 1735 } // namespace content |
| OLD | NEW |