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

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

Issue 2017763003: Suspend more task queues for background renderers (experimental) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 6 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 6a23ea568fc82c49671edafe6334072688a485c8..b9e74d0dd11f45af3ed343fa829aa9f3fecf1137 100644
--- a/components/scheduler/renderer/renderer_scheduler_impl.cc
+++ b/components/scheduler/renderer/renderer_scheduler_impl.cc
@@ -119,6 +119,7 @@ RendererSchedulerImpl::MainThreadOnly::MainThreadOnly(
expensive_task_policy(ExpensiveTaskPolicy::RUN),
renderer_hidden(false),
renderer_backgrounded(false),
+ renderer_suspended(false),
timer_queue_suspension_when_backgrounded_enabled(false),
timer_queue_suspended_when_backgrounded(false),
was_shutdown(false),
@@ -392,6 +393,7 @@ void RendererSchedulerImpl::OnRendererForegrounded() {
return;
MainThreadOnly().renderer_backgrounded = false;
+ MainThreadOnly().renderer_suspended = false;
suspend_timers_when_backgrounded_closure_.Cancel();
ResumeTimerQueueWhenForegrounded();
}
@@ -404,6 +406,7 @@ void RendererSchedulerImpl::SuspendRenderer() {
suspend_timers_when_backgrounded_closure_.Cancel();
// TODO(hajimehoshi): We might need to suspend not only timer queue but also
// e.g. loading tasks or postMessage.
+ MainThreadOnly().renderer_suspended = true;
SuspendTimerQueueWhenBackgrounded();
}
@@ -841,6 +844,11 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) {
new_policy.timer_queue_policy.time_domain_type = TimeDomainType::REAL;
}
+ if (MainThreadOnly().renderer_suspended) {
+ new_policy.loading_queue_policy.is_enabled = false;
+ DCHECK(!new_policy.timer_queue_policy.is_enabled);
+ }
+
// Tracing is done before the early out check, because it's quite possible we
// will otherwise miss this information in traces.
TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(

Powered by Google App Engine
This is Rietveld 408576698