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" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
| 14 class WebPageScheduler; |
14 class WebTraceLocation; | 15 class WebTraceLocation; |
15 | 16 |
16 // This class is used to submit tasks and pass other information from Blink to | 17 // This class is used to submit tasks and pass other information from Blink to |
17 // the platform's scheduler. | 18 // the platform's scheduler. |
18 class BLINK_PLATFORM_EXPORT WebScheduler { | 19 class BLINK_PLATFORM_EXPORT WebScheduler { |
19 public: | 20 public: |
20 virtual ~WebScheduler() { } | 21 virtual ~WebScheduler() { } |
21 | 22 |
22 // Called to prevent any more pending tasks from running. Must be called on | 23 // Called to prevent any more pending tasks from running. Must be called on |
23 // the associated WebThread. | 24 // the associated WebThread. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // TODO(alexclarke): Move timer throttling for background pages to the | 66 // TODO(alexclarke): Move timer throttling for background pages to the |
66 // chromium side and remove this. | 67 // chromium side and remove this. |
67 virtual void postTimerTaskAt(const WebTraceLocation&, WebTaskRunner::Task*,
double monotonicTime) {} | 68 virtual void postTimerTaskAt(const WebTraceLocation&, WebTaskRunner::Task*,
double monotonicTime) {} |
68 | 69 |
69 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. | 70 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. |
70 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } | 71 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } |
71 | 72 |
72 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. | 73 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. |
73 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } | 74 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } |
74 | 75 |
| 76 // Creates a new WebPageScheduler. Must be called from the associated WebThr
ead. |
| 77 virtual WebPageScheduler* createPageScheduler() { return nullptr; } |
| 78 |
75 // Suspends the timer queue and increments the timer queue suspension count. | 79 // Suspends the timer queue and increments the timer queue suspension count. |
76 // May only be called from the main thread. | 80 // May only be called from the main thread. |
77 virtual void suspendTimerQueue() { } | 81 virtual void suspendTimerQueue() { } |
78 | 82 |
79 // Decrements the timer queue suspension count and re-enables the timer queu
e | 83 // Decrements the timer queue suspension count and re-enables the timer queu
e |
80 // if the suspension count is zero and the current scheduler policy allows i
t. | 84 // if the suspension count is zero and the current scheduler policy allows i
t. |
81 virtual void resumeTimerQueue() { } | 85 virtual void resumeTimerQueue() { } |
82 | 86 |
83 #ifdef INSIDE_BLINK | 87 #ifdef INSIDE_BLINK |
84 // Helpers for posting bound functions as tasks. | 88 // Helpers for posting bound functions as tasks. |
85 typedef Function<void(double deadlineSeconds)> IdleTask; | 89 typedef Function<void(double deadlineSeconds)> IdleTask; |
86 | 90 |
87 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 91 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
88 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 92 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
89 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 93 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
90 #endif | 94 #endif |
91 }; | 95 }; |
92 | 96 |
93 } // namespace blink | 97 } // namespace blink |
94 | 98 |
95 #endif // WebScheduler_h | 99 #endif // WebScheduler_h |
OLD | NEW |