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

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

Issue 2533603002: [scheduler] Add options to TaskQueue::InsertFence (Closed)
Patch Set: More nits Created 4 years 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // hard-code string instead. 161 // hard-code string instead.
162 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler, 162 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler,
163 const char* tracing_category); 163 const char* tracing_category);
164 164
165 ~TaskQueueThrottler() override; 165 ~TaskQueueThrottler() override;
166 166
167 // TimeDomain::Observer implementation: 167 // TimeDomain::Observer implementation:
168 void OnTimeDomainHasImmediateWork(TaskQueue*) override; 168 void OnTimeDomainHasImmediateWork(TaskQueue*) override;
169 void OnTimeDomainHasDelayedWork(TaskQueue*) override; 169 void OnTimeDomainHasDelayedWork(TaskQueue*) override;
170 170
171 // The purpose of this method is to make sure throttling doesn't conflict with
172 // enabling/disabling the queue for policy reasons.
173 // If |task_queue| is throttled then the TaskQueueThrottler remembers the
174 // |enabled| setting. In addition if |enabled| is false then the queue is
175 // immediatly disabled. Otherwise if |task_queue| not throttled then
176 // TaskQueue::SetEnabled(enabled) is called.
177 void SetQueueEnabled(TaskQueue* task_queue, bool enabled);
178
179 // Increments the throttled refcount and causes |task_queue| to be throttled 171 // Increments the throttled refcount and causes |task_queue| to be throttled
180 // if its not already throttled. 172 // if its not already throttled.
181 void IncreaseThrottleRefCount(TaskQueue* task_queue); 173 void IncreaseThrottleRefCount(TaskQueue* task_queue);
182 174
183 // If the refcouint is non-zero it's decremented. If the throttled refcount 175 // If the refcouint is non-zero it's decremented. If the throttled refcount
184 // becomes zero then |task_queue| is unthrottled. If the refcount was already 176 // becomes zero then |task_queue| is unthrottled. If the refcount was already
185 // zero this function does nothing. 177 // zero this function does nothing.
186 void DecreaseThrottleRefCount(TaskQueue* task_queue); 178 void DecreaseThrottleRefCount(TaskQueue* task_queue);
187 179
188 // Removes |task_queue| from |queue_details| and from appropriate budget pool. 180 // Removes |task_queue| from |queue_details| and from appropriate budget pool.
(...skipping 26 matching lines...) Expand all
215 // Accounts for given task for cpu-based throttling needs. 207 // Accounts for given task for cpu-based throttling needs.
216 void OnTaskRunTimeReported(TaskQueue* task_queue, 208 void OnTaskRunTimeReported(TaskQueue* task_queue,
217 base::TimeTicks start_time, 209 base::TimeTicks start_time,
218 base::TimeTicks end_time); 210 base::TimeTicks end_time);
219 211
220 void AsValueInto(base::trace_event::TracedValue* state, 212 void AsValueInto(base::trace_event::TracedValue* state,
221 base::TimeTicks now) const; 213 base::TimeTicks now) const;
222 214
223 private: 215 private:
224 struct Metadata { 216 struct Metadata {
225 Metadata() 217 Metadata() : throttling_ref_count(0), time_budget_pool(nullptr) {}
226 : throttling_ref_count(0), enabled(false), time_budget_pool(nullptr) {}
227
228 Metadata(size_t ref_count, bool is_enabled)
229 : throttling_ref_count(ref_count),
230 enabled(is_enabled),
231 time_budget_pool(nullptr) {}
232 218
233 size_t throttling_ref_count; 219 size_t throttling_ref_count;
234 bool enabled;
235 220
236 TimeBudgetPool* time_budget_pool; 221 TimeBudgetPool* time_budget_pool;
237
238 void SetQueueEnabled(TaskQueue* task_queue);
239 }; 222 };
240 using TaskQueueMap = std::unordered_map<TaskQueue*, Metadata>; 223 using TaskQueueMap = std::unordered_map<TaskQueue*, Metadata>;
241 224
242 void PumpThrottledTasks(); 225 void PumpThrottledTasks();
243 226
244 // Note |unthrottled_runtime| might be in the past. When this happens we 227 // Note |unthrottled_runtime| might be in the past. When this happens we
245 // compute the delay to the next runtime based on now rather than 228 // compute the delay to the next runtime based on now rather than
246 // unthrottled_runtime. 229 // unthrottled_runtime.
247 void MaybeSchedulePumpThrottledTasks( 230 void MaybeSchedulePumpThrottledTasks(
248 const tracked_objects::Location& from_here, 231 const tracked_objects::Location& from_here,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 264
282 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; 265 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_;
283 266
284 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); 267 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler);
285 }; 268 };
286 269
287 } // namespace scheduler 270 } // namespace scheduler
288 } // namespace blink 271 } // namespace blink
289 272
290 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_ 273 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_THROTTLING_HELP ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698