// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_IDLE_HELPER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_IDLE_HELPER_H_ #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/task/task_observer.h" #include "base/time/time.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/scheduler/common/cancelable_closure_holder.h" #include "third_party/blink/renderer/platform/scheduler/common/scheduler_helper.h" #include "third_party/blink/renderer/platform/scheduler/common/single_thread_idle_task_runner.h" namespace blink { namespace scheduler { namespace idle_helper_unittest { class BaseIdleHelperTest; class IdleHelperTest; } // namespace idle_helper_unittest class SchedulerHelper; // The job of the IdleHelper is to run idle tasks when the system is otherwise // idle. Idle tasks should be optional work, with no guarantee they will be run // at all. Idle tasks are subject to three levels of throttling: // // 1. Both idle queues are run a BEST_EFFORT priority (i.e. only selected if // there is nothing else to do. // 2. The idle queues are only enabled during an idle period. // 3. Idle tasks posted from within an idle task run in the next idle period. // This is achieved by inserting a fence into the queue. // // There are two types of idle periods: // 1. Short idle period - typically less than 10ms run after begin main frame // has finished, with the idle period ending at the compositor provided // deadline. // 2. Long idle periods - typically up to 50ms when no frames are being // produced. // // Idle tasks are supplied a deadline, and should endeavor to finished before it // ends to avoid jank. class PLATFORM_EXPORT IdleHelper : public base::TaskObserver, public SingleThreadIdleTaskRunner::Delegate { … }; } // namespace scheduler } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_COMMON_IDLE_HELPER_H_