Chromium Code Reviews| Index: components/scheduler/renderer/throttling_helper.cc |
| diff --git a/components/scheduler/renderer/throttling_helper.cc b/components/scheduler/renderer/throttling_helper.cc |
| index 31fcb7de54db1bfa34a454ad6f2705819ee7051a..7d0fdea9646e784c16a908e40cee6de34df98ae0 100644 |
| --- a/components/scheduler/renderer/throttling_helper.cc |
| +++ b/components/scheduler/renderer/throttling_helper.cc |
| @@ -43,11 +43,26 @@ ThrottlingHelper::~ThrottlingHelper() { |
| renderer_scheduler_->UnregisterTimeDomain(time_domain_.get()); |
| } |
| +void ThrottlingHelper::SetQueueEnabled(TaskQueue* task_queue, bool enabled) { |
| + TaskQueueMap::iterator find_it = throttled_queues_.find(task_queue); |
| + |
| + if (find_it == throttled_queues_.end()) { |
| + task_queue->SetQueueEnabled(enabled); |
| + return; |
| + } |
| + |
| + find_it->second.enabled = enabled; |
| + |
| + if (!enabled) |
|
Sami
2016/05/31 18:11:04
Maybe add a comment why we don't want to enable th
alex clarke (OOO till 29th)
2016/06/02 13:51:05
Done.
|
| + task_queue->SetQueueEnabled(false); |
| +} |
| + |
| void ThrottlingHelper::IncreaseThrottleRefCount(TaskQueue* task_queue) { |
| DCHECK_NE(task_queue, task_runner_.get()); |
| std::pair<TaskQueueMap::iterator, bool> insert_result = |
| - throttled_queues_.insert(std::make_pair(task_queue, 1)); |
| + throttled_queues_.insert(std::make_pair( |
| + task_queue, Metadata(1, task_queue->IsQueueEnabled()))); |
| if (insert_result.second) { |
| // The insert was succesful so we need to throttle the queue. |
| @@ -64,20 +79,22 @@ void ThrottlingHelper::IncreaseThrottleRefCount(TaskQueue* task_queue) { |
| } |
| } else { |
| // An entry already existed in the map so we need to increment the refcount. |
| - insert_result.first->second++; |
| + insert_result.first->second.throttling_ref_count++; |
| } |
| } |
| void ThrottlingHelper::DecreaseThrottleRefCount(TaskQueue* task_queue) { |
| TaskQueueMap::iterator iter = throttled_queues_.find(task_queue); |
| - if (iter != throttled_queues_.end() && --iter->second == 0) { |
| + if (iter != throttled_queues_.end() && |
| + --iter->second.throttling_ref_count == 0) { |
| + bool enabled = iter->second.enabled; |
| // The refcount has become zero, we need to unthrottle the queue. |
| throttled_queues_.erase(iter); |
| task_queue->SetTimeDomain(renderer_scheduler_->real_time_domain()); |
| task_queue->SetPumpPolicy(TaskQueue::PumpPolicy::AUTO); |
| - task_queue->SetQueueEnabled(true); |
| + task_queue->SetQueueEnabled(enabled); |
| } |
| } |
| @@ -120,7 +137,7 @@ void ThrottlingHelper::PumpThrottledTasks() { |
| if (task_queue->IsEmpty()) |
| continue; |
| - task_queue->SetQueueEnabled(true); |
| + task_queue->SetQueueEnabled(map_entry.second.enabled); |
|
Sami
2016/05/31 18:11:04
Mind adding a DCHECK here that makes sure the enab
alex clarke (OOO till 29th)
2016/06/02 13:51:05
This in principle is a good idea, but due to the w
|
| task_queue->PumpQueue(false); |
| } |
| // Make sure NextScheduledRunTime gives us an up-to date result. |