Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_impl.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
| index 2e560f635d57729e21d66f439e226ec29f8e7604..cc871f65fe95f6fcffa845631f2a35d78d4a45d2 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_impl.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
| @@ -115,7 +115,7 @@ namespace { |
| static ResourceDispatcherHostImpl* g_resource_dispatcher_host; |
| // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates |
| -const int kUpdateLoadStatesIntervalMsec = 100; |
| +const int kUpdateLoadStatesIntervalMsec = 250; |
| // Maximum byte "cost" of all the outstanding requests for a renderer. |
| // See delcaration of |max_outstanding_requests_cost_per_process_| for details. |
| @@ -453,7 +453,7 @@ ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
| base::Unretained(this))); |
| update_load_states_timer_.reset( |
| - new base::RepeatingTimer<ResourceDispatcherHostImpl>()); |
| + new base::OneShotTimer<ResourceDispatcherHostImpl>()); |
| } |
| ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { |
| @@ -788,12 +788,8 @@ bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader, |
| } |
| void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) { |
| - // Make sure we have the load state monitor running |
| - if (!update_load_states_timer_->IsRunning()) { |
| - update_load_states_timer_->Start( |
| - FROM_HERE, TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
| - this, &ResourceDispatcherHostImpl::UpdateLoadInfo); |
| - } |
| + if (scheduler_->HasLoadingClients()) |
| + ScheduleUpdateLoadInfo(); |
| } |
| void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, |
| @@ -940,7 +936,7 @@ void ResourceDispatcherHostImpl::OnShutdown() { |
| // Make sure we shutdown the timer now, otherwise by the time our destructor |
| // runs if the timer is still running the Task is deleted twice (once by |
| - // the MessageLoop and the second time by RepeatingTimer). |
| + // the MessageLoop and the second time by OneShotTimer). |
| update_load_states_timer_.reset(); |
| // Clear blocked requests if any left. |
| @@ -1781,10 +1777,6 @@ void ResourceDispatcherHostImpl::RemovePendingLoader( |
| IncrementOutstandingRequestsMemory(-1, *info); |
| pending_loaders_.erase(iter); |
| - |
| - // If we have no more pending requests, then stop the load state monitor |
| - if (pending_loaders_.empty() && update_load_states_timer_) |
| - update_load_states_timer_->Stop(); |
| } |
| void ResourceDispatcherHostImpl::CancelRequest(int child_id, |
| @@ -2179,10 +2171,6 @@ ResourceDispatcherHostImpl::GetLoadInfoForAllRoutes() { |
| scoped_ptr<LoadInfoMap> info_map(new LoadInfoMap()); |
| for (const auto& loader : pending_loaders_) { |
|
mmenke
2015/05/21 15:53:25
Should actually remove this call in the other CL.
Andre
2015/05/21 22:05:39
Done.
|
| - // Also poll for upload progress on this timer and send upload progress ipc |
| - // messages to the plugin process. |
| - loader.second->ReportUploadProgress(); |
| - |
| net::URLRequest* request = loader.second->request(); |
| net::UploadProgress upload_progress = request->GetUploadProgress(); |
| @@ -2213,6 +2201,9 @@ void ResourceDispatcherHostImpl::UpdateLoadInfo() { |
| BrowserThread::UI, FROM_HERE, |
| base::Bind(&ResourceDispatcherHostImpl::UpdateLoadInfoOnUIThread, |
| base::Passed(&info_map))); |
| + |
| + if (scheduler_->HasLoadingClients()) |
| + ScheduleUpdateLoadInfo(); |
|
mmenke
2015/05/21 15:53:25
Should use 2 space indent here, not 3
Andre
2015/05/21 22:05:39
Done.
|
| } |
| void ResourceDispatcherHostImpl::BlockRequestsForRoute(int child_id, |
| @@ -2375,4 +2366,12 @@ int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest( |
| return load_flags; |
| } |
| +void ResourceDispatcherHostImpl::ScheduleUpdateLoadInfo() { |
| + if (!update_load_states_timer_->IsRunning()) { |
|
mmenke
2015/05/21 15:53:25
Suggest early return instead - it's generally pref
Andre
2015/05/21 22:05:39
Done.
|
| + update_load_states_timer_->Start( |
| + FROM_HERE, TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
| + this, &ResourceDispatcherHostImpl::UpdateLoadInfo); |
| + } |
| +} |
| + |
| } // namespace content |