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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 | 195 |
| 196 TRACE_EVENT0("renderer.scheduler", | 196 TRACE_EVENT0("renderer.scheduler", |
| 197 "TaskQueueThrottler::OnQueueNextWakeUpChanged"); | 197 "TaskQueueThrottler::OnQueueNextWakeUpChanged"); |
| 198 | 198 |
| 199 // We don't expect this to get called for disabled queues, but we can't DCHECK | 199 // We don't expect this to get called for disabled queues, but we can't DCHECK |
| 200 // because of the above thread hop. Just bail out if the queue is disabled. | 200 // because of the above thread hop. Just bail out if the queue is disabled. |
| 201 if (!queue->IsQueueEnabled()) | 201 if (!queue->IsQueueEnabled()) |
| 202 return; | 202 return; |
| 203 | 203 |
| 204 base::TimeTicks now = tick_clock_->NowTicks(); | 204 base::TimeTicks now = tick_clock_->NowTicks(); |
| 205 next_wake_up = std::max(now, next_wake_up); | |
| 205 | 206 |
| 206 auto find_it = queue_details_.find(queue); | 207 auto find_it = queue_details_.find(queue); |
| 207 if (find_it == queue_details_.end()) | 208 if (find_it == queue_details_.end()) |
| 208 return; | 209 return; |
| 209 | 210 |
| 210 for (BudgetPool* budget_pool : find_it->second.budget_pools) { | 211 for (BudgetPool* budget_pool : find_it->second.budget_pools) { |
| 211 budget_pool->OnQueueNextWakeUpChanged(queue, now, next_wake_up); | 212 budget_pool->OnQueueNextWakeUpChanged(queue, now, next_wake_up); |
| 212 } | 213 } |
| 213 | 214 |
| 214 // TODO(altimin): This probably can be removed —- budget pools should | 215 // TODO(altimin): This probably can be removed —- budget pools should |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 243 ((unthrottled_runtime - base::TimeTicks()) % one_second); | 244 ((unthrottled_runtime - base::TimeTicks()) % one_second); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void TaskQueueThrottler::MaybeSchedulePumpThrottledTasks( | 247 void TaskQueueThrottler::MaybeSchedulePumpThrottledTasks( |
| 247 const tracked_objects::Location& from_here, | 248 const tracked_objects::Location& from_here, |
| 248 base::TimeTicks now, | 249 base::TimeTicks now, |
| 249 base::TimeTicks unaligned_runtime) { | 250 base::TimeTicks unaligned_runtime) { |
| 250 if (!allow_throttling_) | 251 if (!allow_throttling_) |
| 251 return; | 252 return; |
| 252 | 253 |
| 254 // TODO(altimin): Consider removing alignment here. | |
|
Z_DONOTUSE
2017/05/23 19:31:46
Ditto.
| |
| 253 base::TimeTicks runtime = | 255 base::TimeTicks runtime = |
| 254 AlignedThrottledRunTime(std::max(now, unaligned_runtime)); | 256 std::max(now, unaligned_runtime) |
| 257 .SnappedToNextTick(base::TimeTicks(), | |
| 258 base::TimeDelta::FromSeconds(1)); | |
| 255 DCHECK_LE(now, runtime); | 259 DCHECK_LE(now, runtime); |
| 256 | 260 |
| 257 // If there is a pending call to PumpThrottledTasks and it's sooner than | 261 // If there is a pending call to PumpThrottledTasks and it's sooner than |
| 258 // |runtime| then return. | 262 // |runtime| then return. |
| 259 if (pending_pump_throttled_tasks_runtime_ && | 263 if (pending_pump_throttled_tasks_runtime_ && |
| 260 runtime >= pending_pump_throttled_tasks_runtime_.value()) { | 264 runtime >= pending_pump_throttled_tasks_runtime_.value()) { |
| 261 return; | 265 return; |
| 262 } | 266 } |
| 263 | 267 |
| 264 pending_pump_throttled_tasks_runtime_ = runtime; | 268 pending_pump_throttled_tasks_runtime_ = runtime; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 queue->InsertFence(TaskQueue::InsertFencePosition::BEGINNING_OF_TIME); | 557 queue->InsertFence(TaskQueue::InsertFencePosition::BEGINNING_OF_TIME); |
| 554 queue->SetTimeDomain(time_domain_.get()); | 558 queue->SetTimeDomain(time_domain_.get()); |
| 555 UpdateQueueThrottlingState(lazy_now.Now(), queue); | 559 UpdateQueueThrottlingState(lazy_now.Now(), queue); |
| 556 } | 560 } |
| 557 | 561 |
| 558 TRACE_EVENT0("renderer.scheduler", "TaskQueueThrottler_EnableThrottling"); | 562 TRACE_EVENT0("renderer.scheduler", "TaskQueueThrottler_EnableThrottling"); |
| 559 } | 563 } |
| 560 | 564 |
| 561 } // namespace scheduler | 565 } // namespace scheduler |
| 562 } // namespace blink | 566 } // namespace blink |
| OLD | NEW |