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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 8519001: Schedule idle timer of render thread when user is idle. Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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/renderer/mock_content_renderer_client.cc ('k') | content/renderer/render_view_impl.cc » ('j') | 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 962e8569b21753acf8a39184c9bd3d7779656184..cb4c109c755da9f4561faf5bda244e6551fbcdb5 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -560,21 +560,30 @@ void RenderThreadImpl::ScheduleIdleHandler(double initial_delay_s) {
void RenderThreadImpl::IdleHandler() {
#if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
MallocExtension::instance()->ReleaseFreeMemory();
-#endif
-
- v8::V8::IdleNotification();
+ #endif
- // Schedule next invocation.
- // Dampen the delay using the algorithm:
- // delay = delay + 1 / (delay + 2)
- // Using floor(delay) has a dampening effect such as:
- // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
- // Note that idle_notification_delay_in_s_ would be reset to
- // kInitialIdleHandlerDelayS in RenderThreadImpl::WidgetHidden.
- ScheduleIdleHandler(idle_notification_delay_in_s_ +
- 1.0 / (idle_notification_delay_in_s_ + 2.0));
-
- FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification());
+ if (hidden_widget_count_ < widget_count_ &&
+ content::GetContentClient()->renderer()->RunIdleHandlerWhenUserIdle()) {
+ if (!v8::V8::IdleNotification()) {
+ ScheduleIdleHandler(kInitialIdleHandlerDelayS);
+ } else {
+ idle_timer_.Stop();
+ }
+ } else {
+ v8::V8::IdleNotification();
+
+ // Schedule next invocation.
+ // Dampen the delay using the algorithm:
+ // delay = delay + 1 / (delay + 2)
+ // Using floor(delay) has a dampening effect such as:
+ // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
+ // Note that idle_notification_delay_in_s_ would be reset to
+ // kInitialIdleHandlerDelayS in RenderThreadImpl::WidgetHidden.
+ ScheduleIdleHandler(idle_notification_delay_in_s_ +
+ 1.0 / (idle_notification_delay_in_s_ + 2.0));
+
+ FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification());
+ }
}
double RenderThreadImpl::GetIdleNotificationDelayInS() const {
@@ -789,3 +798,4 @@ RenderThreadImpl::GetFileThreadMessageLoopProxy() {
}
return file_thread_->message_loop_proxy();
}
+
« no previous file with comments | « content/renderer/mock_content_renderer_client.cc ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698