Index: components/scheduler/renderer/renderer_scheduler_impl.cc |
diff --git a/components/scheduler/renderer/renderer_scheduler_impl.cc b/components/scheduler/renderer/renderer_scheduler_impl.cc |
index 9f3d9b6ef21a16711e52ff193531d3459aed5064..a5d607e8ddb919a33f5bd68c63bf7e6640f26c71 100644 |
--- a/components/scheduler/renderer/renderer_scheduler_impl.cc |
+++ b/components/scheduler/renderer/renderer_scheduler_impl.cc |
@@ -62,10 +62,6 @@ RendererSchedulerImpl::RendererSchedulerImpl( |
end_renderer_hidden_idle_period_closure_.Reset(base::Bind( |
&RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); |
- suspend_timers_when_backgrounded_closure_.Reset( |
- base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, |
- weak_factory_.GetWeakPtr())); |
- |
default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq"); |
default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq"); |
@@ -351,6 +347,7 @@ void RendererSchedulerImpl::SetHasVisibleRenderWidgetWithTouchHandler( |
UpdatePolicyLocked(UpdateType::FORCE_UPDATE); |
} |
+// TODO(hajimehoshi): This does nothing for now. Remove this handler. |
void RendererSchedulerImpl::OnRendererBackgrounded() { |
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
"RendererSchedulerImpl::OnRendererBackgrounded"); |
@@ -359,16 +356,6 @@ void RendererSchedulerImpl::OnRendererBackgrounded() { |
return; |
MainThreadOnly().renderer_backgrounded = true; |
- if (!MainThreadOnly().timer_queue_suspension_when_backgrounded_enabled) |
- return; |
- |
- suspend_timers_when_backgrounded_closure_.Cancel(); |
- base::TimeDelta suspend_timers_when_backgrounded_delay = |
- base::TimeDelta::FromMilliseconds( |
- kSuspendTimersWhenBackgroundedDelayMillis); |
- control_task_runner_->PostDelayedTask( |
- FROM_HERE, suspend_timers_when_backgrounded_closure_.callback(), |
- suspend_timers_when_backgrounded_delay); |
} |
void RendererSchedulerImpl::OnRendererForegrounded() { |
@@ -379,10 +366,18 @@ void RendererSchedulerImpl::OnRendererForegrounded() { |
return; |
MainThreadOnly().renderer_backgrounded = false; |
- suspend_timers_when_backgrounded_closure_.Cancel(); |
ResumeTimerQueueWhenForegrounded(); |
} |
+void RendererSchedulerImpl::OnRendererSuspend() { |
+ helper_.CheckOnValidThread(); |
+ if (helper_.IsShutdown() || !MainThreadOnly().renderer_backgrounded) |
+ return; |
+ if (!MainThreadOnly().timer_queue_suspension_when_backgrounded_enabled) |
+ return; |
+ SuspendTimerQueueWhenBackgrounded(); |
+} |
+ |
void RendererSchedulerImpl::EndIdlePeriod() { |
if (MainThreadOnly().in_idle_period_for_testing) |
return; |