Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | |
| 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | |
| 7 | |
| 8 #include "base/atomicops.h" | |
| 9 #include "base/synchronization/lock.h" | |
| 10 #include "base/task/task_queue_manager.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 struct BeginFrameArgs; | |
| 15 } | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class RendererSchedulerSelector; | |
| 20 | |
| 21 class RendererScheduler { | |
| 22 public: | |
| 23 RendererScheduler(); | |
| 24 ~RendererScheduler(); | |
| 25 | |
| 26 // Returns the default task runner. | |
| 27 scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner(); | |
|
Sami
2014/10/22 13:26:06
These guys could be const, right (now that I fixed
| |
| 28 | |
| 29 // Returns the compositor task runner. | |
| 30 scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner(); | |
| 31 | |
| 32 // Returns the idle task runner. | |
| 33 scoped_refptr<base::SingleThreadTaskRunner> IdleTaskRunner(); | |
| 34 | |
| 35 // Called to notify about the start of a new frame. Must be called from the | |
| 36 // main thread. | |
| 37 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
| |
| 38 | |
| 39 // Called to notify that a previously begun frame was committed. Must be | |
| 40 // called from the main thread. | |
| 41 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
| |
| 42 | |
| 43 // Tells the scheduler that the system received an input event. Can be called | |
| 44 // on any thread. | |
| 45 void DidReceiveInputEvent(); | |
| 46 | |
| 47 // Returns true if there is high priority work pending on the main thread | |
| 48 // and the caller should yield to let the scheduler service that work. | |
| 49 // Must be called from the main thread. | |
| 50 bool ShouldYieldForHighPriorityWork(); | |
| 51 | |
| 52 // Returns the deadline by which an idle task should finish by for the | |
| 53 // current frame. Must be called from the main thread. | |
| 54 base::TimeTicks CurrentFrameDeadlineForIdleTasks() const; | |
| 55 | |
| 56 private: | |
| 57 enum QueueId { | |
| 58 kDefaultTaskQueue, | |
| 59 kCompositorTaskQueue, | |
| 60 kIdleTaskQueue, | |
| 61 kControlTaskQueue, | |
| 62 // Must be the last entry. | |
| 63 kTaskQueueCount, | |
| 64 }; | |
| 65 | |
| 66 enum Policy { | |
| 67 kNormalPriorityPolicy, | |
| 68 kCompositorPriorityPolicy, | |
| 69 }; | |
| 70 | |
| 71 // The time we should stay in CompositorPriority mode for after a touch event. | |
| 72 static const int kCompositorPriorityAfterTouchMillis = 100; | |
| 73 | |
| 74 // Returns the current scheduler policy. This may involve updating the | |
| 75 // current policy if a new signal has arrived. Must be called from the main | |
| 76 // thread. | |
| 77 Policy SchedulerPolicy(); | |
| 78 | |
| 79 // Updates the scheduler policy. Must be called from the main thread. | |
| 80 void UpdatePolicy(); | |
| 81 | |
| 82 // Start and end an idle period. | |
| 83 void StartIdlePeriod(); | |
| 84 void EndIdlePeriod(); | |
| 85 | |
| 86 base::ThreadChecker main_thread_checker_; | |
|
alexclarke
2014/10/22 10:06:37
It might make sense to add a struct to gather toge
| |
| 87 scoped_ptr<RendererSchedulerSelector> renderer_scheduler_selector_; | |
| 88 base::TaskQueueManager task_queue_manager_; | |
| 89 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | |
| 90 | |
| 91 // Don't access current_policy_ directly, instead use SchedulerPolicy(). | |
| 92 base::subtle::AtomicWord policy_may_need_update_; | |
| 93 Policy current_policy_; | |
| 94 | |
| 95 base::TimeTicks estimated_next_frame_begin_; | |
| 96 | |
| 97 // The incoming_signals_lock_ mutex protects access to last_input_time_. | |
| 98 base::Lock incoming_signals_lock_; | |
| 99 base::TimeTicks last_input_time_; | |
| 100 }; | |
| 101 | |
| 102 } // namespace content | |
| 103 | |
| 104 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_H_ | |
| OLD | NEW |