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 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class WebTraceLocation; | 13 class WebTraceLocation; |
14 | 14 |
15 // This class is used to submit tasks and pass other information from Blink to | 15 // This class is used to submit tasks and pass other information from Blink to |
16 // the platform's scheduler. | 16 // the platform's scheduler. |
17 class BLINK_PLATFORM_EXPORT WebScheduler { | 17 class BLINK_PLATFORM_EXPORT WebScheduler { |
18 public: | 18 public: |
19 virtual ~WebScheduler() { } | 19 virtual ~WebScheduler() { } |
20 | 20 |
21 // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is | 21 // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is |
22 // expected to complete before this deadline. | 22 // expected to complete before this deadline. |
23 class IdleTask { | 23 class IdleTask { |
24 public: | 24 public: |
25 virtual ~IdleTask() { } | 25 virtual ~IdleTask() { } |
26 virtual void run(double deadlineSeconds) = 0; | 26 virtual void run(double deadlineSeconds) = 0; |
27 }; | 27 }; |
28 | 28 |
29 // Called during Blink's shutdown to delete any pending tasks from the | |
30 // scheduler. Must be called on the main thread. | |
31 virtual void shutdown() { } | |
32 | |
33 // Returns true if there is high priority work pending on the main thread | 29 // 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. | 30 // and the caller should yield to let the scheduler service that work. |
35 // Must be called on the main thread. | 31 // Must be called on the main thread. |
36 virtual bool shouldYieldForHighPriorityWork() { return false; } | 32 virtual bool shouldYieldForHighPriorityWork() { return false; } |
37 | 33 |
38 // Schedule an idle task to run the Blink main thread. For non-critical | 34 // 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 | 35 // 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. | 36 // starved for an arbitrarily long time if no idle time is available. |
41 // Takes ownership of |IdleTask|. Can be called from any thread. | 37 // Takes ownership of |IdleTask|. Can be called from any thread. |
42 virtual void postIdleTask(const WebTraceLocation&, IdleTask*) { } | 38 virtual void postIdleTask(const WebTraceLocation&, IdleTask*) { } |
(...skipping 14 matching lines...) Expand all Loading... |
57 // Schedule a loading task to be run on the Blink main thread. Loading | 53 // Schedule a loading task to be run on the Blink main thread. Loading |
58 // tasks usually have the default priority, but may be deprioritised | 54 // tasks usually have the default priority, but may be deprioritised |
59 // when the user is interacting with the device. | 55 // when the user is interacting with the device. |
60 // Takes ownership of |WebThread::Task|. Can be called from any thread. | 56 // Takes ownership of |WebThread::Task|. Can be called from any thread. |
61 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } | 57 virtual void postLoadingTask(const WebTraceLocation&, WebThread::Task*) { } |
62 }; | 58 }; |
63 | 59 |
64 } // namespace blink | 60 } // namespace blink |
65 | 61 |
66 #endif // WebScheduler_h | 62 #endif // WebScheduler_h |
OLD | NEW |