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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 1117923004: Run load state update timer only when needed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cpu
Patch Set: Fixes for mmenke Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_scheduler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698