| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/throttling_helper.h" | 5 #include "components/scheduler/renderer/throttling_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/scheduler/base/real_time_domain.h" | 8 #include "components/scheduler/base/real_time_domain.h" |
| 9 #include "components/scheduler/base/virtual_time_domain.h" | 9 #include "components/scheduler/base/virtual_time_domain.h" |
| 10 #include "components/scheduler/child/scheduler_tqm_delegate.h" | 10 #include "components/scheduler/child/scheduler_tqm_delegate.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 if (iter != throttled_queues_.end() && --iter->second == 0) { | 73 if (iter != throttled_queues_.end() && --iter->second == 0) { |
| 74 // The refcount has become zero, we need to unthrottle the queue. | 74 // The refcount has become zero, we need to unthrottle the queue. |
| 75 throttled_queues_.erase(iter); | 75 throttled_queues_.erase(iter); |
| 76 | 76 |
| 77 task_queue->SetTimeDomain(renderer_scheduler_->real_time_domain()); | 77 task_queue->SetTimeDomain(renderer_scheduler_->real_time_domain()); |
| 78 task_queue->SetPumpPolicy(TaskQueue::PumpPolicy::AUTO); | 78 task_queue->SetPumpPolicy(TaskQueue::PumpPolicy::AUTO); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ThrottlingHelper::UnregisterTaskQueue(TaskQueue* task_queue) { |
| 83 throttled_queues_.erase(task_queue); |
| 84 } |
| 85 |
| 82 void ThrottlingHelper::OnTimeDomainHasImmediateWork() { | 86 void ThrottlingHelper::OnTimeDomainHasImmediateWork() { |
| 83 // Forward to the main thread if called from another thread. | 87 // Forward to the main thread if called from another thread. |
| 84 if (!task_runner_->RunsTasksOnCurrentThread()) { | 88 if (!task_runner_->RunsTasksOnCurrentThread()) { |
| 85 task_runner_->PostTask(FROM_HERE, forward_immediate_work_closure_); | 89 task_runner_->PostTask(FROM_HERE, forward_immediate_work_closure_); |
| 86 return; | 90 return; |
| 87 } | 91 } |
| 88 TRACE_EVENT0(tracing_category_, | 92 TRACE_EVENT0(tracing_category_, |
| 89 "ThrottlingHelper::OnTimeDomainHasImmediateWork"); | 93 "ThrottlingHelper::OnTimeDomainHasImmediateWork"); |
| 90 base::TimeTicks now = tick_clock_->NowTicks(); | 94 base::TimeTicks now = tick_clock_->NowTicks(); |
| 91 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, now, now); | 95 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, now, now); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 156 |
| 153 pending_pump_throttled_tasks_runtime_ = throttled_runtime; | 157 pending_pump_throttled_tasks_runtime_ = throttled_runtime; |
| 154 | 158 |
| 155 suspend_timers_when_backgrounded_closure_.Cancel(); | 159 suspend_timers_when_backgrounded_closure_.Cancel(); |
| 156 task_runner_->PostDelayedTask( | 160 task_runner_->PostDelayedTask( |
| 157 from_here, suspend_timers_when_backgrounded_closure_.callback(), | 161 from_here, suspend_timers_when_backgrounded_closure_.callback(), |
| 158 pending_pump_throttled_tasks_runtime_ - now); | 162 pending_pump_throttled_tasks_runtime_ - now); |
| 159 } | 163 } |
| 160 | 164 |
| 161 } // namespace scheduler | 165 } // namespace scheduler |
| OLD | NEW |