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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELPER_ H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 // becomes zero then |task_queue| is unthrottled. If the refcount was already | 153 // becomes zero then |task_queue| is unthrottled. If the refcount was already |
| 154 // zero this function does nothing. | 154 // zero this function does nothing. |
| 155 void DecreaseThrottleRefCount(TaskQueue* task_queue); | 155 void DecreaseThrottleRefCount(TaskQueue* task_queue); |
| 156 | 156 |
| 157 // Removes |task_queue| from |queue_details| and from appropriate budget pool. | 157 // Removes |task_queue| from |queue_details| and from appropriate budget pool. |
| 158 void UnregisterTaskQueue(TaskQueue* task_queue); | 158 void UnregisterTaskQueue(TaskQueue* task_queue); |
| 159 | 159 |
| 160 // Returns true if the |task_queue| is throttled. | 160 // Returns true if the |task_queue| is throttled. |
| 161 bool IsThrottled(TaskQueue* task_queue) const; | 161 bool IsThrottled(TaskQueue* task_queue) const; |
| 162 | 162 |
| 163 // Communicate audio state to TaskQueueThrottler. | |
| 164 void SetIsAudioActive(bool is_audio_active); | |
|
Sami
2016/09/29 13:36:07
I don't think TaskQueueThrottler should know about
altimin
2016/09/29 16:29:43
Done.
| |
| 165 | |
| 163 // Tells the TaskQueueThrottler we're using virtual time, which disables all | 166 // Tells the TaskQueueThrottler we're using virtual time, which disables all |
| 164 // throttling. | 167 // throttling. |
| 165 void EnableVirtualTime(); | 168 void EnableVirtualTime(); |
| 166 | 169 |
| 167 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); } | 170 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); } |
| 168 | 171 |
| 169 static base::TimeTicks AlignedThrottledRunTime( | 172 static base::TimeTicks AlignedThrottledRunTime( |
| 170 base::TimeTicks unthrottled_runtime); | 173 base::TimeTicks unthrottled_runtime); |
| 171 | 174 |
| 172 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; } | 175 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 base::TimeTicks now, | 222 base::TimeTicks now, |
| 220 TaskQueue* queue, | 223 TaskQueue* queue, |
| 221 base::Optional<base::TimeTicks> next_possible_run_time); | 224 base::Optional<base::TimeTicks> next_possible_run_time); |
| 222 | 225 |
| 223 // Return next possible time when queue is allowed to run in accordance | 226 // Return next possible time when queue is allowed to run in accordance |
| 224 // with throttling policy. | 227 // with throttling policy. |
| 225 base::TimeTicks GetNextAllowedRunTime(base::TimeTicks now, TaskQueue* queue); | 228 base::TimeTicks GetNextAllowedRunTime(base::TimeTicks now, TaskQueue* queue); |
| 226 | 229 |
| 227 void MaybeDeleteQueueMetadata(TaskQueueMap::iterator it); | 230 void MaybeDeleteQueueMetadata(TaskQueueMap::iterator it); |
| 228 | 231 |
| 232 // Disable throttling for all queues, this setting takes precedence over | |
| 233 // all other throttling settings. Designed to be used when a global event | |
| 234 // disabling throttling happens (e.g. audio is playing). | |
| 235 void DisableThrottling(); | |
| 236 | |
| 237 // Enable back global throttling. | |
| 238 void EnableThrottling(); | |
| 239 | |
| 240 void UpdateGlobalThrottlingSetting(); | |
|
alex clarke (OOO till 29th)
2016/09/29 11:16:53
Sami how do you feel about this vs UpdatePolicy? M
Sami
2016/09/29 13:36:07
Yeah I think we want to cause a policy update inst
alex clarke (OOO till 29th)
2016/09/29 13:46:18
Thinking about this more I'd suggest instead of ad
altimin
2016/09/29 16:29:43
Done.
| |
| 241 | |
| 229 TaskQueueMap queue_details_; | 242 TaskQueueMap queue_details_; |
| 230 base::Callback<void(TaskQueue*)> forward_immediate_work_callback_; | 243 base::Callback<void(TaskQueue*)> forward_immediate_work_callback_; |
| 231 scoped_refptr<TaskQueue> task_runner_; | 244 scoped_refptr<TaskQueue> task_runner_; |
| 232 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED | 245 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED |
| 233 base::TickClock* tick_clock_; // NOT OWNED | 246 base::TickClock* tick_clock_; // NOT OWNED |
| 234 const char* tracing_category_; // NOT OWNED | 247 const char* tracing_category_; // NOT OWNED |
| 235 std::unique_ptr<ThrottledTimeDomain> time_domain_; | 248 std::unique_ptr<ThrottledTimeDomain> time_domain_; |
| 236 | 249 |
| 237 CancelableClosureHolder pump_throttled_tasks_closure_; | 250 CancelableClosureHolder pump_throttled_tasks_closure_; |
| 238 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_; | 251 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_; |
| 252 bool is_throttling_disabled_; | |
|
Sami
2016/09/29 13:36:07
Negative flags hurt my head -- how about allow_thr
altimin
2016/09/29 16:29:43
Done.
| |
| 239 bool virtual_time_; | 253 bool virtual_time_; |
| 254 bool is_audio_active_; | |
| 240 | 255 |
| 241 std::unordered_map<TimeBudgetPool*, std::unique_ptr<TimeBudgetPool>> | 256 std::unordered_map<TimeBudgetPool*, std::unique_ptr<TimeBudgetPool>> |
| 242 time_budget_pools_; | 257 time_budget_pools_; |
| 243 | 258 |
| 244 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; | 259 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; |
| 245 | 260 |
| 246 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); | 261 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); |
| 247 }; | 262 }; |
| 248 | 263 |
| 249 } // namespace scheduler | 264 } // namespace scheduler |
| 250 } // namespace blink | 265 } // namespace blink |
| 251 | 266 |
| 252 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ | 267 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ |
| OLD | NEW |