OLD | NEW |
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 #ifndef WebScheduler_h | 5 #ifndef WebScheduler_h |
6 #define WebScheduler_h | 6 #define WebScheduler_h |
7 | 7 |
8 #include "WebCommon.h" | 8 #include "WebCommon.h" |
9 #include "public/platform/WebThread.h" | 9 #include "public/platform/WebThread.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // Called during Blink's shutdown to delete any pending tasks from the | 29 // Called during Blink's shutdown to delete any pending tasks from the |
30 // scheduler. Must be called on the main thread. | 30 // scheduler. Must be called on the main thread. |
31 virtual void shutdown() { } | 31 virtual void shutdown() { } |
32 | 32 |
33 // Returns true if there is high priority work pending on the main thread | 33 // Returns true if there is high priority work pending on the main thread |
34 // and the caller should yield to let the scheduler service that work. | 34 // and the caller should yield to let the scheduler service that work. |
35 // Must be called on the main thread. | 35 // Must be called on the main thread. |
36 virtual bool shouldYieldForHighPriorityWork() { return false; } | 36 virtual bool shouldYieldForHighPriorityWork() { return false; } |
37 | 37 |
| 38 // Returns true if a currently running idle task could exceed its deadline |
| 39 // without impacting user experience too much. This should only be used if |
| 40 // there is a task which cannot be pre-empted and is likely to take longer |
| 41 // than the largest expected idle task deadline. It should NOT be polled to |
| 42 // check whether more work can be performed on the current idle task after |
| 43 // its deadline has expired - post a new idle task for the continuation of |
| 44 // the work in this case. |
| 45 // Must be called from the main thread. |
| 46 virtual bool canExceedIdleDeadlineIfRequired() { return false; } |
| 47 |
38 // Schedule an idle task to run the Blink main thread. For non-critical | 48 // Schedule an idle task to run the Blink main thread. For non-critical |
39 // tasks which may be reordered relative to other task types and may be | 49 // tasks which may be reordered relative to other task types and may be |
40 // starved for an arbitrarily long time if no idle time is available. | 50 // starved for an arbitrarily long time if no idle time is available. |
41 // Takes ownership of |IdleTask|. Can be called from any thread. | 51 // Takes ownership of |IdleTask|. Can be called from any thread. |
42 virtual void postIdleTask(const WebTraceLocation&, IdleTask*) { } | 52 virtual void postIdleTask(const WebTraceLocation&, IdleTask*) { } |
43 | 53 |
44 // Like postIdleTask but does not run the idle task until after some other | 54 // Like postIdleTask but does not run the idle task until after some other |
45 // task has run. This enables posting of a task which won't stop the Blink | 55 // task has run. This enables posting of a task which won't stop the Blink |
46 // main thread from sleeping, but will start running after it wakes up. | 56 // main thread from sleeping, but will start running after it wakes up. |
47 // Takes ownership of |IdleTask|. Can be called from any thread. | 57 // Takes ownership of |IdleTask|. Can be called from any thread. |
48 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, IdleTask*) { } | 58 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, IdleTask*) { } |
49 | 59 |
50 // Schedule a loading task to be run on the Blink main thread. Loading | 60 // Schedule a loading task to be run on the Blink main thread. Loading |
51 // tasks usually have the default priority, but may be deprioritised | 61 // tasks usually have the default priority, but may be deprioritised |
52 // when the user is interacting with the device. | 62 // when the user is interacting with the device. |
53 // Takes ownership of |WebThread::Task|. Can be called from any thread. | 63 // Takes ownership of |WebThread::Task|. Can be called from any thread. |
54 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } | 64 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } |
55 }; | 65 }; |
56 | 66 |
57 } // namespace blink | 67 } // namespace blink |
58 | 68 |
59 #endif // WebScheduler_h | 69 #endif // WebScheduler_h |
OLD | NEW |