Chromium Code Reviews| Index: Source/platform/scheduler/Scheduler.h |
| diff --git a/Source/platform/scheduler/Scheduler.h b/Source/platform/scheduler/Scheduler.h |
| index 7f7835abcf76d6ac90c6780e6fdad520e3808d80..4095de7a6c376093d5d2a20e1602680d2f9772ef 100644 |
| --- a/Source/platform/scheduler/Scheduler.h |
| +++ b/Source/platform/scheduler/Scheduler.h |
| @@ -23,15 +23,15 @@ class PLATFORM_EXPORT Scheduler { |
| WTF_MAKE_NONCOPYABLE(Scheduler); |
| public: |
| typedef Function<void()> Task; |
| - // An IdleTask is passed an allotted time in CLOCK_MONOTONIC milliseconds and is expected to complete within this timeframe. |
| - typedef Function<void(double allottedTimeMs)> IdleTask; |
| + // An IdleTask is passed a deadline in CLOCK_MONOTONIC seconds and is expected to complete before this deadline. |
| + typedef Function<void(double deadlineSeconds)> IdleTask; |
| static Scheduler* shared(); |
| static void initializeOnMainThread(); |
| static void shutdown(); |
| // Called to notify about the start of a new frame. |
| - void willBeginFrame(const WebBeginFrameArgs&); |
| + void willBeginFrame(double frameDeadlineSeconds); |
| // Called to notify that a previously begun frame was committed. |
| void didCommitFrameToCompositor(); |
| @@ -62,8 +62,10 @@ public: |
| protected: |
| class MainThreadPendingTaskRunner; |
| class MainThreadPendingHighPriorityTaskRunner; |
| + class MainThreadPendingIdleTaskRunner; |
| friend class MainThreadPendingTaskRunner; |
| friend class MainThreadPendingHighPriorityTaskRunner; |
| + friend class TracedIdleTask; |
| enum SchedulerPolicy { |
| Normal, |
| @@ -73,8 +75,8 @@ protected: |
| Scheduler(); |
| virtual ~Scheduler(); |
| - void scheduleIdleTask(const TraceLocation&, const IdleTask&); |
| void postHighPriorityTaskInternal(const TraceLocation&, const Task&, const char* traceName); |
| + void postIdleTaskInternal(const TraceLocation&, const IdleTask&, const char* traceName); |
| static void sharedTimerAdapter(); |
| @@ -83,13 +85,22 @@ protected: |
| // Only does work in CompositorPriority mode. Returns true if any work was done. |
| bool runPendingHighPriorityTasksIfInCompositorPriority(); |
| + // Only does work in CanRunIdleTask and there is a pending idle task. Returns true if any work was done. |
| + bool runPendingIdleTaskIfCanRunIdleTask(); |
|
Sami
2014/10/03 10:39:22
This is a mouthful. How about runPendintIdleTaskIf
rmcilroy
2014/10/03 21:41:21
Made it maybeRunPendingIdleTask on Alex's suggesti
|
| + |
| // Returns true if any work was done. |
| bool swapQueuesAndRunPendingTasks(); |
| void swapQueuesRunPendingTasksAndAllowHighPriorityTaskRunnerPosting(); |
| // Returns true if any work was done. |
| - bool executeHighPriorityTasks(Deque<TracedTask>&); |
| + bool executeHighPriorityTasks(Deque<TracedStandardTask>&); |
| + |
| + // Returns the time in CLOCK_MONOTONIC seconds until the current frame deadline expires. |
| + double currentFrameDeadlineSeconds() const; |
|
Sami
2014/10/03 10:39:21
Please be explicit about which deadline this is ta
rmcilroy
2014/10/03 21:41:21
Done.
|
| + |
| + // Returns true if the scheduler can run idle tasks at this time. |
| + bool canRunIdleTask() const; |
| // Return the current SchedulerPolicy. |
| SchedulerPolicy schedulerPolicy() const; |
| @@ -99,6 +110,9 @@ protected: |
| // Must be called while m_pendingTasksMutex is locked. |
| void maybePostMainThreadPendingHighPriorityTaskRunner(); |
| + // Returns true if an idle task was posted to the main thread for execution. |
| + bool maybePostMainThreadPendingIdleTask(); |
| + |
| void tickSharedTimer(); |
| void (*m_sharedTimerFunction)(); |
| @@ -118,9 +132,13 @@ protected: |
| // This mutex protects calls to the pending task queue, m_highPriorityTaskRunnerPosted and |
| // m_compositorPriorityPolicyEndTimeSeconds. |
| Mutex m_pendingTasksMutex; |
| - DoubleBufferedDeque<TracedTask> m_pendingHighPriorityTasks; |
| + DoubleBufferedDeque<TracedStandardTask> m_pendingHighPriorityTasks; |
| + Deque<TracedIdleTask> m_pendingIdleTasks; |
| double m_compositorPriorityPolicyEndTimeSeconds; |
| + bool m_currentFrameCommitted; |
| + double m_currentFrameDeadlineSeconds; |
| + |
| // Declared volatile as it is atomically incremented. |
| volatile int m_highPriorityTaskCount; |