Chromium Code Reviews| 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 "platform/scheduler/renderer/task_queue_throttler.h" | 5 #include "platform/scheduler/renderer/task_queue_throttler.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 task_queue->RemoveFence(); | 310 task_queue->RemoveFence(); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 renderer_scheduler_->UnregisterTimeDomain(time_domain_.get()); | 314 renderer_scheduler_->UnregisterTimeDomain(time_domain_.get()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void TaskQueueThrottler::SetQueueEnabled(TaskQueue* task_queue, bool enabled) { | 317 void TaskQueueThrottler::SetQueueEnabled(TaskQueue* task_queue, bool enabled) { |
| 318 TaskQueueMap::iterator find_it = queue_details_.find(task_queue); | 318 TaskQueueMap::iterator find_it = queue_details_.find(task_queue); |
| 319 | 319 |
| 320 // If TaskQueueThrottler does not know about this queue, just call | |
|
alex clarke (OOO till 29th)
2016/11/24 14:45:07
Please add a comment in here saying:
Both the Tas
altimin
2016/11/24 15:00:55
Done.
| |
| 321 // SetQueueEnabled directly. | |
| 320 if (find_it == queue_details_.end()) { | 322 if (find_it == queue_details_.end()) { |
| 321 task_queue->SetQueueEnabled(enabled); | 323 task_queue->SetQueueEnabled(enabled); |
| 322 return; | 324 return; |
| 323 } | 325 } |
| 324 | 326 |
| 327 // Even when this queue is not throttled by task queue throttler, we | |
|
alex clarke (OOO till 29th)
2016/11/24 14:45:07
Maybe:
// Remember the caller's preference so we
altimin
2016/11/24 15:00:55
Done.
| |
| 328 // need to remember this setting for the times when it wil.. | |
| 325 find_it->second.enabled = enabled; | 329 find_it->second.enabled = enabled; |
| 326 | 330 |
| 331 // If this queue is not throttled by task queue throttler, just call | |
| 332 // SetQueueEnabled directly. | |
| 327 if (!find_it->second.IsThrottled()) { | 333 if (!find_it->second.IsThrottled()) { |
| 328 task_queue->SetQueueEnabled(enabled); | 334 task_queue->SetQueueEnabled(enabled); |
| 329 return; | 335 return; |
| 330 } | 336 } |
| 331 | 337 |
| 332 // We don't enable the queue here because it's throttled and there might be | 338 // Task queue should be disabled here because it is throttled. |
| 333 // tasks in it's work queue that would execute immediatly rather than after | 339 // If it is enabled, a call to PumpThrottledTask will be scheduled. |
| 334 // PumpThrottledTasks runs. | 340 task_queue->SetQueueEnabled(false); |
|
alex clarke (OOO till 29th)
2016/11/24 14:45:07
That doesn't look right to me. I think it should
altimin
2016/11/24 15:00:55
That's intentional. Even when queue is enabled, we
| |
| 335 if (!enabled) { | 341 if (enabled) { |
| 336 task_queue->SetQueueEnabled(false); | |
| 337 MaybeSchedulePumpQueue(FROM_HERE, tick_clock_->NowTicks(), task_queue, | 342 MaybeSchedulePumpQueue(FROM_HERE, tick_clock_->NowTicks(), task_queue, |
| 338 base::nullopt); | 343 base::nullopt); |
| 339 } | 344 } |
| 340 } | 345 } |
| 341 | 346 |
| 342 void TaskQueueThrottler::IncreaseThrottleRefCount(TaskQueue* task_queue) { | 347 void TaskQueueThrottler::IncreaseThrottleRefCount(TaskQueue* task_queue) { |
| 343 DCHECK_NE(task_queue, task_runner_.get()); | 348 DCHECK_NE(task_queue, task_runner_.get()); |
| 344 | 349 |
| 345 std::pair<TaskQueueMap::iterator, bool> insert_result = | 350 std::pair<TaskQueueMap::iterator, bool> insert_result = |
| 346 queue_details_.insert(std::make_pair(task_queue, Metadata())); | 351 queue_details_.insert(std::make_pair(task_queue, Metadata())); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 queue->SetTimeDomain(time_domain_.get()); | 667 queue->SetTimeDomain(time_domain_.get()); |
| 663 MaybeSchedulePumpQueue(FROM_HERE, lazy_now.Now(), queue, | 668 MaybeSchedulePumpQueue(FROM_HERE, lazy_now.Now(), queue, |
| 664 GetNextAllowedRunTime(lazy_now.Now(), queue)); | 669 GetNextAllowedRunTime(lazy_now.Now(), queue)); |
| 665 } | 670 } |
| 666 | 671 |
| 667 TRACE_EVENT0(tracing_category_, "TaskQueueThrottler_EnableThrottling"); | 672 TRACE_EVENT0(tracing_category_, "TaskQueueThrottler_EnableThrottling"); |
| 668 } | 673 } |
| 669 | 674 |
| 670 } // namespace scheduler | 675 } // namespace scheduler |
| 671 } // namespace blink | 676 } // namespace blink |
| OLD | NEW |