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

Side by Side 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: Clarify comments Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 } 1045 }
1046 1046
1047 // Schedule next invocation. When the tab is originally hidden, an invocation 1047 // Schedule next invocation. When the tab is originally hidden, an invocation
1048 // is scheduled for kInitialIdleHandlerDelayMs in 1048 // is scheduled for kInitialIdleHandlerDelayMs in
1049 // RenderThreadImpl::WidgetHidden in order to race to a minimal heap. 1049 // RenderThreadImpl::WidgetHidden in order to race to a minimal heap.
1050 // After that, idle calls can be much less frequent, so run at a maximum of 1050 // After that, idle calls can be much less frequent, so run at a maximum of
1051 // once every kLongIdleHandlerDelayMs. 1051 // once every kLongIdleHandlerDelayMs.
1052 // Dampen the delay using the algorithm (if delay is in seconds): 1052 // Dampen the delay using the algorithm (if delay is in seconds):
1053 // delay = delay + 1 / (delay + 2) 1053 // delay = delay + 1 / (delay + 2)
1054 // Using floor(delay) has a dampening effect such as: 1054 // Using floor(delay) has a dampening effect such as:
1055 // 30s, 30, 30, 31, 31, 31, 31, 32, 32, ... 1055 // 30s repeated > 30 times, 31s repeated > 30 times, 32s...
1056 // If the delay is in milliseconds, the above formula is equivalent to: 1056 // If the delay is in milliseconds, the above formula is equivalent to:
1057 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2) 1057 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2)
1058 // which is equivalent to 1058 // which is equivalent to
1059 // delay_ms = delay_ms + 1000*1000 / (delay_ms + 2000). 1059 // delay_ms = delay_ms + 1000*1000 / (delay_ms + 2000).
1060 if (continue_timer) { 1060 if (continue_timer) {
1061 ScheduleIdleHandler( 1061 ScheduleIdleHandler(
1062 std::max(kLongIdleHandlerDelayMs, 1062 std::max(kLongIdleHandlerDelayMs,
1063 idle_notification_delay_in_ms_ + 1063 idle_notification_delay_in_ms_ +
1064 1000000 / (idle_notification_delay_in_ms_ + 2000))); 1064 1000000 / (idle_notification_delay_in_ms_ + 2000)));
1065 1065
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 hidden_widget_count_--; 1638 hidden_widget_count_--;
1639 1639
1640 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { 1640 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
1641 return; 1641 return;
1642 } 1642 }
1643 1643
1644 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 1644 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
1645 } 1645 }
1646 1646
1647 } // namespace content 1647 } // namespace content
OLDNEW
« 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