| 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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THROTTL
ER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 // Accounts for given task for cpu-based throttling needs. | 139 // Accounts for given task for cpu-based throttling needs. |
| 140 void OnTaskRunTimeReported(TaskQueue* task_queue, | 140 void OnTaskRunTimeReported(TaskQueue* task_queue, |
| 141 base::TimeTicks start_time, | 141 base::TimeTicks start_time, |
| 142 base::TimeTicks end_time); | 142 base::TimeTicks end_time); |
| 143 | 143 |
| 144 void AsValueInto(base::trace_event::TracedValue* state, | 144 void AsValueInto(base::trace_event::TracedValue* state, |
| 145 base::TimeTicks now) const; | 145 base::TimeTicks now) const; |
| 146 private: | 146 private: |
| 147 struct Metadata { | 147 struct Metadata { |
| 148 Metadata() : throttling_ref_count(0), budget_pool(nullptr) {} | 148 Metadata() : throttling_ref_count(0) {} |
| 149 | 149 |
| 150 size_t throttling_ref_count; | 150 size_t throttling_ref_count; |
| 151 | 151 |
| 152 BudgetPool* budget_pool; | 152 std::unordered_set<BudgetPool*> budget_pools; |
| 153 }; | 153 }; |
| 154 using TaskQueueMap = std::unordered_map<TaskQueue*, Metadata>; | 154 using TaskQueueMap = std::unordered_map<TaskQueue*, Metadata>; |
| 155 | 155 |
| 156 void PumpThrottledTasks(); | 156 void PumpThrottledTasks(); |
| 157 | 157 |
| 158 // Note |unthrottled_runtime| might be in the past. When this happens we | 158 // Note |unthrottled_runtime| might be in the past. When this happens we |
| 159 // compute the delay to the next runtime based on now rather than | 159 // compute the delay to the next runtime based on now rather than |
| 160 // unthrottled_runtime. | 160 // unthrottled_runtime. |
| 161 void MaybeSchedulePumpThrottledTasks( | 161 void MaybeSchedulePumpThrottledTasks( |
| 162 const tracked_objects::Location& from_here, | 162 const tracked_objects::Location& from_here, |
| 163 base::TimeTicks now, | 163 base::TimeTicks now, |
| 164 base::TimeTicks runtime); | 164 base::TimeTicks runtime); |
| 165 | 165 |
| 166 BudgetPool* GetBudgetPoolForQueue(TaskQueue* queue); | |
| 167 | |
| 168 // Return next possible time when queue is allowed to run in accordance | 166 // Return next possible time when queue is allowed to run in accordance |
| 169 // with throttling policy. | 167 // with throttling policy. |
| 170 base::TimeTicks GetNextAllowedRunTime(base::TimeTicks now, TaskQueue* queue); | 168 base::TimeTicks GetNextAllowedRunTime(base::TimeTicks now, TaskQueue* queue); |
| 171 | 169 |
| 172 void MaybeDeleteQueueMetadata(TaskQueueMap::iterator it); | 170 void MaybeDeleteQueueMetadata(TaskQueueMap::iterator it); |
| 173 | 171 |
| 174 // Schedule a call PumpThrottledTasks at an appropriate moment for this queue. | 172 // Schedule a call PumpThrottledTasks at an appropriate moment for this queue. |
| 175 void SchedulePumpQueue(const tracked_objects::Location& from_here, | 173 void SchedulePumpQueue(const tracked_objects::Location& from_here, |
| 176 base::TimeTicks now, | 174 base::TimeTicks now, |
| 177 TaskQueue* queue); | 175 TaskQueue* queue); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 192 | 190 |
| 193 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; | 191 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; |
| 194 | 192 |
| 195 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); | 193 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); |
| 196 }; | 194 }; |
| 197 | 195 |
| 198 } // namespace scheduler | 196 } // namespace scheduler |
| 199 } // namespace blink | 197 } // namespace blink |
| 200 | 198 |
| 201 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THRO
TTLER_H_ | 199 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THRO
TTLER_H_ |
| OLD | NEW |