| 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 "components/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "components/scheduler/renderer/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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 helper_.CheckOnValidThread(); | 129 helper_.CheckOnValidThread(); |
| 130 if (helper_.IsShutdown()) | 130 if (helper_.IsShutdown()) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 base::TimeTicks now(helper_.Now()); | 133 base::TimeTicks now(helper_.Now()); |
| 134 if (now < estimated_next_frame_begin_) { | 134 if (now < estimated_next_frame_begin_) { |
| 135 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of | 135 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of |
| 136 // the next pending delayed tasks (as currently done in for long idle times) | 136 // the next pending delayed tasks (as currently done in for long idle times) |
| 137 idle_helper_.StartIdlePeriod( | 137 idle_helper_.StartIdlePeriod( |
| 138 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, | 138 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, |
| 139 estimated_next_frame_begin_, true); | 139 estimated_next_frame_begin_); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { | 143 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { |
| 144 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 144 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 145 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); | 145 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); |
| 146 helper_.CheckOnValidThread(); | 146 helper_.CheckOnValidThread(); |
| 147 if (helper_.IsShutdown()) | 147 if (helper_.IsShutdown()) |
| 148 return; | 148 return; |
| 149 | 149 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 return true; | 297 return true; |
| 298 | 298 |
| 299 default: | 299 default: |
| 300 NOTREACHED(); | 300 NOTREACHED(); |
| 301 return false; | 301 return false; |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 base::TimeTicks RendererSchedulerImpl::CurrentIdleTaskDeadlineForTesting() | 305 base::TimeTicks RendererSchedulerImpl::CurrentIdleTaskDeadlineForTesting() |
| 306 const { | 306 const { |
| 307 base::TimeTicks deadline; | 307 return idle_helper_.CurrentIdleTaskDeadline(); |
| 308 idle_helper_.CurrentIdleTaskDeadlineCallback(&deadline); | |
| 309 return deadline; | |
| 310 } | 308 } |
| 311 | 309 |
| 312 RendererSchedulerImpl::Policy RendererSchedulerImpl::SchedulerPolicy() const { | 310 RendererSchedulerImpl::Policy RendererSchedulerImpl::SchedulerPolicy() const { |
| 313 helper_.CheckOnValidThread(); | 311 helper_.CheckOnValidThread(); |
| 314 return current_policy_; | 312 return current_policy_; |
| 315 } | 313 } |
| 316 | 314 |
| 317 void RendererSchedulerImpl::MaybeUpdatePolicy() { | 315 void RendererSchedulerImpl::MaybeUpdatePolicy() { |
| 318 helper_.CheckOnValidThread(); | 316 helper_.CheckOnValidThread(); |
| 319 if (policy_may_need_update_.IsSet()) { | 317 if (policy_may_need_update_.IsSet()) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 *next_long_idle_period_delay_out = current_policy_expiration_time_ - now; | 478 *next_long_idle_period_delay_out = current_policy_expiration_time_ - now; |
| 481 return false; | 479 return false; |
| 482 } | 480 } |
| 483 return true; | 481 return true; |
| 484 } | 482 } |
| 485 | 483 |
| 486 SchedulerHelper* RendererSchedulerImpl::GetSchedulerHelperForTesting() { | 484 SchedulerHelper* RendererSchedulerImpl::GetSchedulerHelperForTesting() { |
| 487 return &helper_; | 485 return &helper_; |
| 488 } | 486 } |
| 489 | 487 |
| 490 RendererSchedulerImpl::PollableNeedsUpdateFlag::PollableNeedsUpdateFlag( | |
| 491 base::Lock* write_lock_) | |
| 492 : flag_(false), write_lock_(write_lock_) { | |
| 493 } | |
| 494 | |
| 495 RendererSchedulerImpl::PollableNeedsUpdateFlag::~PollableNeedsUpdateFlag() { | |
| 496 } | |
| 497 | |
| 498 void RendererSchedulerImpl::PollableNeedsUpdateFlag::SetWhileLocked( | |
| 499 bool value) { | |
| 500 write_lock_->AssertAcquired(); | |
| 501 base::subtle::Release_Store(&flag_, value); | |
| 502 } | |
| 503 | |
| 504 bool RendererSchedulerImpl::PollableNeedsUpdateFlag::IsSet() const { | |
| 505 return base::subtle::Acquire_Load(&flag_) != 0; | |
| 506 } | |
| 507 | |
| 508 void RendererSchedulerImpl::SuspendTimerQueue() { | 488 void RendererSchedulerImpl::SuspendTimerQueue() { |
| 509 helper_.CheckOnValidThread(); | 489 helper_.CheckOnValidThread(); |
| 510 timer_queue_suspend_count_++; | 490 timer_queue_suspend_count_++; |
| 511 ForceUpdatePolicy(); | 491 ForceUpdatePolicy(); |
| 512 DCHECK(!helper_.IsQueueEnabled(TIMER_TASK_QUEUE)); | 492 DCHECK(!helper_.IsQueueEnabled(TIMER_TASK_QUEUE)); |
| 513 } | 493 } |
| 514 | 494 |
| 515 void RendererSchedulerImpl::ResumeTimerQueue() { | 495 void RendererSchedulerImpl::ResumeTimerQueue() { |
| 516 helper_.CheckOnValidThread(); | 496 helper_.CheckOnValidThread(); |
| 517 timer_queue_suspend_count_--; | 497 timer_queue_suspend_count_--; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 // meaningful touchstart response and should not impact task priority. | 613 // meaningful touchstart response and should not impact task priority. |
| 634 return current_state; | 614 return current_state; |
| 635 | 615 |
| 636 default: | 616 default: |
| 637 break; | 617 break; |
| 638 } | 618 } |
| 639 return InputStreamState::ACTIVE; | 619 return InputStreamState::ACTIVE; |
| 640 } | 620 } |
| 641 | 621 |
| 642 } // namespace scheduler | 622 } // namespace scheduler |
| OLD | NEW |