Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.h

Issue 2383473002: [scheduler] Teach scheduler about audio state (Closed)
Patch Set: Switched to page messages Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Tells the TaskQueueThrottler we're using virtual time, which disables all 163 // Disable throttling for all queues, this setting takes precedence over
164 // throttling. 164 // all other throttling settings. Designed to be used when a global event
165 void EnableVirtualTime(); 165 // disabling throttling happens (e.g. audio is playing).
166 void DisableThrottling();
167
168 // Enable back global throttling.
169 void EnableThrottling();
166 170
167 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); } 171 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); }
168 172
169 static base::TimeTicks AlignedThrottledRunTime( 173 static base::TimeTicks AlignedThrottledRunTime(
170 base::TimeTicks unthrottled_runtime); 174 base::TimeTicks unthrottled_runtime);
171 175
172 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; } 176 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; }
173 177
174 // Returned object is owned by |TaskQueueThrottler|. 178 // Returned object is owned by |TaskQueueThrottler|.
175 TimeBudgetPool* CreateTimeBudgetPool(const char* name); 179 TimeBudgetPool* CreateTimeBudgetPool(const char* name);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 TaskQueueMap queue_details_; 233 TaskQueueMap queue_details_;
230 base::Callback<void(TaskQueue*)> forward_immediate_work_callback_; 234 base::Callback<void(TaskQueue*)> forward_immediate_work_callback_;
231 scoped_refptr<TaskQueue> task_runner_; 235 scoped_refptr<TaskQueue> task_runner_;
232 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED 236 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
233 base::TickClock* tick_clock_; // NOT OWNED 237 base::TickClock* tick_clock_; // NOT OWNED
234 const char* tracing_category_; // NOT OWNED 238 const char* tracing_category_; // NOT OWNED
235 std::unique_ptr<ThrottledTimeDomain> time_domain_; 239 std::unique_ptr<ThrottledTimeDomain> time_domain_;
236 240
237 CancelableClosureHolder pump_throttled_tasks_closure_; 241 CancelableClosureHolder pump_throttled_tasks_closure_;
238 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_; 242 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_;
239 bool virtual_time_; 243 bool allow_throttling_;
240 244
241 std::unordered_map<TimeBudgetPool*, std::unique_ptr<TimeBudgetPool>> 245 std::unordered_map<TimeBudgetPool*, std::unique_ptr<TimeBudgetPool>>
242 time_budget_pools_; 246 time_budget_pools_;
243 247
244 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; 248 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_;
245 249
246 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); 250 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler);
247 }; 251 };
248 252
249 } // namespace scheduler 253 } // namespace scheduler
250 } // namespace blink 254 } // namespace blink
251 255
252 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ 256 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698