| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // |monotonicTime| is in the timebase of WTF::monotonicallyIncreasingTime(). | 78 // |monotonicTime| is in the timebase of WTF::monotonicallyIncreasingTime(). |
| 78 // Takes ownership of |WebThread::Task|. Can be called from any thread. | 79 // Takes ownership of |WebThread::Task|. Can be called from any thread. |
| 79 virtual void postTimerTaskAt(const WebTraceLocation&, WebThread::Task*, doub
le monotonicTime) {} | 80 virtual void postTimerTaskAt(const WebTraceLocation&, WebThread::Task*, doub
le monotonicTime) {} |
| 80 | 81 |
| 81 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. | 82 // Returns a WebTaskRunner for loading tasks. Can be called from any thread. |
| 82 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } | 83 virtual WebTaskRunner* loadingTaskRunner() { return nullptr; } |
| 83 | 84 |
| 84 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. | 85 // Returns a WebTaskRunner for timer tasks. Can be called from any thread. |
| 85 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } | 86 virtual WebTaskRunner* timerTaskRunner() { return nullptr; } |
| 86 | 87 |
| 88 // Creates a new WebPageScheduler. Must be called from the associated WebThr
ead. |
| 89 virtual WebPageScheduler* createPageScheduler() { return nullptr; } |
| 90 |
| 87 // Suspends the timer queue and increments the timer queue suspension count. | 91 // Suspends the timer queue and increments the timer queue suspension count. |
| 88 // May only be called from the main thread. | 92 // May only be called from the main thread. |
| 89 virtual void suspendTimerQueue() { } | 93 virtual void suspendTimerQueue() { } |
| 90 | 94 |
| 91 // Decrements the timer queue suspension count and re-enables the timer queu
e | 95 // 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. | 96 // if the suspension count is zero and the current scheduler policy allows i
t. |
| 93 virtual void resumeTimerQueue() { } | 97 virtual void resumeTimerQueue() { } |
| 94 | 98 |
| 95 #ifdef INSIDE_BLINK | 99 #ifdef INSIDE_BLINK |
| 96 // Helpers for posting bound functions as tasks. | 100 // Helpers for posting bound functions as tasks. |
| 97 typedef Function<void(double deadlineSeconds)> IdleTask; | 101 typedef Function<void(double deadlineSeconds)> IdleTask; |
| 98 typedef Function<void()> Task; | 102 typedef Function<void()> Task; |
| 99 | 103 |
| 100 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 104 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
| 101 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 105 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
| 102 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 106 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
| 103 void postLoadingTask(const WebTraceLocation&, PassOwnPtr<Task>); | 107 void postLoadingTask(const WebTraceLocation&, PassOwnPtr<Task>); |
| 104 void postTimerTask(const WebTraceLocation&, PassOwnPtr<Task>, long long dela
yMs); | 108 void postTimerTask(const WebTraceLocation&, PassOwnPtr<Task>, long long dela
yMs); |
| 105 #endif | 109 #endif |
| 106 }; | 110 }; |
| 107 | 111 |
| 108 } // namespace blink | 112 } // namespace blink |
| 109 | 113 |
| 110 #endif // WebScheduler_h | 114 #endif // WebScheduler_h |
| OLD | NEW |