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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void RendererSchedulerImpl::UpdateForInputEvent() { | 140 void RendererSchedulerImpl::UpdateForInputEvent() { |
141 base::AutoLock lock(incoming_signals_lock_); | 141 base::AutoLock lock(incoming_signals_lock_); |
142 if (last_input_time_.is_null()) { | 142 if (last_input_time_.is_null()) { |
143 // Update scheduler policy if should start a new compositor policy mode. | 143 // Update scheduler policy if should start a new compositor policy mode. |
144 policy_may_need_update_.SetLocked(true); | 144 policy_may_need_update_.SetLocked(true); |
145 PostUpdatePolicyOnControlRunner(base::TimeDelta()); | 145 PostUpdatePolicyOnControlRunner(base::TimeDelta()); |
146 } | 146 } |
147 last_input_time_ = Now(); | 147 last_input_time_ = Now(); |
148 } | 148 } |
149 | 149 |
| 150 bool RendererSchedulerImpl::IsHighPriorityWorkAnticipated() { |
| 151 main_thread_checker_.CalledOnValidThread(); |
| 152 if (!task_queue_manager_) |
| 153 return false; |
| 154 |
| 155 MaybeUpdatePolicy(); |
| 156 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY; |
| 157 } |
| 158 |
150 bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { | 159 bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { |
151 main_thread_checker_.CalledOnValidThread(); | 160 main_thread_checker_.CalledOnValidThread(); |
152 if (!task_queue_manager_) | 161 if (!task_queue_manager_) |
153 return false; | 162 return false; |
154 | 163 |
155 MaybeUpdatePolicy(); | 164 MaybeUpdatePolicy(); |
156 // We only yield if we are in the compositor priority and there is compositor | 165 // We only yield if we are in the compositor priority and there is compositor |
157 // work outstanding. Note: even though the control queue is higher priority | 166 // work outstanding. Note: even though the control queue is higher priority |
158 // we don't yield for it since these tasks are not user-provided work and they | 167 // we don't yield for it since these tasks are not user-provided work and they |
159 // are only intended to run before the next task, not interrupt the tasks. | 168 // are only intended to run before the next task, not interrupt the tasks. |
| 169 // Note: This function could conceivably be implemented in terms of |
| 170 // |IsHighPriorityWorkAnticipated|, but for clarity is not. |
160 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY && | 171 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY && |
161 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); | 172 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); |
162 } | 173 } |
163 | 174 |
164 void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( | 175 void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( |
165 base::TimeTicks* deadline_out) const { | 176 base::TimeTicks* deadline_out) const { |
166 main_thread_checker_.CalledOnValidThread(); | 177 main_thread_checker_.CalledOnValidThread(); |
167 *deadline_out = estimated_next_frame_begin_; | 178 *deadline_out = estimated_next_frame_begin_; |
168 } | 179 } |
169 | 180 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 state->SetDouble("last_input_time", | 344 state->SetDouble("last_input_time", |
334 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); | 345 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); |
335 state->SetDouble( | 346 state->SetDouble( |
336 "estimated_next_frame_begin", | 347 "estimated_next_frame_begin", |
337 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); | 348 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); |
338 | 349 |
339 return state; | 350 return state; |
340 } | 351 } |
341 | 352 |
342 } // namespace content | 353 } // namespace content |
OLD | NEW |