Index: content/renderer/scheduler/renderer_scheduler.h |
diff --git a/content/renderer/scheduler/renderer_scheduler.h b/content/renderer/scheduler/renderer_scheduler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..68e5c4586162aa906362eb597cd44bb03c94fab0 |
--- /dev/null |
+++ b/content/renderer/scheduler/renderer_scheduler.h |
@@ -0,0 +1,94 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ |
+#define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ |
+ |
+#include "base/atomicops.h" |
+#include "base/task/task_queue_manager.h" |
+#include "base/threading/thread_checker.h" |
+ |
+namespace cc { |
+struct BeginFrameArgs; |
+} |
+ |
+namespace content { |
+ |
+class RendererSchedulerSelector; |
+ |
+class RendererScheduler { |
+ public: |
+ enum QueueId { |
+ kDefaultTaskQueue, |
+ kCompositorTaskQueue, |
+ kIdleTaskQueue, |
+ // Must be the last entry. |
+ kTaskQueueCount, |
Sami
2014/10/20 13:31:08
Strange to have the count here since we have +1 qu
rmcilroy
2014/10/21 17:21:27
Good point, went with accessors.
|
+ }; |
+ |
+ RendererScheduler(); |
+ ~RendererScheduler(); |
+ |
+ // Returns the task runner which targets the queue selected by |queue_index|. |
Sami
2014/10/20 13:31:08
|queue|.
rmcilroy
2014/10/21 17:21:27
Done.
|
+ scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue(QueueId queue); |
+ |
+ // Called to notify about the start of a new frame. Must be called from the |
+ // main thread. |
+ void WillBeginFrame(const cc::BeginFrameArgs& args); |
+ |
+ // Called to notify that a previously begun frame was committed. Must be |
+ // called from the main thread. |
+ void DidCommitFrameToCompositor(); |
+ |
+ // Tells the scheduler that the system received an input event. Can be called |
+ // on any thread. |
+ void DidReceiveInputEvent(); |
+ |
+ // Returns true if there is high priority work pending on the main thread |
+ // and the caller should yield to let the scheduler service that work. |
+ // Can be called on any thread. |
+ bool ShouldYieldForHighPriorityWork(); |
+ |
+ // Returns the deadline by which an idle task should finish by for the |
+ // current frame. Must be called from the main thread. |
+ base::TimeTicks CurrentFrameDeadlineForIdleTasks() const; |
+ |
+ private: |
+ enum Policy { |
+ kNormalPriorityPolicy, |
+ kCompositorPriorityPolicy, |
+ }; |
+ |
+ size_t kControlQueue = kTaskQueueCount; |
+ size_t kTaskAndControlQueueCount = kControlQueue + 1; |
+ |
+ // The time we should stay in CompositorPriority mode for after a touch event. |
+ base::TimeDelta kCompositoryPriorityAfterTouchTime = |
Sami
2014/10/20 13:31:08
static const? Needs to be a POD number in that cas
rmcilroy
2014/10/21 17:21:27
Done.
|
+ base::TimeDelta::FromMilliseconds(100); |
+ |
+ // Returns the current scheduler policy. Can be called on any thread. |
+ Policy SchedulerPolicy() const; |
+ |
+ // Enters the scheduler policy. Must be called from the main thread. |
+ void EnterSchedulerPolicy(Policy policy); |
+ |
+ // Start and end an idle period. |
+ void StartIdlePeriod(); |
+ void EndIdlePeriod(); |
+ |
+ base::ThreadChecker main_thread_checker_; |
+ scoped_ptr<RendererSchedulerSelector> renderer_scheduler_selector_; |
+ base::TaskQueueManager task_queue_manager_; |
+ scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
+ |
+ // Don't access scheduler_policy_ directly, use EnterSchedulerPolicy |
+ // and SchedulerPolicy instead. |
+ base::subtle::AtomicWord current_policy_; |
+ |
+ base::TimeTicks estimated_next_frame_begin_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ |