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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 580173003: Set IdleHandler timer on background threads a minimum of 30s in the future after initial run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 4a1a1bccc401221de6ccb4183f98ed0b8d45abf9..3842bca15684605283d42e4376996aeb1eb0c7fa 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -1017,20 +1017,24 @@ void RenderThreadImpl::IdleHandler() {
continue_timer = true;
}
- // Schedule next invocation.
+ // Schedule next invocation. When the tab is originally hidden, an invocation
+ // is scheduled for kInitialIdleHandlerDelayMs in
+ // RenderThreadImpl::WidgetHidden in order to race to a minimal heap.
+ // After that, idle calls can be much less frequent, so run at a maximum of
+ // once every kLongIdleHandlerDelayMs.
// Dampen the delay using the algorithm (if delay is in seconds):
// delay = delay + 1 / (delay + 2)
// Using floor(delay) has a dampening effect such as:
- // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
+ // 30s, 30, 30, 31, 31, 31, 31, 32, 32, ...
pasko 2014/10/09 09:32:14 with the new formula the series is actually growin
sullivan 2014/10/10 20:55:27 I added a new patch to try and clarify the comment
// If the delay is in milliseconds, the above formula is equivalent to:
// delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2)
// which is equivalent to
// delay_ms = delay_ms + 1000*1000 / (delay_ms + 2000).
- // Note that idle_notification_delay_in_ms_ would be reset to
- // kInitialIdleHandlerDelayMs in RenderThreadImpl::WidgetHidden.
pasko 2014/10/09 09:32:14 why deleting this comment?
sullivan 2014/10/10 20:55:27 It was a little misleading, since it's reset to kI
if (continue_timer) {
- ScheduleIdleHandler(idle_notification_delay_in_ms_ +
- 1000000 / (idle_notification_delay_in_ms_ + 2000));
+ ScheduleIdleHandler(
+ std::max(kLongIdleHandlerDelayMs,
+ idle_notification_delay_in_ms_ +
+ 1000000 / (idle_notification_delay_in_ms_ + 2000)));
} else {
idle_timer_.Stop();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698