diff options
author | qsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-20 14:18:22 +0000 |
---|---|---|
committer | qsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-20 14:18:22 +0000 |
commit | 26e82329adab3219c66c66aeb155da153ba10573 (patch) | |
tree | 745a4fdf3a3d25e7ad53b155087407d163cd4591 /content | |
parent | f87514078928f6e5781b4818838f091d8cbdda3d (diff) | |
download | chromium_src-26e82329adab3219c66c66aeb155da153ba10573.zip chromium_src-26e82329adab3219c66c66aeb155da153ba10573.tar.gz chromium_src-26e82329adab3219c66c66aeb155da153ba10573.tar.bz2 |
Disable the idle handler timer when no action is expected.
On Android, the webkit timer are disabled after the application is in
the background for 5 minutes. When this happens, there is no reason to
let the idle handler timer run indefinitly. This CL disables the timer
once v8 reported that it will not take any further action.
BUG=333875
Review URL: https://codereview.chromium.org/136903002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/renderer/render_thread_impl.cc | 19 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.h | 1 |
2 files changed, 17 insertions, 3 deletions
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index bf37dc2..1ddfa29 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -332,6 +332,7 @@ void RenderThreadImpl::Init() { // In single process the single process is all there is. suspend_webkit_shared_timer_ = true; notify_webkit_of_modal_loop_ = true; + webkit_shared_timer_suspended_ = false; widget_count_ = 0; hidden_widget_count_ = 0; idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; @@ -820,7 +821,13 @@ void RenderThreadImpl::IdleHandler() { base::allocator::ReleaseFreeMemory(); - v8::V8::IdleNotification(); + // Continue the idle timer if the webkit shared timer is not suspended or + // something is left to do. + bool continue_timer = !webkit_shared_timer_suspended_; + + if (!v8::V8::IdleNotification()) { + continue_timer = true; + } // Schedule next invocation. // Dampen the delay using the algorithm (if delay is in seconds): @@ -833,8 +840,13 @@ void RenderThreadImpl::IdleHandler() { // delay_ms = delay_ms + 1000*1000 / (delay_ms + 2000). // Note that idle_notification_delay_in_ms_ would be reset to // kInitialIdleHandlerDelayMs in RenderThreadImpl::WidgetHidden. - ScheduleIdleHandler(idle_notification_delay_in_ms_ + - 1000000 / (idle_notification_delay_in_ms_ + 2000)); + if (continue_timer) { + ScheduleIdleHandler(idle_notification_delay_in_ms_ + + 1000000 / (idle_notification_delay_in_ms_ + 2000)); + + } else { + idle_timer_.Stop(); + } FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification()); } @@ -1310,6 +1322,7 @@ void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { } else { webkit_platform_support_->ResumeSharedTimer(); } + webkit_shared_timer_suspended_ = suspend; } } #endif diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index 05b18f2..3670165 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -449,6 +449,7 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, bool suspend_webkit_shared_timer_; bool notify_webkit_of_modal_loop_; + bool webkit_shared_timer_suspended_; // The following flag is used to control layout test specific behavior. bool layout_test_mode_; |