| 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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/debug/trace_event_argument.h" | 9 #include "base/debug/trace_event_argument.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void RendererSchedulerImpl::UpdateForInputEvent() { | 129 void RendererSchedulerImpl::UpdateForInputEvent() { |
| 130 base::AutoLock lock(incoming_signals_lock_); | 130 base::AutoLock lock(incoming_signals_lock_); |
| 131 if (last_input_time_.is_null()) { | 131 if (last_input_time_.is_null()) { |
| 132 // Update scheduler policy if should start a new compositor policy mode. | 132 // Update scheduler policy if should start a new compositor policy mode. |
| 133 policy_may_need_update_.SetLocked(true); | 133 policy_may_need_update_.SetLocked(true); |
| 134 PostUpdatePolicyOnControlRunner(base::TimeDelta()); | 134 PostUpdatePolicyOnControlRunner(base::TimeDelta()); |
| 135 } | 135 } |
| 136 last_input_time_ = Now(); | 136 last_input_time_ = Now(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool RendererSchedulerImpl::ShouldAnticipateHighPriorityWork() { |
| 140 main_thread_checker_.CalledOnValidThread(); |
| 141 if (!task_queue_manager_) |
| 142 return false; |
| 143 |
| 144 MaybeUpdatePolicy(); |
| 145 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY; |
| 146 } |
| 147 |
| 139 bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { | 148 bool RendererSchedulerImpl::ShouldYieldForHighPriorityWork() { |
| 140 main_thread_checker_.CalledOnValidThread(); | 149 main_thread_checker_.CalledOnValidThread(); |
| 141 if (!task_queue_manager_) | 150 if (!task_queue_manager_) |
| 142 return false; | 151 return false; |
| 143 | 152 |
| 144 MaybeUpdatePolicy(); | 153 MaybeUpdatePolicy(); |
| 145 // We only yield if we are in the compositor priority and there is compositor | 154 // We only yield if we are in the compositor priority and there is compositor |
| 146 // work outstanding. Note: even though the control queue is higher priority | 155 // work outstanding. Note: even though the control queue is higher priority |
| 147 // we don't yield for it since these tasks are not user-provided work and they | 156 // we don't yield for it since these tasks are not user-provided work and they |
| 148 // are only intended to run before the next task, not interrupt the tasks. | 157 // are only intended to run before the next task, not interrupt the tasks. |
| 158 // Note: This function could conceivable be implemented in terms of |
| 159 // |ShouldAnticipateHighPriorityWork|, but for clarity is not. |
| 149 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY && | 160 return SchedulerPolicy() == COMPOSITOR_PRIORITY_POLICY && |
| 150 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); | 161 !task_queue_manager_->IsQueueEmpty(COMPOSITOR_TASK_QUEUE); |
| 151 } | 162 } |
| 152 | 163 |
| 153 void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( | 164 void RendererSchedulerImpl::CurrentIdleTaskDeadlineCallback( |
| 154 base::TimeTicks* deadline_out) const { | 165 base::TimeTicks* deadline_out) const { |
| 155 main_thread_checker_.CalledOnValidThread(); | 166 main_thread_checker_.CalledOnValidThread(); |
| 156 *deadline_out = estimated_next_frame_begin_; | 167 *deadline_out = estimated_next_frame_begin_; |
| 157 } | 168 } |
| 158 | 169 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 state->SetDouble("last_input_time", | 317 state->SetDouble("last_input_time", |
| 307 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); | 318 (last_input_time_ - base::TimeTicks()).InMillisecondsF()); |
| 308 state->SetDouble( | 319 state->SetDouble( |
| 309 "estimated_next_frame_begin", | 320 "estimated_next_frame_begin", |
| 310 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); | 321 (estimated_next_frame_begin_ - base::TimeTicks()).InMillisecondsF()); |
| 311 | 322 |
| 312 return state; | 323 return state; |
| 313 } | 324 } |
| 314 | 325 |
| 315 } // namespace content | 326 } // namespace content |
| OLD | NEW |