OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ |
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "platform/scheduler/base/cancelable_closure_holder.h" | 10 #include "platform/scheduler/base/cancelable_closure_holder.h" |
11 #include "platform/scheduler/base/task_queue_selector.h" | 11 #include "platform/scheduler/base/task_queue_selector.h" |
12 #include "platform/scheduler/child/scheduler_helper.h" | 12 #include "platform/scheduler/child/scheduler_helper.h" |
13 #include "public/platform/scheduler/child/single_thread_idle_task_runner.h" | 13 #include "public/platform/scheduler/child/single_thread_idle_task_runner.h" |
14 #include "public/platform/WebCommon.h" | 14 #include "public/platform/WebCommon.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 namespace scheduler { | 17 namespace scheduler { |
18 | 18 |
19 class SchedulerHelper; | 19 class SchedulerHelper; |
20 | 20 |
21 // Common scheduler functionality for Idle tasks. | 21 // The job of the IdleHelper is to run idle tasks when the system is otherwise |
| 22 // idle. Idle tasks should be optional work, with no guarantee they will be run |
| 23 // at all. Idle tasks are subject to three levels of throttling: |
| 24 // |
| 25 // 1. Both idle queues are run a BEST_EFFORT priority (i.e. only selected if |
| 26 // there is nothing else to do. |
| 27 // 2. The idle queues are only enabled during an idle period. |
| 28 // 3. Idle tasks posted from within an idle task run in the next idle period. |
| 29 // This is achieved by inserting a fence into the queue. |
| 30 // |
| 31 // There are two types of idle periods: |
| 32 // 1. Short idle period - typically less than 10ms run after begin main frame |
| 33 // has finished, with the idle period ending at the compositor provided |
| 34 // deadline. |
| 35 // 2. Long idle periods - typically up to 50ms when no frames are being |
| 36 // produced. |
| 37 // |
| 38 // Idle tasks are supplied a deadline, and should endeavor to finished before it |
| 39 // ends to avoid jank. |
22 class BLINK_PLATFORM_EXPORT IdleHelper | 40 class BLINK_PLATFORM_EXPORT IdleHelper |
23 : public base::MessageLoop::TaskObserver, | 41 : public base::MessageLoop::TaskObserver, |
24 public SingleThreadIdleTaskRunner::Delegate { | 42 public SingleThreadIdleTaskRunner::Delegate { |
25 public: | 43 public: |
26 // Used to by scheduler implementations to customize idle behaviour. | 44 // Used to by scheduler implementations to customize idle behaviour. |
27 class BLINK_PLATFORM_EXPORT Delegate { | 45 class BLINK_PLATFORM_EXPORT Delegate { |
28 public: | 46 public: |
29 Delegate(); | 47 Delegate(); |
30 virtual ~Delegate(); | 48 virtual ~Delegate(); |
31 | 49 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 base::WeakPtr<IdleHelper> weak_idle_helper_ptr_; | 232 base::WeakPtr<IdleHelper> weak_idle_helper_ptr_; |
215 base::WeakPtrFactory<IdleHelper> weak_factory_; | 233 base::WeakPtrFactory<IdleHelper> weak_factory_; |
216 | 234 |
217 DISALLOW_COPY_AND_ASSIGN(IdleHelper); | 235 DISALLOW_COPY_AND_ASSIGN(IdleHelper); |
218 }; | 236 }; |
219 | 237 |
220 } // namespace scheduler | 238 } // namespace scheduler |
221 } // namespace blink | 239 } // namespace blink |
222 | 240 |
223 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ | 241 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_CHILD_IDLE_HELPER_H_ |
OLD | NEW |