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

Unified Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 1895773002: Move responsiblity of tab suspending from renderer to TabManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix time Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698