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 #include "content/renderer/scheduler/renderer_scheduler_impl.h" | 5 #include "content/renderer/scheduler/renderer_scheduler_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 void RendererSchedulerImpl::UpdateForInputEvent() { | 138 void RendererSchedulerImpl::UpdateForInputEvent() { |
139 base::AutoLock lock(incoming_signals_lock_); | 139 base::AutoLock lock(incoming_signals_lock_); |
140 if (last_input_time_.is_null()) { | 140 if (last_input_time_.is_null()) { |
141 // Update scheduler policy if should start a new compositor policy mode. | 141 // Update scheduler policy if should start a new compositor policy mode. |
142 policy_may_need_update_.SetLocked(true); | 142 policy_may_need_update_.SetLocked(true); |
143 PostUpdatePolicyOnControlRunner(base::TimeDelta()); | 143 PostUpdatePolicyOnControlRunner(base::TimeDelta()); |
144 } | 144 } |
145 last_input_time_ = Now(); | 145 last_input_time_ = Now(); |
146 } | 146 } |
147 | 147 |
148 bool RendererSchedulerImpl::IsHighPriorityWorkAnticipated() { | |
149 main_thread_checker_.CalledOnValidThread(); | |
davidben
2015/02/03 19:46:47
DCHECK(....);
Ditto for all the other instances o
jdduke (slow)
2015/02/04 01:39:50
Hah, good catch.
| |
150 if (!task_queue_manager_) | |
151 return false; | |
152 | |
153 MaybeUpdatePolicy(); | |
154 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY; | |
155 } | |
156 | |
148 bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { | 157 bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { |
149 main_thread_checker_.CalledOnValidThread(); | 158 main_thread_checker_.CalledOnValidThread(); |
150 if (!task_queue_manager_) | 159 if (!task_queue_manager_) |
151 return false; | 160 return false; |
152 | 161 |
153 MaybeUpdatePolicy(); | 162 MaybeUpdatePolicy(); |
154 // We only yield if we are in the compositor priority and there is compositor | 163 // We only yield if we are in the compositor priority and there is compositor |
155 // work outstanding. Note: even though the control queue is higher priority | 164 // work outstanding. Note: even though the control queue is higher priority |
156 // we don't yield for it since these tasks are not user-provided work and they | 165 // we don't yield for it since these tasks are not user-provided work and they |
157 // are only intended to run before the next task, not interrupt the tasks. | 166 // are only intended to run before the next task, not interrupt the tasks. |
167 // Note: This function could conceivable be implemented in terms of | |
davidben
2015/02/03 19:46:47
Nit: conceivable -> conceivably
jdduke (slow)
2015/02/04 01:39:50
Done.
| |
168 // |IsHighPriorityWorkAnticipated|, but for clarity is not. | |
158 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY && | 169 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY && |
159 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); | 170 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); |
160 } | 171 } |
161 | 172 |
162 void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( | 173 void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( |
163 base::TimeTicks* deadline_out) const { | 174 base::TimeTicks* deadline_out) const { |
164 main_thread_checker_.CalledOnValidThread(); | 175 main_thread_checker_.CalledOnValidThread(); |
165 *deadline_out = estimated_next_frame_begin_; | 176 *deadline_out = estimated_next_frame_begin_; |
166 } | 177 } |
167 | 178 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 state->SetDouble("last_input_time", | 335 state->SetDouble("last_input_time", |
325 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); | 336 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); |
326 state->SetDouble( | 337 state->SetDouble( |
327 "estimated_next_frame_begin", | 338 "estimated_next_frame_begin", |
328 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); | 339 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); |
329 | 340 |
330 return state; | 341 return state; |
331 } | 342 } |
332 | 343 |
333 } // namespace content | 344 } // namespace content |
OLD | NEW |