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/WebTaskRunner.h" | 9 #include "public/platform/WebTaskRunner.h" |
10 #include "public/platform/WebThread.h" | 10 #include "public/platform/WebThread.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // make it run later than it normally would, but it won't make it | 50 // make it run later than it normally would, but it won't make it |
51 // run earlier than it normally would. | 51 // run earlier than it normally would. |
52 virtual void postNonNestableIdleTask(const WebTraceLocation&, WebThread::Idl
eTask*) { } | 52 virtual void postNonNestableIdleTask(const WebTraceLocation&, WebThread::Idl
eTask*) { } |
53 | 53 |
54 // 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 |
55 // 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 |
56 // 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. |
57 // Takes ownership of |IdleTask|. Can be called from any thread. | 57 // Takes ownership of |IdleTask|. Can be called from any thread. |
58 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl
eTask*) { } | 58 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl
eTask*) { } |
59 | 59 |
60 // Schedule a loading task to be run on the the associated WebThread. Loadin
g | |
61 // tasks usually have the default priority, but may be deprioritised | |
62 // when the user is interacting with the device. | |
63 // Takes ownership of |WebThread::Task|. Can be called from any thread. | |
64 // TODO(alexclarke): Remove this in favour of loadingTaskRunner(). | |
65 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } | |
66 | |
67 // Schedule a timer task to be run on the the associated WebThread. Timer Ta
sks | |
68 // tasks usually have the default priority, but may be delayed | |
69 // when the user is interacting with the device. | |
70 // Takes ownership of |WebThread::Task|. Can be called from any thread. | |
71 // TODO(alexclarke): Remove this in favour of timerTaskRunner(). | |
72 virtual void postTimerTask(const WebTraceLocation&, WebThread::Task*, long l
ong delayMs) {} | |
73 | |
74 // Schedule a timer task to be run on the the associated WebThread. Timer Ta
sks | 60 // Schedule a timer task to be run on the the associated WebThread. Timer Ta
sks |
75 // tasks usually have the default priority, but may be delayed | 61 // tasks usually have the default priority, but may be delayed |
76 // when the user is interacting with the device. | 62 // when the user is interacting with the device. |
77 // |monotonicTime| is in the timebase of WTF::monotonicallyIncreasingTime(). | 63 // |monotonicTime| is in the timebase of WTF::monotonicallyIncreasingTime(). |
78 // Takes ownership of |WebThread::Task|. Can be called from any thread. | 64 // Takes ownership of |WebTaskRunner::Task|. Can be called from any thread. |
79 virtual void postTimerTaskAt(const WebTraceLocation&, WebThread::Task*, doub
le monotonicTime) {} | 65 // TODO(alexclarke): Move timer throttling for background pages to the |
| 66 // chromium side and remove this. |
| 67 virtual void postTimerTaskAt(const WebTraceLocation&, WebTaskRunner::Task*,
double monotonicTime) {} |
80 | 68 |
81 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. | 69 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. |
82 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } | 70 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } |
83 | 71 |
84 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. | 72 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. |
85 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } | 73 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } |
86 | 74 |
87 // Suspends the timer queue and increments the timer queue suspension count. | 75 // Suspends the timer queue and increments the timer queue suspension count. |
88 // May only be called from the main thread. | 76 // May only be called from the main thread. |
89 virtual void suspendTimerQueue() { } | 77 virtual void suspendTimerQueue() { } |
90 | 78 |
91 // Decrements the timer queue suspension count and re-enables the timer queu
e | 79 // Decrements the timer queue suspension count and re-enables the timer queu
e |
92 // if the suspension count is zero and the current scheduler policy allows i
t. | 80 // if the suspension count is zero and the current scheduler policy allows i
t. |
93 virtual void resumeTimerQueue() { } | 81 virtual void resumeTimerQueue() { } |
94 | 82 |
95 #ifdef INSIDE_BLINK | 83 #ifdef INSIDE_BLINK |
96 // Helpers for posting bound functions as tasks. | 84 // Helpers for posting bound functions as tasks. |
97 typedef Function<void(double deadlineSeconds)> IdleTask; | 85 typedef Function<void(double deadlineSeconds)> IdleTask; |
98 typedef Function<void()> Task; | |
99 | 86 |
100 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 87 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
101 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 88 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
102 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 89 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
103 void postLoadingTask(const WebTraceLocation&, PassOwnPtr<Task>); | |
104 void postTimerTask(const WebTraceLocation&, PassOwnPtr<Task>, long long dela
yMs); | |
105 #endif | 90 #endif |
106 }; | 91 }; |
107 | 92 |
108 } // namespace blink | 93 } // namespace blink |
109 | 94 |
110 #endif // WebScheduler_h | 95 #endif // WebScheduler_h |
OLD | NEW |