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" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() override; | 34 scoped_refptr<base::SingleThreadTaskRunner> DefaultTaskRunner() override; |
35 scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner() override; | 35 scoped_refptr<base::SingleThreadTaskRunner> CompositorTaskRunner() override; |
36 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; | 36 scoped_refptr<SingleThreadIdleTaskRunner> IdleTaskRunner() override; |
37 scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() override; | 37 scoped_refptr<base::SingleThreadTaskRunner> LoadingTaskRunner() override; |
38 void WillBeginFrame(const cc::BeginFrameArgs& args) override; | 38 void WillBeginFrame(const cc::BeginFrameArgs& args) override; |
39 void BeginFrameNotExpectedSoon() override; | 39 void BeginFrameNotExpectedSoon() override; |
40 void DidCommitFrameToCompositor() override; | 40 void DidCommitFrameToCompositor() override; |
41 void DidReceiveInputEventOnCompositorThread( | 41 void DidReceiveInputEventOnCompositorThread( |
42 const blink::WebInputEvent& web_input_event) override; | 42 const blink::WebInputEvent& web_input_event) override; |
43 void DidAnimateForInputOnCompositorThread() override; | 43 void DidAnimateForInputOnCompositorThread() override; |
44 bool CanExceedIdleDeadlineIfRequired() const override; | |
44 bool IsHighPriorityWorkAnticipated() override; | 45 bool IsHighPriorityWorkAnticipated() override; |
45 bool ShouldYieldForHighPriorityWork() override; | 46 bool ShouldYieldForHighPriorityWork() override; |
46 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; | 47 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; |
47 void RemoveTaskObserver( | 48 void RemoveTaskObserver( |
48 base::MessageLoop::TaskObserver* task_observer) override; | 49 base::MessageLoop::TaskObserver* task_observer) override; |
49 void Shutdown() override; | 50 void Shutdown() override; |
50 | 51 |
51 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); | 52 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); |
52 void SetWorkBatchSizeForTesting(size_t work_batch_size); | 53 void SetWorkBatchSizeForTesting(size_t work_batch_size); |
53 | 54 |
(...skipping 17 matching lines...) Expand all Loading... | |
71 COMPOSITOR_PRIORITY, | 72 COMPOSITOR_PRIORITY, |
72 TOUCHSTART_PRIORITY, | 73 TOUCHSTART_PRIORITY, |
73 }; | 74 }; |
74 | 75 |
75 enum class InputStreamState { | 76 enum class InputStreamState { |
76 INACTIVE, | 77 INACTIVE, |
77 ACTIVE, | 78 ACTIVE, |
78 ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE | 79 ACTIVE_AND_AWAITING_TOUCHSTART_RESPONSE |
79 }; | 80 }; |
80 | 81 |
82 enum class IdlePeriodState { | |
83 NOT_WITHIN_IDLE_PERIOD, | |
84 WITHIN_IDLE_PERIOD, | |
85 WITHIN_MAX_DEADLINE_IDLE_PERIOD | |
86 }; | |
87 | |
81 class PollableNeedsUpdateFlag { | 88 class PollableNeedsUpdateFlag { |
82 public: | 89 public: |
83 PollableNeedsUpdateFlag(base::Lock* write_lock); | 90 PollableNeedsUpdateFlag(base::Lock* write_lock); |
84 ~PollableNeedsUpdateFlag(); | 91 ~PollableNeedsUpdateFlag(); |
85 | 92 |
86 // Set the flag. May only be called if |write_lock| is held. | 93 // Set the flag. May only be called if |write_lock| is held. |
87 void SetWhileLocked(bool value); | 94 void SetWhileLocked(bool value); |
88 | 95 |
89 // Returns true iff the flag is set to true. | 96 // Returns true iff the flag is set to true. |
90 bool IsSet() const; | 97 bool IsSet() const; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration); | 151 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration); |
145 | 152 |
146 // An input event of some sort happened, the policy may need updating. | 153 // An input event of some sort happened, the policy may need updating. |
147 void UpdateForInputEvent(blink::WebInputEvent::Type type); | 154 void UpdateForInputEvent(blink::WebInputEvent::Type type); |
148 | 155 |
149 // Called when a previously queued input event was processed. | 156 // Called when a previously queued input event was processed. |
150 // |begin_frame_time|, if non-zero, identifies the frame time at which the | 157 // |begin_frame_time|, if non-zero, identifies the frame time at which the |
151 // input was processed. | 158 // input was processed. |
152 void DidProcessInputEvent(base::TimeTicks begin_frame_time); | 159 void DidProcessInputEvent(base::TimeTicks begin_frame_time); |
153 | 160 |
154 // Returns true if we should initiate a long idle time now. Fills in | 161 // Returns the new idle period state for the next long idle period. Fills in |
155 // |next_long_idle_period_delay_out| with the next time we should try to | 162 // |next_long_idle_period_delay_out| with the next time we should try to |
156 // initiate the next idle period. | 163 // initiate the next idle period. |
157 bool ShouldStartLongIdlePeriod( | 164 IdlePeriodState ComputeNewLongIdlePeriodState( |
158 const base::TimeTicks now, | 165 const base::TimeTicks now, |
159 base::TimeDelta* next_long_idle_period_delay_out); | 166 base::TimeDelta* next_long_idle_period_delay); |
Sami
2015/03/05 11:59:33
Did you mean to drop the _out here? It's still ref
rmcilroy
2015/03/05 13:50:19
opps no, thanks.
| |
160 | 167 |
161 // Initiate a long idle period. | 168 // Initiate a long idle period. |
162 void InitiateLongIdlePeriod(); | 169 void InitiateLongIdlePeriod(); |
163 void InitiateLongIdlePeriodAfterWakeup(); | 170 void InitiateLongIdlePeriodAfterWakeup(); |
164 | 171 |
165 // Start and end an idle period. | 172 // Start and end an idle period. |
166 void StartIdlePeriod(); | 173 void StartIdlePeriod(IdlePeriodState new_idle_period_state); |
167 void EndIdlePeriod(); | 174 void EndIdlePeriod(); |
168 | 175 |
169 base::TimeTicks Now() const; | 176 base::TimeTicks Now() const; |
170 | 177 |
171 base::ThreadChecker main_thread_checker_; | 178 base::ThreadChecker main_thread_checker_; |
172 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; | 179 scoped_ptr<RendererTaskQueueSelector> renderer_task_queue_selector_; |
173 scoped_ptr<TaskQueueManager> task_queue_manager_; | 180 scoped_ptr<TaskQueueManager> task_queue_manager_; |
174 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; | 181 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
175 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_; | 182 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_; |
176 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; | 183 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; |
177 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 184 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
178 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; | 185 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; |
179 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; | 186 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; |
180 | 187 |
181 base::Closure update_policy_closure_; | 188 base::Closure update_policy_closure_; |
182 CancelableClosureHolder end_idle_period_closure_; | 189 CancelableClosureHolder end_idle_period_closure_; |
183 CancelableClosureHolder initiate_next_long_idle_period_closure_; | 190 CancelableClosureHolder initiate_next_long_idle_period_closure_; |
184 CancelableClosureHolder after_wakeup_initiate_next_long_idle_period_closure_; | 191 CancelableClosureHolder after_wakeup_initiate_next_long_idle_period_closure_; |
185 | 192 |
186 // Don't access current_policy_ directly, instead use SchedulerPolicy(). | 193 // Don't access current_policy_ directly, instead use SchedulerPolicy(). |
187 Policy current_policy_; | 194 Policy current_policy_; |
188 bool in_idle_period_; | 195 IdlePeriodState idle_period_state_; |
Sami
2015/03/05 11:59:33
Not initialized?
rmcilroy
2015/03/05 13:50:19
Done.
| |
189 | 196 |
190 base::TimeTicks estimated_next_frame_begin_; | 197 base::TimeTicks estimated_next_frame_begin_; |
191 base::TimeTicks current_policy_expiration_time_; | 198 base::TimeTicks current_policy_expiration_time_; |
192 | 199 |
193 // The incoming_signals_lock_ mutex protects access to all variables in the | 200 // The incoming_signals_lock_ mutex protects access to all variables in the |
194 // (contiguous) block below. | 201 // (contiguous) block below. |
195 base::Lock incoming_signals_lock_; | 202 base::Lock incoming_signals_lock_; |
196 base::TimeTicks last_input_receipt_time_on_compositor_; | 203 base::TimeTicks last_input_receipt_time_on_compositor_; |
197 base::TimeTicks last_input_process_time_on_main_; | 204 base::TimeTicks last_input_process_time_on_main_; |
198 blink::WebInputEvent::Type last_input_type_; | 205 blink::WebInputEvent::Type last_input_type_; |
199 InputStreamState input_stream_state_; | 206 InputStreamState input_stream_state_; |
200 PollableNeedsUpdateFlag policy_may_need_update_; | 207 PollableNeedsUpdateFlag policy_may_need_update_; |
201 | 208 |
202 scoped_refptr<cc::TestNowSource> time_source_; | 209 scoped_refptr<cc::TestNowSource> time_source_; |
203 | 210 |
204 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; | 211 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; |
205 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; | 212 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; |
206 | 213 |
207 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); | 214 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); |
208 }; | 215 }; |
209 | 216 |
210 } // namespace content | 217 } // namespace content |
211 | 218 |
212 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ | 219 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ |
OLD | NEW |