| 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 Scheduler_h | 5 #ifndef Scheduler_h |
| 6 #define Scheduler_h | 6 #define Scheduler_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "public/platform/WebThread.h" | 9 #include "public/platform/WebThread.h" |
| 10 #include "wtf/Functional.h" | 10 #include "wtf/Functional.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 typedef Function<void(double deadlineSeconds)> IdleTask; | 24 typedef Function<void(double deadlineSeconds)> IdleTask; |
| 25 | 25 |
| 26 static Scheduler* shared(); | 26 static Scheduler* shared(); |
| 27 static void setForTesting(Scheduler*); | 27 static void setForTesting(Scheduler*); |
| 28 static void shutdown(); | 28 static void shutdown(); |
| 29 | 29 |
| 30 // For non-critical tasks which may be reordered relative to other task type
s and may be starved | 30 // For non-critical tasks which may be reordered relative to other task type
s and may be starved |
| 31 // for an arbitrarily long time if no idle time is available. | 31 // for an arbitrarily long time if no idle time is available. |
| 32 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 32 void postIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
| 33 | 33 |
| 34 // Like postIdleTask but guarantees that the posted task will not run |
| 35 // nested within an already-running task. Posting an idle task as |
| 36 // non-nestable may not affect when the task gets run, or it could |
| 37 // make it run later than it normally would, but it won't make it |
| 38 // run earlier than it normally would. |
| 39 void postNonNestableIdleTask(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
| 40 |
| 34 // Like postIdleTask but does not run the idle task until after some other | 41 // Like postIdleTask but does not run the idle task until after some other |
| 35 // task has run. This enables posting of a task which won't stop the Blink | 42 // task has run. This enables posting of a task which won't stop the Blink |
| 36 // main thread from sleeping, but will start running after it wakes up. | 43 // main thread from sleeping, but will start running after it wakes up. |
| 37 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); | 44 void postIdleTaskAfterWakeup(const WebTraceLocation&, PassOwnPtr<IdleTask>); |
| 38 | 45 |
| 39 // For tasks related to loading, e.g. HTML parsing. Loading tasks usually h
ave default priority | 46 // For tasks related to loading, e.g. HTML parsing. Loading tasks usually h
ave default priority |
| 40 // but they may be deprioritized when the user is interacting with the devic
e. | 47 // but they may be deprioritized when the user is interacting with the devic
e. |
| 41 // Takes ownership of |WebThread::Task|. | 48 // Takes ownership of |WebThread::Task|. |
| 42 void postLoadingTask(const WebTraceLocation&, WebThread::Task*); | 49 void postLoadingTask(const WebTraceLocation&, WebThread::Task*); |
| 43 | 50 |
| 44 // Returns true if there is high priority work pending on the main thread | 51 // Returns true if there is high priority work pending on the main thread |
| 45 // and the caller should yield to let the scheduler service that work. | 52 // and the caller should yield to let the scheduler service that work. |
| 46 // Must be called on the main thread. | 53 // Must be called on the main thread. |
| 47 bool shouldYieldForHighPriorityWork() const; | 54 bool shouldYieldForHighPriorityWork() const; |
| 48 | 55 |
| 49 protected: | 56 protected: |
| 50 Scheduler(WebScheduler*); | 57 Scheduler(WebScheduler*); |
| 51 virtual ~Scheduler(); | 58 virtual ~Scheduler(); |
| 52 | 59 |
| 53 static Scheduler* s_sharedScheduler; | 60 static Scheduler* s_sharedScheduler; |
| 54 WebScheduler* m_webScheduler; | 61 WebScheduler* m_webScheduler; |
| 55 }; | 62 }; |
| 56 | 63 |
| 57 } // namespace blink | 64 } // namespace blink |
| 58 | 65 |
| 59 #endif // Scheduler_h | 66 #endif // Scheduler_h |
| OLD | NEW |