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

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

Issue 2812703002: Revert of [scheduler] Add TaskQueue::Observer (Closed)
Patch Set: Manual Revert Created 3 years, 8 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_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 28 matching lines...) Expand all
39 // To be used by BudgetPool only, use BudgetPool::{Add,Remove}Queue 39 // To be used by BudgetPool only, use BudgetPool::{Add,Remove}Queue
40 // methods instead. 40 // methods instead.
41 virtual void AddQueueToBudgetPool(TaskQueue* queue, 41 virtual void AddQueueToBudgetPool(TaskQueue* queue,
42 BudgetPool* budget_pool) = 0; 42 BudgetPool* budget_pool) = 0;
43 virtual void RemoveQueueFromBudgetPool(TaskQueue* queue, 43 virtual void RemoveQueueFromBudgetPool(TaskQueue* queue,
44 BudgetPool* budget_pool) = 0; 44 BudgetPool* budget_pool) = 0;
45 45
46 // Deletes the budget pool. 46 // Deletes the budget pool.
47 virtual void UnregisterBudgetPool(BudgetPool* budget_pool) = 0; 47 virtual void UnregisterBudgetPool(BudgetPool* budget_pool) = 0;
48 48
49 // Insert a fence to prevent tasks from running and schedule a wake_up at 49 // Insert a fence to prevent tasks from running and schedule a wakeup at
50 // an appropriate time. 50 // an appropriate time.
51 virtual void BlockQueue(base::TimeTicks now, TaskQueue* queue) = 0; 51 virtual void BlockQueue(base::TimeTicks now, TaskQueue* queue) = 0;
52 52
53 // Schedule a call to unblock queue at an appropriate moment. 53 // Schedule a call to unblock queue at an appropriate moment.
54 virtual void UnblockQueue(base::TimeTicks now, TaskQueue* queue) = 0; 54 virtual void UnblockQueue(base::TimeTicks now, TaskQueue* queue) = 0;
55 55
56 // Returns true if the |queue| is throttled (i.e. added to TaskQueueThrottler 56 // Returns true if the |queue| is throttled (i.e. added to TaskQueueThrottler
57 // and throttling is not disabled). 57 // and throttling is not disabled).
58 virtual bool IsThrottled(TaskQueue* queue) const = 0; 58 virtual bool IsThrottled(TaskQueue* queue) const = 0;
59 }; 59 };
(...skipping 13 matching lines...) Expand all
73 // policy reasons. To prevent the systems from fighting, clients of 73 // policy reasons. To prevent the systems from fighting, clients of
74 // TaskQueueThrottler must use SetQueueEnabled rather than calling the function 74 // TaskQueueThrottler must use SetQueueEnabled rather than calling the function
75 // directly on the queue. 75 // directly on the queue.
76 // 76 //
77 // There may be more than one system that wishes to throttle a queue (e.g. 77 // There may be more than one system that wishes to throttle a queue (e.g.
78 // renderer suspension vs tab level suspension) so the TaskQueueThrottler keeps 78 // renderer suspension vs tab level suspension) so the TaskQueueThrottler keeps
79 // a count of the number of systems that wish a queue to be throttled. 79 // a count of the number of systems that wish a queue to be throttled.
80 // See IncreaseThrottleRefCount & DecreaseThrottleRefCount. 80 // See IncreaseThrottleRefCount & DecreaseThrottleRefCount.
81 // 81 //
82 // This class is main-thread only. 82 // This class is main-thread only.
83 class BLINK_PLATFORM_EXPORT TaskQueueThrottler : public TaskQueue::Observer, 83 class BLINK_PLATFORM_EXPORT TaskQueueThrottler : public TimeDomain::Observer,
84 public BudgetPoolController { 84 public BudgetPoolController {
85 public: 85 public:
86 // TODO(altimin): Do not pass tracing category as const char*, 86 // TODO(altimin): Do not pass tracing category as const char*,
87 // hard-code string instead. 87 // hard-code string instead.
88 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler, 88 TaskQueueThrottler(RendererSchedulerImpl* renderer_scheduler,
89 const char* tracing_category); 89 const char* tracing_category);
90 90
91 ~TaskQueueThrottler() override; 91 ~TaskQueueThrottler() override;
92 92
93 // TaskQueue::Observer implementation: 93 // TimeDomain::Observer implementation:
94 void OnQueueNextWakeUpChanged(TaskQueue* queue, 94 void OnTimeDomainHasImmediateWork(TaskQueue*) override;
95 base::TimeTicks wake_up) override; 95 void OnTimeDomainHasDelayedWork(TaskQueue*) override;
96 96
97 // BudgetPoolController implementation: 97 // BudgetPoolController implementation:
98 void AddQueueToBudgetPool(TaskQueue* queue, BudgetPool* budget_pool) override; 98 void AddQueueToBudgetPool(TaskQueue* queue, BudgetPool* budget_pool) override;
99 void RemoveQueueFromBudgetPool(TaskQueue* queue, 99 void RemoveQueueFromBudgetPool(TaskQueue* queue,
100 BudgetPool* budget_pool) override; 100 BudgetPool* budget_pool) override;
101 void UnregisterBudgetPool(BudgetPool* budget_pool) override; 101 void UnregisterBudgetPool(BudgetPool* budget_pool) override;
102 void BlockQueue(base::TimeTicks now, TaskQueue* queue) override; 102 void BlockQueue(base::TimeTicks now, TaskQueue* queue) override;
103 void UnblockQueue(base::TimeTicks now, TaskQueue* queue) override; 103 void UnblockQueue(base::TimeTicks now, TaskQueue* queue) override;
104 bool IsThrottled(TaskQueue* queue) const override; 104 bool IsThrottled(TaskQueue* queue) const override;
105 105
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 base::TimeTicks GetNextAllowedRunTime(base::TimeTicks now, TaskQueue* queue); 165 base::TimeTicks GetNextAllowedRunTime(base::TimeTicks now, TaskQueue* queue);
166 166
167 void MaybeDeleteQueueMetadata(TaskQueueMap::iterator it); 167 void MaybeDeleteQueueMetadata(TaskQueueMap::iterator it);
168 168
169 // Schedule a call PumpThrottledTasks at an appropriate moment for this queue. 169 // Schedule a call PumpThrottledTasks at an appropriate moment for this queue.
170 void SchedulePumpQueue(const tracked_objects::Location& from_here, 170 void SchedulePumpQueue(const tracked_objects::Location& from_here,
171 base::TimeTicks now, 171 base::TimeTicks now,
172 TaskQueue* queue); 172 TaskQueue* queue);
173 173
174 TaskQueueMap queue_details_; 174 TaskQueueMap queue_details_;
175 base::Callback<void(TaskQueue*, base::TimeTicks)> 175 base::Callback<void(TaskQueue*)> forward_immediate_work_callback_;
176 forward_immediate_work_callback_;
177 scoped_refptr<TaskQueue> task_runner_; 176 scoped_refptr<TaskQueue> task_runner_;
178 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED 177 RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED
179 base::TickClock* tick_clock_; // NOT OWNED 178 base::TickClock* tick_clock_; // NOT OWNED
180 const char* tracing_category_; // NOT OWNED 179 const char* tracing_category_; // NOT OWNED
181 std::unique_ptr<ThrottledTimeDomain> time_domain_; 180 std::unique_ptr<ThrottledTimeDomain> time_domain_;
182 181
183 CancelableClosureHolder pump_throttled_tasks_closure_; 182 CancelableClosureHolder pump_throttled_tasks_closure_;
184 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_; 183 base::Optional<base::TimeTicks> pending_pump_throttled_tasks_runtime_;
185 bool allow_throttling_; 184 bool allow_throttling_;
186 185
187 std::unordered_map<BudgetPool*, std::unique_ptr<BudgetPool>> budget_pools_; 186 std::unordered_map<BudgetPool*, std::unique_ptr<BudgetPool>> budget_pools_;
188 187
189 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_; 188 base::WeakPtrFactory<TaskQueueThrottler> weak_factory_;
190 189
191 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler); 190 DISALLOW_COPY_AND_ASSIGN(TaskQueueThrottler);
192 }; 191 };
193 192
194 } // namespace scheduler 193 } // namespace scheduler
195 } // namespace blink 194 } // namespace blink
196 195
197 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THRO TTLER_H_ 196 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_RENDERER_TASK_QUEUE_THRO TTLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698