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..a90e296e5718ccaa4be246ad36464bb788f1e52f 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. |
@@ -788,8 +788,9 @@ 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()) { |
+ // Make sure we have the load state monitor running. |
+ if (!update_load_states_timer_->IsRunning() && |
+ scheduler_->HasLoadingClients()) { |
update_load_states_timer_->Start( |
FROM_HERE, TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
this, &ResourceDispatcherHostImpl::UpdateLoadInfo); |
@@ -1781,10 +1782,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, |
@@ -2206,8 +2203,15 @@ ResourceDispatcherHostImpl::GetLoadInfoForAllRoutes() { |
void ResourceDispatcherHostImpl::UpdateLoadInfo() { |
scoped_ptr<LoadInfoMap> info_map(GetLoadInfoForAllRoutes()); |
- if (info_map->empty()) |
+ // Stop the timer if there are no more pending requests. Future new requests |
+ // will restart it as necessary. |
+ // Also stop the timer if there are no loading clients, to avoid waking up |
+ // unnecessarily when there is a long running (hanging get) request like when |
+ // on a Google Docs document. |
mmenke
2015/05/22 15:19:24
nit: Shouldn't mention Google Docs, think it's fi
Andre
2015/05/22 17:30:21
Done.
|
+ if (info_map->empty() || !scheduler_->HasLoadingClients()) { |
+ update_load_states_timer_->Stop(); |
return; |
+ } |
BrowserThread::PostTask( |
BrowserThread::UI, FROM_HERE, |