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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 if (!enabled) { | 325 if (!enabled) { |
| 326 task_queue->SetQueueEnabled(false); | 326 task_queue->SetQueueEnabled(false); |
| 327 MaybeSchedulePumpQueue(FROM_HERE, tick_clock_->NowTicks(), task_queue, | 327 MaybeSchedulePumpQueue(FROM_HERE, tick_clock_->NowTicks(), task_queue, |
| 328 base::nullopt); | 328 base::nullopt); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 void TaskQueueThrottler::IncreaseThrottleRefCount(TaskQueue* task_queue) { | 332 void TaskQueueThrottler::IncreaseThrottleRefCount(TaskQueue* task_queue) { |
| 333 DCHECK_NE(task_queue, task_runner_.get()); | 333 DCHECK_NE(task_queue, task_runner_.get()); |
| 334 | 334 |
| 335 std::pair<TaskQueueMap::iterator, bool> insert_result = | 335 std::pair<TaskQueueMap::iterator, bool> insert_result = queue_details_.insert( |
| 336 queue_details_.insert(std::make_pair(task_queue, Metadata())); | 336 std::make_pair(task_queue, Metadata(0, task_queue->IsQueueEnabled()))); |
|
Sami
2016/11/22 19:27:35
0 /* ref_count */ (I had to look it up)
altimin
2016/11/23 11:11:29
Done.
| |
| 337 | 337 |
| 338 if (!insert_result.first->second.IsThrottled()) { | 338 if (!insert_result.first->second.IsThrottled()) { |
| 339 // The insert was successful so we need to throttle the queue. | |
| 340 insert_result.first->second.enabled = task_queue->IsQueueEnabled(); | |
| 341 | |
| 342 if (allow_throttling_) { | 339 if (allow_throttling_) { |
| 343 task_queue->SetTimeDomain(time_domain_.get()); | 340 task_queue->SetTimeDomain(time_domain_.get()); |
| 344 task_queue->RemoveFence(); | 341 task_queue->RemoveFence(); |
| 345 task_queue->SetQueueEnabled(false); | 342 task_queue->SetQueueEnabled(false); |
| 346 | 343 |
| 347 if (!task_queue->IsEmpty()) { | 344 if (!task_queue->IsEmpty()) { |
| 348 if (task_queue->HasPendingImmediateWork()) { | 345 if (task_queue->HasPendingImmediateWork()) { |
| 349 OnTimeDomainHasImmediateWork(task_queue); | 346 OnTimeDomainHasImmediateWork(task_queue); |
| 350 } else { | 347 } else { |
| 351 OnTimeDomainHasDelayedWork(task_queue); | 348 OnTimeDomainHasDelayedWork(task_queue); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 374 task_queue->RemoveFence(); | 371 task_queue->RemoveFence(); |
| 375 task_queue->SetQueueEnabled(enabled); | 372 task_queue->SetQueueEnabled(enabled); |
| 376 } | 373 } |
| 377 | 374 |
| 378 TRACE_EVENT1(tracing_category_, "TaskQueueThrottler_TaskQueueUntrottled", | 375 TRACE_EVENT1(tracing_category_, "TaskQueueThrottler_TaskQueueUntrottled", |
| 379 "task_queue", task_queue); | 376 "task_queue", task_queue); |
| 380 } | 377 } |
| 381 } | 378 } |
| 382 | 379 |
| 383 bool TaskQueueThrottler::IsThrottled(TaskQueue* task_queue) const { | 380 bool TaskQueueThrottler::IsThrottled(TaskQueue* task_queue) const { |
| 381 if (!allow_throttling_) | |
|
Sami
2016/11/22 19:27:35
Is this a necessary change? To me this query says
altimin
2016/11/23 11:11:29
Yes, this is the source of the bug.
I think that
Sami
2016/11/23 11:52:06
I think this is still pretty confusing. Based on t
altimin
2016/11/23 14:29:17
It is very confusing indeed! I took another look a
| |
| 382 return false; | |
| 383 | |
| 384 auto find_it = queue_details_.find(task_queue); | 384 auto find_it = queue_details_.find(task_queue); |
| 385 if (find_it == queue_details_.end()) | 385 if (find_it == queue_details_.end()) |
| 386 return false; | 386 return false; |
| 387 return find_it->second.IsThrottled(); | 387 return find_it->second.IsThrottled(); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void TaskQueueThrottler::UnregisterTaskQueue(TaskQueue* task_queue) { | 390 void TaskQueueThrottler::UnregisterTaskQueue(TaskQueue* task_queue) { |
| 391 LazyNow lazy_now(tick_clock_); | 391 LazyNow lazy_now(tick_clock_); |
| 392 auto find_it = queue_details_.find(task_queue); | 392 auto find_it = queue_details_.find(task_queue); |
| 393 | 393 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 | 636 |
| 637 queue->SetQueueEnabled(false); | 637 queue->SetQueueEnabled(false); |
| 638 queue->SetTimeDomain(time_domain_.get()); | 638 queue->SetTimeDomain(time_domain_.get()); |
| 639 MaybeSchedulePumpQueue(FROM_HERE, lazy_now.Now(), queue, | 639 MaybeSchedulePumpQueue(FROM_HERE, lazy_now.Now(), queue, |
| 640 GetNextAllowedRunTime(lazy_now.Now(), queue)); | 640 GetNextAllowedRunTime(lazy_now.Now(), queue)); |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 | 643 |
| 644 } // namespace scheduler | 644 } // namespace scheduler |
| 645 } // namespace blink | 645 } // namespace blink |
| OLD | NEW |