| 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/throttling_helper.h" | 5 #include "platform/scheduler/renderer/throttling_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "platform/scheduler/base/real_time_domain.h" | 8 #include "platform/scheduler/base/real_time_domain.h" |
| 9 #include "platform/scheduler/child/scheduler_tqm_delegate.h" | 9 #include "platform/scheduler/child/scheduler_tqm_delegate.h" |
| 10 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h" | 10 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 DCHECK(has_delayed_task); | 139 DCHECK(has_delayed_task); |
| 140 base::TimeTicks now = tick_clock_->NowTicks(); | 140 base::TimeTicks now = tick_clock_->NowTicks(); |
| 141 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, now, | 141 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, now, |
| 142 next_scheduled_delayed_task); | 142 next_scheduled_delayed_task); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ThrottlingHelper::PumpThrottledTasks() { | 145 void ThrottlingHelper::PumpThrottledTasks() { |
| 146 TRACE_EVENT0(tracing_category_, "ThrottlingHelper::PumpThrottledTasks"); | 146 TRACE_EVENT0(tracing_category_, "ThrottlingHelper::PumpThrottledTasks"); |
| 147 pending_pump_throttled_tasks_runtime_ = base::TimeTicks(); | 147 pending_pump_throttled_tasks_runtime_ = base::TimeTicks(); |
| 148 | 148 |
| 149 LazyNow lazy_low(tick_clock_); | |
| 150 for (const TaskQueueMap::value_type& map_entry : throttled_queues_) { | 149 for (const TaskQueueMap::value_type& map_entry : throttled_queues_) { |
| 151 TaskQueue* task_queue = map_entry.first; | 150 TaskQueue* task_queue = map_entry.first; |
| 152 if (!map_entry.second.enabled || task_queue->IsEmpty()) | 151 if (!map_entry.second.enabled || task_queue->IsEmpty()) |
| 153 continue; | 152 continue; |
| 154 | 153 |
| 155 task_queue->SetQueueEnabled(true); | 154 task_queue->SetQueueEnabled(true); |
| 156 task_queue->InsertFence(); | 155 task_queue->InsertFence(); |
| 157 } | 156 } |
| 158 // Make sure NextScheduledRunTime gives us an up-to date result. | |
| 159 time_domain_->ClearExpiredWakeups(); | |
| 160 | 157 |
| 161 base::TimeTicks next_scheduled_delayed_task; | 158 base::TimeTicks next_scheduled_delayed_task; |
| 162 // Maybe schedule a call to ThrottlingHelper::PumpThrottledTasks if there is | 159 // Maybe schedule a call to ThrottlingHelper::PumpThrottledTasks if there is |
| 163 // a pending delayed task. NOTE posting a non-delayed task in the future will | 160 // a pending delayed task. NOTE posting a non-delayed task in the future will |
| 164 // result in ThrottlingHelper::OnTimeDomainHasImmediateWork being called. | 161 // result in ThrottlingHelper::OnTimeDomainHasImmediateWork being called. |
| 165 if (time_domain_->NextScheduledRunTime(&next_scheduled_delayed_task)) { | 162 if (time_domain_->NextScheduledRunTime(&next_scheduled_delayed_task)) { |
| 166 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, lazy_low.Now(), | 163 LazyNow lazy_now(tick_clock_); |
| 164 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, lazy_now.Now(), |
| 167 next_scheduled_delayed_task); | 165 next_scheduled_delayed_task); |
| 168 } | 166 } |
| 169 } | 167 } |
| 170 | 168 |
| 171 /* static */ | 169 /* static */ |
| 172 base::TimeTicks ThrottlingHelper::ThrottledRunTime( | 170 base::TimeTicks ThrottlingHelper::ThrottledRunTime( |
| 173 base::TimeTicks unthrottled_runtime) { | 171 base::TimeTicks unthrottled_runtime) { |
| 174 const base::TimeDelta one_second = base::TimeDelta::FromSeconds(1); | 172 const base::TimeDelta one_second = base::TimeDelta::FromSeconds(1); |
| 175 return unthrottled_runtime + one_second - | 173 return unthrottled_runtime + one_second - |
| 176 ((unthrottled_runtime - base::TimeTicks()) % one_second); | 174 ((unthrottled_runtime - base::TimeTicks()) % one_second); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 throttled_queues_.erase(throttled_queues_.begin()); | 214 throttled_queues_.erase(throttled_queues_.begin()); |
| 217 | 215 |
| 218 task_queue->SetTimeDomain(renderer_scheduler_->GetVirtualTimeDomain()); | 216 task_queue->SetTimeDomain(renderer_scheduler_->GetVirtualTimeDomain()); |
| 219 task_queue->RemoveFence(); | 217 task_queue->RemoveFence(); |
| 220 task_queue->SetQueueEnabled(enabled); | 218 task_queue->SetQueueEnabled(enabled); |
| 221 } | 219 } |
| 222 } | 220 } |
| 223 | 221 |
| 224 } // namespace scheduler | 222 } // namespace scheduler |
| 225 } // namespace blink | 223 } // namespace blink |
| OLD | NEW |