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..0d8c9e95c3f255287aa1feae717e09137bee17c3 |
--- /dev/null |
+++ b/content/renderer/scheduler/renderer_scheduler.h |
@@ -0,0 +1,104 @@ |
+// 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/synchronization/lock.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: |
+ RendererScheduler(); |
+ ~RendererScheduler(); |
+ |
+ // Returns the default task runner. |
+ scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner(); |
Sami
2014/10/22 13:26:06
These guys could be const, right (now that I fixed
|
+ |
+ // Returns the compositor task runner. |
+ scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner(); |
+ |
+ // Returns the idle task runner. |
+ scoped_refptr<base::SingleThreadTaskRunner> IdleTaskRunner(); |
+ |
+ // Called to notify about the start of a new frame. Must be called from the |
+ // main thread. |
+ void WillBeginFrame(const cc::BeginFrameArgs& args); |
alexclarke
2014/10/22 10:06:37
Perhaps this could post itself onto the kControlTa
Sami
2014/10/22 13:26:06
It should never be called from a different thread
|
+ |
+ // Called to notify that a previously begun frame was committed. Must be |
+ // called from the main thread. |
+ void DidCommitFrameToCompositor(); |
alexclarke
2014/10/22 10:06:37
Likewise perhaps this could post itself onto the k
Sami
2014/10/22 13:26:06
Likewise. I think we should try to limit things to
|
+ |
+ // 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. |
+ // Must be called from the main 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 QueueId { |
+ kDefaultTaskQueue, |
+ kCompositorTaskQueue, |
+ kIdleTaskQueue, |
+ kControlTaskQueue, |
+ // Must be the last entry. |
+ kTaskQueueCount, |
+ }; |
+ |
+ enum Policy { |
+ kNormalPriorityPolicy, |
+ kCompositorPriorityPolicy, |
+ }; |
+ |
+ // The time we should stay in CompositorPriority mode for after a touch event. |
+ static const int kCompositorPriorityAfterTouchMillis = 100; |
+ |
+ // Returns the current scheduler policy. This may involve updating the |
+ // current policy if a new signal has arrived. Must be called from the main |
+ // thread. |
+ Policy SchedulerPolicy(); |
+ |
+ // Updates the scheduler policy. Must be called from the main thread. |
+ void UpdatePolicy(); |
+ |
+ // Start and end an idle period. |
+ void StartIdlePeriod(); |
+ void EndIdlePeriod(); |
+ |
+ base::ThreadChecker main_thread_checker_; |
alexclarke
2014/10/22 10:06:37
It might make sense to add a struct to gather toge
|
+ scoped_ptr<RendererSchedulerSelector> renderer_scheduler_selector_; |
+ base::TaskQueueManager task_queue_manager_; |
+ scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
+ |
+ // Don't access current_policy_ directly, instead use SchedulerPolicy(). |
+ base::subtle::AtomicWord policy_may_need_update_; |
+ Policy current_policy_; |
+ |
+ base::TimeTicks estimated_next_frame_begin_; |
+ |
+ // The incoming_signals_lock_ mutex protects access to last_input_time_. |
+ base::Lock incoming_signals_lock_; |
+ base::TimeTicks last_input_time_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ |