OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |