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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h

Issue 2915993003: Revert of [scheduler] Change TaskQueue observer call mechanism. (Closed)
Patch Set: Created 3 years, 6 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_BASE_TASK_QUEUE_IMPL_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool PostDelayedTask(const tracked_objects::Location& from_here, 135 bool PostDelayedTask(const tracked_objects::Location& from_here,
136 base::OnceClosure task, 136 base::OnceClosure task,
137 base::TimeDelta delay) override; 137 base::TimeDelta delay) override;
138 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 138 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
139 base::OnceClosure task, 139 base::OnceClosure task,
140 base::TimeDelta delay) override; 140 base::TimeDelta delay) override;
141 std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override; 141 std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override;
142 bool IsQueueEnabled() const override; 142 bool IsQueueEnabled() const override;
143 bool IsEmpty() const override; 143 bool IsEmpty() const override;
144 size_t GetNumberOfPendingTasks() const override; 144 size_t GetNumberOfPendingTasks() const override;
145 bool HasTaskToRunImmediately() const override; 145 bool HasPendingImmediateWork() const override;
146 base::Optional<base::TimeTicks> GetNextScheduledWakeUp() override; 146 base::Optional<base::TimeTicks> GetNextScheduledWakeUp() override;
147 void SetQueuePriority(QueuePriority priority) override; 147 void SetQueuePriority(QueuePriority priority) override;
148 QueuePriority GetQueuePriority() const override; 148 QueuePriority GetQueuePriority() const override;
149 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; 149 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
150 void RemoveTaskObserver( 150 void RemoveTaskObserver(
151 base::MessageLoop::TaskObserver* task_observer) override; 151 base::MessageLoop::TaskObserver* task_observer) override;
152 void SetTimeDomain(TimeDomain* time_domain) override; 152 void SetTimeDomain(TimeDomain* time_domain) override;
153 TimeDomain* GetTimeDomain() const override; 153 TimeDomain* GetTimeDomain() const override;
154 void SetBlameContext(base::trace_event::BlameContext* blame_context) override; 154 void SetBlameContext(base::trace_event::BlameContext* blame_context) override;
155 void InsertFence(InsertFencePosition position) override; 155 void InsertFence(InsertFencePosition position) override;
(...skipping 14 matching lines...) Expand all
170 170
171 void AsValueInto(base::TimeTicks now, 171 void AsValueInto(base::TimeTicks now,
172 base::trace_event::TracedValue* state) const; 172 base::trace_event::TracedValue* state) const;
173 173
174 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } 174 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; }
175 bool GetShouldNotifyObservers() const { return should_notify_observers_; } 175 bool GetShouldNotifyObservers() const { return should_notify_observers_; }
176 176
177 void NotifyWillProcessTask(const base::PendingTask& pending_task); 177 void NotifyWillProcessTask(const base::PendingTask& pending_task);
178 void NotifyDidProcessTask(const base::PendingTask& pending_task); 178 void NotifyDidProcessTask(const base::PendingTask& pending_task);
179 179
180 // Called by TimeDomain when the wake-up for this queue has changed.
181 // There is only one wake-up, new wake-up cancels any previous wake-ups.
182 // If |scheduled_time_domain_wake_up| is base::nullopt then the wake-up
183 // has been cancelled.
184 // Must be called from the main thread.
185 void SetScheduledTimeDomainWakeUp(
186 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up);
187
188 // Check for available tasks in immediate work queues.
189 // Used to check if we need to generate notifications about delayed work.
190 bool HasPendingImmediateWork();
191
192 WorkQueue* delayed_work_queue() { 180 WorkQueue* delayed_work_queue() {
193 return main_thread_only().delayed_work_queue.get(); 181 return main_thread_only().delayed_work_queue.get();
194 } 182 }
195 183
196 const WorkQueue* delayed_work_queue() const { 184 const WorkQueue* delayed_work_queue() const {
197 return main_thread_only().delayed_work_queue.get(); 185 return main_thread_only().delayed_work_queue.get();
198 } 186 }
199 187
200 WorkQueue* immediate_work_queue() { 188 WorkQueue* immediate_work_queue() {
201 return main_thread_only().immediate_work_queue.get(); 189 return main_thread_only().immediate_work_queue.get();
202 } 190 }
203 191
204 const WorkQueue* immediate_work_queue() const { 192 const WorkQueue* immediate_work_queue() const {
205 return main_thread_only().immediate_work_queue.get(); 193 return main_thread_only().immediate_work_queue.get();
206 } 194 }
207 195
208 bool should_report_when_execution_blocked() const { 196 bool should_report_when_execution_blocked() const {
209 return should_report_when_execution_blocked_; 197 return should_report_when_execution_blocked_;
210 } 198 }
211 199
212 // Enqueues any delayed tasks which should be run now on the 200 // Enqueues any delayed tasks which should be run now on the
213 // |delayed_work_queue|. Returns the subsequent wake-up that is required, if 201 // |delayed_work_queue|. Returns the subsequent wake-up that is required, if
214 // any. Must be called from the main thread. 202 // any. Must be called from the main thread.
215 base::Optional<DelayedWakeUp> WakeUpForDelayedWork(LazyNow* lazy_now); 203 base::Optional<DelayedWakeUp> WakeUpForDelayedWork(LazyNow* lazy_now);
216 204
217 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up() const { 205 base::TimeTicks scheduled_time_domain_wake_up() const {
218 return main_thread_only().scheduled_time_domain_wake_up; 206 return main_thread_only().scheduled_time_domain_wake_up;
219 } 207 }
220 208
209 void set_scheduled_time_domain_wake_up(
210 base::TimeTicks scheduled_time_domain_wake_up) {
211 main_thread_only().scheduled_time_domain_wake_up =
212 scheduled_time_domain_wake_up;
213 }
214
221 HeapHandle heap_handle() const { return main_thread_only().heap_handle; } 215 HeapHandle heap_handle() const { return main_thread_only().heap_handle; }
222 216
223 void set_heap_handle(HeapHandle heap_handle) { 217 void set_heap_handle(HeapHandle heap_handle) {
224 main_thread_only().heap_handle = heap_handle; 218 main_thread_only().heap_handle = heap_handle;
225 } 219 }
226 220
227 void PushImmediateIncomingTaskForTest(TaskQueueImpl::Task&& task); 221 void PushImmediateIncomingTaskForTest(TaskQueueImpl::Task&& task);
228 EnqueueOrder GetFenceForTest() const; 222 EnqueueOrder GetFenceForTest() const;
229 223
230 class QueueEnabledVoterImpl : public QueueEnabledVoter { 224 class QueueEnabledVoterImpl : public QueueEnabledVoter {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 std::unique_ptr<WorkQueue> delayed_work_queue; 278 std::unique_ptr<WorkQueue> delayed_work_queue;
285 std::unique_ptr<WorkQueue> immediate_work_queue; 279 std::unique_ptr<WorkQueue> immediate_work_queue;
286 std::priority_queue<Task> delayed_incoming_queue; 280 std::priority_queue<Task> delayed_incoming_queue;
287 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; 281 base::ObserverList<base::MessageLoop::TaskObserver> task_observers;
288 size_t set_index; 282 size_t set_index;
289 HeapHandle heap_handle; 283 HeapHandle heap_handle;
290 int is_enabled_refcount; 284 int is_enabled_refcount;
291 int voter_refcount; 285 int voter_refcount;
292 base::trace_event::BlameContext* blame_context; // Not owned. 286 base::trace_event::BlameContext* blame_context; // Not owned.
293 EnqueueOrder current_fence; 287 EnqueueOrder current_fence;
294 base::Optional<base::TimeTicks> scheduled_time_domain_wake_up; 288 base::TimeTicks scheduled_time_domain_wake_up;
295 }; 289 };
296 290
297 ~TaskQueueImpl() override; 291 ~TaskQueueImpl() override;
298 292
299 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, 293 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here,
300 base::OnceClosure task, 294 base::OnceClosure task,
301 TaskType task_type); 295 TaskType task_type);
302 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, 296 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here,
303 base::OnceClosure task, 297 base::OnceClosure task,
304 base::TimeDelta delay, 298 base::TimeDelta delay,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 base::TimeTicks now, 340 base::TimeTicks now,
347 base::trace_event::TracedValue* state); 341 base::trace_event::TracedValue* state);
348 342
349 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); 343 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter);
350 void OnQueueEnabledVoteChanged(bool enabled); 344 void OnQueueEnabledVoteChanged(bool enabled);
351 void EnableOrDisableWithSelector(bool enable); 345 void EnableOrDisableWithSelector(bool enable);
352 346
353 // Schedules delayed work on time domain and calls the observer. 347 // Schedules delayed work on time domain and calls the observer.
354 void ScheduleDelayedWorkInTimeDomain(base::TimeTicks now); 348 void ScheduleDelayedWorkInTimeDomain(base::TimeTicks now);
355 349
350 void NotifyWakeUpChangedOnMainThread(base::TimeTicks wake_up);
351
356 const base::PlatformThreadId thread_id_; 352 const base::PlatformThreadId thread_id_;
357 353
358 mutable base::Lock any_thread_lock_; 354 mutable base::Lock any_thread_lock_;
359 AnyThread any_thread_; 355 AnyThread any_thread_;
360 struct AnyThread& any_thread() { 356 struct AnyThread& any_thread() {
361 any_thread_lock_.AssertAcquired(); 357 any_thread_lock_.AssertAcquired();
362 return any_thread_; 358 return any_thread_;
363 } 359 }
364 const struct AnyThread& any_thread() const { 360 const struct AnyThread& any_thread() const {
365 any_thread_lock_.AssertAcquired(); 361 any_thread_lock_.AssertAcquired();
(...skipping 30 matching lines...) Expand all
396 const bool should_report_when_execution_blocked_; 392 const bool should_report_when_execution_blocked_;
397 393
398 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); 394 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl);
399 }; 395 };
400 396
401 } // namespace internal 397 } // namespace internal
402 } // namespace scheduler 398 } // namespace scheduler
403 } // namespace blink 399 } // namespace blink
404 400
405 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 401 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698