Index: third_party/WebKit/Source/platform/scheduler/child/idle_helper.h |
diff --git a/third_party/WebKit/Source/platform/scheduler/child/idle_helper.h b/third_party/WebKit/Source/platform/scheduler/child/idle_helper.h |
index 47fc8cfb81f427731438994bfcf62dbd7d931edc..3b174818e4cd818d13d6b3f80389188905190487 100644 |
--- a/third_party/WebKit/Source/platform/scheduler/child/idle_helper.h |
+++ b/third_party/WebKit/Source/platform/scheduler/child/idle_helper.h |
@@ -18,7 +18,26 @@ namespace scheduler { |
class SchedulerHelper; |
-// Common scheduler functionality for Idle tasks. |
+// 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 noting else to do. |
Sami
2016/08/25 15:54:13
typo: nothing
alex clarke (OOO till 29th)
2016/08/26 13:29:08
Done.
|
+// 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 posting DisableIdleTaskQueueTask or |
+// DisableNonNestableIdleTaskQueueTask before enabling the queues. |
+// |
+// 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 more than 50ms when no frames are being |
Sami
2016/08/25 15:54:13
s/more than/up to/
alex clarke (OOO till 29th)
2016/08/26 13:29:08
Done.
|
+// produced. |
+// |
+// Idle tasks are supplied a deadline, and should endeavor to finished before it |
+// ends to avoid jank. |
class BLINK_PLATFORM_EXPORT IdleHelper |
: public base::MessageLoop::TaskObserver, |
public SingleThreadIdleTaskRunner::Delegate { |
@@ -192,6 +211,9 @@ class BLINK_PLATFORM_EXPORT IdleHelper |
base::TimeTicks new_deadline, |
base::TimeTicks optional_now); |
+ void DisableIdleTaskQueueTask(); |
+ void DisableNonNestableIdleTaskQueueTask(); |
+ |
// Returns true if |state| represents being within an idle period state. |
static bool IsInIdlePeriod(IdlePeriodState state); |
// Returns true if |state| represents being within a long idle period state. |
@@ -199,11 +221,20 @@ class BLINK_PLATFORM_EXPORT IdleHelper |
SchedulerHelper* helper_; // NOT OWNED |
Delegate* delegate_; // NOT OWNED |
+ |
+ // We want to ensure idle tasks run in the next idle period. This necessitates |
+ // two idle queues because we do this via posting a task to disable the queue |
+ // and non-nestable tasks execution can be deferred, meaning we end up with |
+ // the situation where we don't want any more nestable tasks to run but the |
+ // non-nestable ones have yet to run. |
scoped_refptr<TaskQueue> idle_queue_; |
+ scoped_refptr<TaskQueue> non_nestable_idle_queue_; |
scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; |
CancelableClosureHolder enable_next_long_idle_period_closure_; |
CancelableClosureHolder on_idle_task_posted_closure_; |
+ CancelableClosureHolder disable_idle_queue_closure_; |
+ CancelableClosureHolder disable_non_nestable_idle_queue_closure_; |
State state_; |