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 CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ |
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
11 #include "cc/test/test_now_source.h" | |
12 #include "content/renderer/scheduler/renderer_scheduler.h" | 11 #include "content/renderer/scheduler/renderer_scheduler.h" |
13 #include "content/renderer/scheduler/single_thread_idle_task_runner.h" | 12 #include "content/renderer/scheduler/single_thread_idle_task_runner.h" |
14 #include "content/renderer/scheduler/task_queue_manager.h" | 13 #include "content/renderer/scheduler/task_queue_manager.h" |
15 | 14 |
16 namespace base { | 15 namespace base { |
17 namespace debug { | 16 namespace debug { |
18 class ConvertableToTraceFormat; | 17 class ConvertableToTraceFormat; |
19 } | 18 } |
20 } | 19 } |
21 | 20 |
(...skipping 13 matching lines...) Expand all Loading... |
35 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; | 34 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; |
36 scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() override; | 35 scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() override; |
37 void WillBeginFrame(const cc::BeginFrameArgs& args) override; | 36 void WillBeginFrame(const cc::BeginFrameArgs& args) override; |
38 void DidCommitFrameToCompositor() override; | 37 void DidCommitFrameToCompositor() override; |
39 void DidReceiveInputEventOnCompositorThread( | 38 void DidReceiveInputEventOnCompositorThread( |
40 blink::WebInputEvent::Type type) override; | 39 blink::WebInputEvent::Type type) override; |
41 void DidAnimateForInputOnCompositorThread() override; | 40 void DidAnimateForInputOnCompositorThread() override; |
42 bool ShouldYieldForHighPriorityWork() override; | 41 bool ShouldYieldForHighPriorityWork() override; |
43 void Shutdown() override; | 42 void Shutdown() override; |
44 | 43 |
45 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); | 44 protected: |
| 45 // Virtual for testing. |
| 46 virtual base::TimeTicks Now() const; |
46 | 47 |
47 private: | 48 private: |
48 friend class RendererSchedulerImplTest; | 49 friend class RendererSchedulerImplTest; |
49 | 50 |
50 // Keep RendererSchedulerImpl::TaskQueueIdToString in sync with this enum. | 51 // Keep RendererSchedulerImpl::TaskQueueIdToString in sync with this enum. |
51 enum QueueId { | 52 enum QueueId { |
52 DEFAULT_TASK_QUEUE, | 53 DEFAULT_TASK_QUEUE, |
53 COMPOSITOR_TASK_QUEUE, | 54 COMPOSITOR_TASK_QUEUE, |
54 IDLE_TASK_QUEUE, | 55 IDLE_TASK_QUEUE, |
55 CONTROL_TASK_QUEUE, | 56 CONTROL_TASK_QUEUE, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Updates the scheduler policy. Must be called from the main thread. | 108 // Updates the scheduler policy. Must be called from the main thread. |
108 void UpdatePolicy(); | 109 void UpdatePolicy(); |
109 | 110 |
110 // An input event of some sort happened, the policy may need updating. | 111 // An input event of some sort happened, the policy may need updating. |
111 void UpdateForInputEvent(); | 112 void UpdateForInputEvent(); |
112 | 113 |
113 // Start and end an idle period. | 114 // Start and end an idle period. |
114 void StartIdlePeriod(); | 115 void StartIdlePeriod(); |
115 void EndIdlePeriod(); | 116 void EndIdlePeriod(); |
116 | 117 |
117 base::TimeTicks Now() const; | |
118 | |
119 base::ThreadChecker main_thread_checker_; | 118 base::ThreadChecker main_thread_checker_; |
120 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; | 119 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; |
121 scoped_ptr<TaskQueueManager> task_queue_manager_; | 120 scoped_ptr<TaskQueueManager> task_queue_manager_; |
122 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | 121 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
123 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; | 122 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; |
124 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 123 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
125 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; | 124 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; |
126 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; | 125 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; |
127 | 126 |
128 base::Closure update_policy_closure_; | 127 base::Closure update_policy_closure_; |
129 base::Closure end_idle_period_closure_; | 128 base::Closure end_idle_period_closure_; |
130 | 129 |
131 // Don't access current_policy_ directly, instead use SchedulerPolicy(). | 130 // Don't access current_policy_ directly, instead use SchedulerPolicy(). |
132 Policy current_policy_; | 131 Policy current_policy_; |
133 | 132 |
134 base::TimeTicks estimated_next_frame_begin_; | 133 base::TimeTicks estimated_next_frame_begin_; |
135 | 134 |
136 // The incoming_signals_lock_ mutex protects access to last_input_time_ | 135 // The incoming_signals_lock_ mutex protects access to last_input_time_ |
137 // and write access to policy_may_need_update_. | 136 // and write access to policy_may_need_update_. |
138 base::Lock incoming_signals_lock_; | 137 base::Lock incoming_signals_lock_; |
139 base::TimeTicks last_input_time_; | 138 base::TimeTicks last_input_time_; |
140 PollableNeedsUpdateFlag policy_may_need_update_; | 139 PollableNeedsUpdateFlag policy_may_need_update_; |
141 | 140 |
142 scoped_refptr<cc::TestNowSource> time_source_; | |
143 | |
144 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; | 141 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; |
145 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 142 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
146 | 143 |
147 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 144 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
148 }; | 145 }; |
149 | 146 |
150 } // namespace content | 147 } // namespace content |
151 | 148 |
152 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | 149 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ |
OLD | NEW |