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

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

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 TaskQueueImpl(TaskQueueManager* task_queue_manager, 59 TaskQueueImpl(TaskQueueManager* task_queue_manager,
60 TimeDomain* time_domain, 60 TimeDomain* time_domain,
61 const Spec& spec, 61 const Spec& spec,
62 const char* disabled_by_default_tracing_category, 62 const char* disabled_by_default_tracing_category,
63 const char* disabled_by_default_verbose_tracing_category); 63 const char* disabled_by_default_verbose_tracing_category);
64 64
65 class BLINK_PLATFORM_EXPORT Task : public base::PendingTask { 65 class BLINK_PLATFORM_EXPORT Task : public base::PendingTask {
66 public: 66 public:
67 Task(); 67 Task();
68 Task(const tracked_objects::Location& posted_from, 68 Task(const tracked_objects::Location& posted_from,
69 const base::Closure& task, 69 base::OnceClosure task,
70 base::TimeTicks desired_run_time, 70 base::TimeTicks desired_run_time,
71 EnqueueOrder sequence_number, 71 EnqueueOrder sequence_number,
72 bool nestable); 72 bool nestable);
73 73
74 Task(const tracked_objects::Location& posted_from, 74 Task(const tracked_objects::Location& posted_from,
75 const base::Closure& task, 75 base::OnceClosure task,
76 base::TimeTicks desired_run_time, 76 base::TimeTicks desired_run_time,
77 EnqueueOrder sequence_number, 77 EnqueueOrder sequence_number,
78 bool nestable, 78 bool nestable,
79 EnqueueOrder enqueue_order); 79 EnqueueOrder enqueue_order);
80 80
81 EnqueueOrder enqueue_order() const { 81 EnqueueOrder enqueue_order() const {
82 #ifndef NDEBUG 82 #ifndef NDEBUG
83 DCHECK(enqueue_order_set_); 83 DCHECK(enqueue_order_set_);
84 #endif 84 #endif
85 return enqueue_order_; 85 return enqueue_order_;
(...skipping 20 matching lines...) Expand all
106 // is set when posted, but for delayed tasks it's not defined until they are 106 // is set when posted, but for delayed tasks it's not defined until they are
107 // enqueued on the |delayed_work_queue_|. This is because otherwise delayed 107 // enqueued on the |delayed_work_queue_|. This is because otherwise delayed
108 // tasks could run before an immediate task posted after the delayed task. 108 // tasks could run before an immediate task posted after the delayed task.
109 EnqueueOrder enqueue_order_; 109 EnqueueOrder enqueue_order_;
110 }; 110 };
111 111
112 // TaskQueue implementation. 112 // TaskQueue implementation.
113 void UnregisterTaskQueue() override; 113 void UnregisterTaskQueue() override;
114 bool RunsTasksOnCurrentThread() const override; 114 bool RunsTasksOnCurrentThread() const override;
115 bool PostDelayedTask(const tracked_objects::Location& from_here, 115 bool PostDelayedTask(const tracked_objects::Location& from_here,
116 const base::Closure& task, 116 base::OnceClosure task,
117 base::TimeDelta delay) override; 117 base::TimeDelta delay) override;
118 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 118 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
119 const base::Closure& task, 119 base::OnceClosure task,
120 base::TimeDelta delay) override; 120 base::TimeDelta delay) override;
121 void SetQueueEnabled(bool enabled) override; 121 void SetQueueEnabled(bool enabled) override;
122 bool IsQueueEnabled() const override; 122 bool IsQueueEnabled() const override;
123 bool IsEmpty() const override; 123 bool IsEmpty() const override;
124 bool HasPendingImmediateWork() const override; 124 bool HasPendingImmediateWork() const override;
125 void SetQueuePriority(QueuePriority priority) override; 125 void SetQueuePriority(QueuePriority priority) override;
126 QueuePriority GetQueuePriority() const override; 126 QueuePriority GetQueuePriority() const override;
127 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; 127 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
128 void RemoveTaskObserver( 128 void RemoveTaskObserver(
129 base::MessageLoop::TaskObserver* task_observer) override; 129 base::MessageLoop::TaskObserver* task_observer) override;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 base::ObserverList<base::MessageLoop::TaskObserver> task_observers; 215 base::ObserverList<base::MessageLoop::TaskObserver> task_observers;
216 size_t set_index; 216 size_t set_index;
217 bool is_enabled; 217 bool is_enabled;
218 base::trace_event::BlameContext* blame_context; // Not owned. 218 base::trace_event::BlameContext* blame_context; // Not owned.
219 EnqueueOrder current_fence; 219 EnqueueOrder current_fence;
220 }; 220 };
221 221
222 ~TaskQueueImpl() override; 222 ~TaskQueueImpl() override;
223 223
224 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, 224 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here,
225 const base::Closure& task, 225 base::OnceClosure task,
226 TaskType task_type); 226 TaskType task_type);
227 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, 227 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here,
228 const base::Closure& task, 228 base::OnceClosure task,
229 base::TimeDelta delay, 229 base::TimeDelta delay,
230 TaskType task_type); 230 TaskType task_type);
231 231
232 // Push the task onto the |delayed_incoming_queue|. Lock-free main thread 232 // Push the task onto the |delayed_incoming_queue|. Lock-free main thread
233 // only fast path. 233 // only fast path.
234 void PushOntoDelayedIncomingQueueFromMainThread(Task pending_task, 234 void PushOntoDelayedIncomingQueueFromMainThread(Task pending_task,
235 base::TimeTicks now); 235 base::TimeTicks now);
236 236
237 // Push the task onto the |delayed_incoming_queue|. Slow path from other 237 // Push the task onto the |delayed_incoming_queue|. Slow path from other
238 // threads. 238 // threads.
239 void PushOntoDelayedIncomingQueueLocked(Task pending_task); 239 void PushOntoDelayedIncomingQueueLocked(Task pending_task);
240 240
241 void ScheduleDelayedWorkTask(Task pending_task); 241 void ScheduleDelayedWorkTask(Task pending_task);
242 242
243 void MoveReadyImmediateTasksToImmediateWorkQueueLocked(); 243 void MoveReadyImmediateTasksToImmediateWorkQueueLocked();
244 244
245 // Push the task onto the |immediate_incoming_queue| and for auto pumped 245 // Push the task onto the |immediate_incoming_queue| and for auto pumped
246 // queues it calls MaybePostDoWorkOnMainRunner if the Incoming queue was 246 // queues it calls MaybePostDoWorkOnMainRunner if the Incoming queue was
247 // empty. 247 // empty.
248 void PushOntoImmediateIncomingQueueLocked( 248 void PushOntoImmediateIncomingQueueLocked(
249 const tracked_objects::Location& posted_from, 249 const tracked_objects::Location& posted_from,
250 const base::Closure& task, 250 base::OnceClosure task,
251 base::TimeTicks desired_run_time, 251 base::TimeTicks desired_run_time,
252 EnqueueOrder sequence_number, 252 EnqueueOrder sequence_number,
253 bool nestable); 253 bool nestable);
254 254
255 // As BlockedByFence but safe to be called while locked. 255 // As BlockedByFence but safe to be called while locked.
256 bool BlockedByFenceLocked() const; 256 bool BlockedByFenceLocked() const;
257 257
258 void TraceQueueSize(bool is_locked) const; 258 void TraceQueueSize(bool is_locked) const;
259 static void QueueAsValueInto(const std::queue<Task>& queue, 259 static void QueueAsValueInto(const std::queue<Task>& queue,
260 base::trace_event::TracedValue* state); 260 base::trace_event::TracedValue* state);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 const bool should_report_when_execution_blocked_; 296 const bool should_report_when_execution_blocked_;
297 297
298 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); 298 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl);
299 }; 299 };
300 300
301 } // namespace internal 301 } // namespace internal
302 } // namespace scheduler 302 } // namespace scheduler
303 } // namespace blink 303 } // namespace blink
304 304
305 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 305 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698