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

Side by Side Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 1914143002: Experimental 'purging and suspending' backgrounded tabs behind the flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on haraken's review Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/scheduler/renderer/renderer_scheduler_impl.h" 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/stack_trace.h" 8 #include "base/debug/stack_trace.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 "RendererSchedulerImpl::OnRendererForegrounded"); 380 "RendererSchedulerImpl::OnRendererForegrounded");
381 helper_.CheckOnValidThread(); 381 helper_.CheckOnValidThread();
382 if (helper_.IsShutdown() || !MainThreadOnly().renderer_backgrounded) 382 if (helper_.IsShutdown() || !MainThreadOnly().renderer_backgrounded)
383 return; 383 return;
384 384
385 MainThreadOnly().renderer_backgrounded = false; 385 MainThreadOnly().renderer_backgrounded = false;
386 suspend_timers_when_backgrounded_closure_.Cancel(); 386 suspend_timers_when_backgrounded_closure_.Cancel();
387 ResumeTimerQueueWhenForegrounded(); 387 ResumeTimerQueueWhenForegrounded();
388 } 388 }
389 389
390 void RendererSchedulerImpl::SuspendRenderer() {
391 helper_.CheckOnValidThread();
392 DCHECK(MainThreadOnly().renderer_backgrounded);
393 if (helper_.IsShutdown())
394 return;
395 suspend_timers_when_backgrounded_closure_.Cancel();
396 // TODO(hajimehoshi): We might need to suspend not only timer queue but also
397 // e.g. loading tasks or postMessage.
398 SuspendTimerQueueWhenBackgrounded();
399 }
400
390 void RendererSchedulerImpl::EndIdlePeriod() { 401 void RendererSchedulerImpl::EndIdlePeriod() {
391 if (MainThreadOnly().in_idle_period_for_testing) 402 if (MainThreadOnly().in_idle_period_for_testing)
392 return; 403 return;
393 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 404 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
394 "RendererSchedulerImpl::EndIdlePeriod"); 405 "RendererSchedulerImpl::EndIdlePeriod");
395 helper_.CheckOnValidThread(); 406 helper_.CheckOnValidThread();
396 idle_helper_.EndIdlePeriod(); 407 idle_helper_.EndIdlePeriod();
397 } 408 }
398 409
399 void RendererSchedulerImpl::EndIdlePeriodForTesting( 410 void RendererSchedulerImpl::EndIdlePeriodForTesting(
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1279 }
1269 MainThreadOnly().have_reported_blocking_intervention_since_navigation = 1280 MainThreadOnly().have_reported_blocking_intervention_since_navigation =
1270 true; 1281 true;
1271 BroadcastConsoleWarning( 1282 BroadcastConsoleWarning(
1272 "Deferred long-running timer task(s) to improve scrolling smoothness. " 1283 "Deferred long-running timer task(s) to improve scrolling smoothness. "
1273 "See crbug.com/574343."); 1284 "See crbug.com/574343.");
1274 } 1285 }
1275 } 1286 }
1276 1287
1277 } // namespace scheduler 1288 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698