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 "WebString.h" |
9 #include "public/platform/WebTaskRunner.h" | 10 #include "public/platform/WebTaskRunner.h" |
10 #include "public/platform/WebThread.h" | 11 #include "public/platform/WebThread.h" |
11 #include "public/platform/WebTraceLocation.h" | 12 #include "public/platform/WebTraceLocation.h" |
12 #include "public/platform/WebViewScheduler.h" | 13 #include "public/platform/WebViewScheduler.h" |
13 | 14 |
14 #include <memory> | 15 #include <memory> |
15 | 16 |
16 namespace blink { | 17 namespace blink { |
17 | 18 |
18 class WebView; | 19 class WebView; |
19 | 20 |
20 // This class is used to submit tasks and pass other information from Blink to | 21 // This class is used to submit tasks and pass other information from Blink to |
21 // the platform's scheduler. | 22 // the platform's scheduler. |
| 23 // TODO(skyostil): Replace this class with RendererScheduler. |
22 class BLINK_PLATFORM_EXPORT WebScheduler { | 24 class BLINK_PLATFORM_EXPORT WebScheduler { |
23 public: | 25 public: |
| 26 class BLINK_PLATFORM_EXPORT InterventionReporter { |
| 27 public: |
| 28 virtual ~InterventionReporter() {} |
| 29 |
| 30 // The scheduler has performed an intervention, described by |message|, |
| 31 // which should be reported to the developer. |
| 32 virtual void ReportIntervention(const WebString& message) = 0; |
| 33 }; |
| 34 |
24 virtual ~WebScheduler() { } | 35 virtual ~WebScheduler() { } |
25 | 36 |
26 // Called to prevent any more pending tasks from running. Must be called on | 37 // Called to prevent any more pending tasks from running. Must be called on |
27 // the associated WebThread. | 38 // the associated WebThread. |
28 virtual void shutdown() = 0; | 39 virtual void shutdown() = 0; |
29 | 40 |
30 // Returns true if there is high priority work pending on the associated Web
Thread | 41 // Returns true if there is high priority work pending on the associated Web
Thread |
31 // and the caller should yield to let the scheduler service that work. | 42 // and the caller should yield to let the scheduler service that work. |
32 // Must be called on the associated WebThread. | 43 // Must be called on the associated WebThread. |
33 virtual bool shouldYieldForHighPriorityWork() = 0; | 44 virtual bool shouldYieldForHighPriorityWork() = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
62 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl
eTask*) = 0; | 73 virtual void postIdleTaskAfterWakeup(const WebTraceLocation&, WebThread::Idl
eTask*) = 0; |
63 | 74 |
64 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. | 75 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. |
65 virtual WebTaskRunner* loadingTaskRunner() = 0; | 76 virtual WebTaskRunner* loadingTaskRunner() = 0; |
66 | 77 |
67 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. | 78 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. |
68 virtual WebTaskRunner* timerTaskRunner() = 0; | 79 virtual WebTaskRunner* timerTaskRunner() = 0; |
69 | 80 |
70 // Creates a new WebViewScheduler for a given WebView. Must be called from | 81 // Creates a new WebViewScheduler for a given WebView. Must be called from |
71 // the associated WebThread. | 82 // the associated WebThread. |
72 virtual std::unique_ptr<WebViewScheduler> createWebViewScheduler(blink::WebV
iew*) = 0; | 83 virtual std::unique_ptr<WebViewScheduler> createWebViewScheduler(Interventio
nReporter*) = 0; |
73 | 84 |
74 // Suspends the timer queue and increments the timer queue suspension count. | 85 // Suspends the timer queue and increments the timer queue suspension count. |
75 // May only be called from the main thread. | 86 // May only be called from the main thread. |
76 virtual void suspendTimerQueue() = 0; | 87 virtual void suspendTimerQueue() = 0; |
77 | 88 |
78 // Decrements the timer queue suspension count and re-enables the timer queu
e | 89 // Decrements the timer queue suspension count and re-enables the timer queu
e |
79 // if the suspension count is zero and the current scheduler policy allows i
t. | 90 // if the suspension count is zero and the current scheduler policy allows i
t. |
80 virtual void resumeTimerQueue() = 0; | 91 virtual void resumeTimerQueue() = 0; |
81 | 92 |
82 enum class NavigatingFrameType { | 93 enum class NavigatingFrameType { |
(...skipping 17 matching lines...) Expand all Loading... |
100 | 111 |
101 void postIdleTask(const WebTraceLocation&, std::unique_ptr<IdleTask>); | 112 void postIdleTask(const WebTraceLocation&, std::unique_ptr<IdleTask>); |
102 void postNonNestableIdleTask(const WebTraceLocation&, std::unique_ptr<IdleTa
sk>); | 113 void postNonNestableIdleTask(const WebTraceLocation&, std::unique_ptr<IdleTa
sk>); |
103 void postIdleTaskAfterWakeup(const WebTraceLocation&, std::unique_ptr<IdleTa
sk>); | 114 void postIdleTaskAfterWakeup(const WebTraceLocation&, std::unique_ptr<IdleTa
sk>); |
104 #endif | 115 #endif |
105 }; | 116 }; |
106 | 117 |
107 } // namespace blink | 118 } // namespace blink |
108 | 119 |
109 #endif // WebScheduler_h | 120 #endif // WebScheduler_h |
OLD | NEW |