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

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: Rebased 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // becomes zero then |task_queue| is unthrottled. If the refcount was already 172 // becomes zero then |task_queue| is unthrottled. If the refcount was already
173 // zero this function does nothing. 173 // zero this function does nothing.
174 void DecreaseThrottleRefCount(TaskQueue* task_queue); 174 void DecreaseThrottleRefCount(TaskQueue* task_queue);
175 175
176 // Removes |task_queue| from |queue_details| and from appropriate budget pool. 176 // Removes |task_queue| from |queue_details| and from appropriate budget pool.
177 void UnregisterTaskQueue(TaskQueue* task_queue); 177 void UnregisterTaskQueue(TaskQueue* task_queue);
178 178
179 // Returns true if the |task_queue| is throttled. 179 // Returns true if the |task_queue| is throttled.
180 bool IsThrottled(TaskQueue* task_queue) const; 180 bool IsThrottled(TaskQueue* task_queue) const;
181 181
182 // Tells the TaskQueueThrottler we're using virtual time, which disables all 182 // Disable throttling for all queues, this setting takes precedence over
183 // throttling. 183 // all other throttling settings. Designed to be used when a global event
184 void EnableVirtualTime(); 184 // disabling throttling happens (e.g. audio is playing).
185 void DisableThrottling();
186
187 // Enable back global throttling.
188 void EnableThrottling();
185 189
186 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); } 190 const ThrottledTimeDomain* time_domain() const { return time_domain_.get(); }
187 191
188 static base::TimeTicks AlignedThrottledRunTime( 192 static base::TimeTicks AlignedThrottledRunTime(
189 base::TimeTicks unthrottled_runtime); 193 base::TimeTicks unthrottled_runtime);
190 194
191 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; } 195 const scoped_refptr<TaskQueue>& task_runner() const { return task_runner_; }
192 196
193 // Returned object is owned by |TaskQueueThrottler|. 197 // Returned object is owned by |TaskQueueThrottler|.
194 TimeBudgetPool* CreateTimeBudgetPool(const char* name); 198 TimeBudgetPool* CreateTimeBudgetPool(const char* name);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED 257 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
254 base::TickClock* tick_clock_; // NOT OWNED 258 base::TickClock* tick_clock_; // NOT OWNED
255 const char* tracing_category_; // NOT OWNED 259 const char* tracing_category_; // NOT OWNED
256 std::unique_ptr<ThrottledTimeDomain> time_domain_; 260 std::unique_ptr<ThrottledTimeDomain> time_domain_;
257 261
258 base::Optional<base::TimeDelta> max_budget_level_; 262 base::Optional<base::TimeDelta> max_budget_level_;
259 base::Optional<base::TimeDelta> max_throttling_duration_; 263 base::Optional<base::TimeDelta> max_throttling_duration_;
260 264
261 CancelableClosureHolder pump_throttled_tasks_closure_; 265 CancelableClosureHolder pump_throttled_tasks_closure_;
262 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_; 266 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_;
263 bool virtual_time_; 267 bool allow_throttling_;
264 268
265 std::unordered_map<TimeBudgetPool*, std::unique_ptr<TimeBudgetPool>> 269 std::unordered_map<TimeBudgetPool*, std::unique_ptr<TimeBudgetPool>>
266 time_budget_pools_; 270 time_budget_pools_;
267 271
268 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; 272 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_;
269 273
270 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); 274 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler);
271 }; 275 };
272 276
273 } // namespace scheduler 277 } // namespace scheduler
274 } // namespace blink 278 } // namespace blink
275 279
276 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ 280 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698