| OLD | NEW |
| 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 CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 6 #define CONTENT_RENDERER_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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, | 213 bool PostImmediateTaskImpl(const tracked_objects::Location& from_here, |
| 214 const base::Closure& task, | 214 const base::Closure& task, |
| 215 TaskType task_type); | 215 TaskType task_type); |
| 216 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, | 216 bool PostDelayedTaskImpl(const tracked_objects::Location& from_here, |
| 217 const base::Closure& task, | 217 const base::Closure& task, |
| 218 base::TimeDelta delay, | 218 base::TimeDelta delay, |
| 219 TaskType task_type); | 219 TaskType task_type); |
| 220 | 220 |
| 221 // Push the task onto the |delayed_incoming_queue|. Lock-free main thread | 221 // Push the task onto the |delayed_incoming_queue|. Lock-free main thread |
| 222 // only fast path. | 222 // only fast path. |
| 223 void PushOntoDelayedIncomingQueueFromMainThread(const Task& pending_task, | 223 void PushOntoDelayedIncomingQueueFromMainThread(Task pending_task, |
| 224 base::TimeTicks now); | 224 base::TimeTicks now); |
| 225 | 225 |
| 226 // Push the task onto the |delayed_incoming_queue|. Slow path from other | 226 // Push the task onto the |delayed_incoming_queue|. Slow path from other |
| 227 // threads. | 227 // threads. |
| 228 void PushOntoDelayedIncomingQueueLocked(const Task& pending_task); | 228 void PushOntoDelayedIncomingQueueLocked(Task pending_task); |
| 229 | 229 |
| 230 void ScheduleDelayedWorkTask(const Task& pending_task); | 230 void ScheduleDelayedWorkTask(Task pending_task); |
| 231 | 231 |
| 232 // Enqueues any delayed tasks which should be run now on the | 232 // Enqueues any delayed tasks which should be run now on the |
| 233 // |delayed_work_queue|. Must be called from the main thread. | 233 // |delayed_work_queue|. Must be called from the main thread. |
| 234 void MoveReadyDelayedTasksToDelayedWorkQueue(LazyNow* lazy_now); | 234 void MoveReadyDelayedTasksToDelayedWorkQueue(LazyNow* lazy_now); |
| 235 | 235 |
| 236 void MoveReadyImmediateTasksToImmediateWorkQueueLocked(); | 236 void MoveReadyImmediateTasksToImmediateWorkQueueLocked(); |
| 237 | 237 |
| 238 // Note this does nothing if its not called from the main thread. | 238 // Note this does nothing if its not called from the main thread. |
| 239 void PumpQueueLocked(bool may_post_dowork); | 239 void PumpQueueLocked(bool may_post_dowork); |
| 240 | 240 |
| 241 // Returns true if |task| is older than the oldest incoming immediate task. | 241 // Returns true if |task| is older than the oldest incoming immediate task. |
| 242 // NOTE |any_thread_lock_| must be locked. | 242 // NOTE |any_thread_lock_| must be locked. |
| 243 bool TaskIsOlderThanQueuedImmediateTasksLocked(const Task* task); | 243 bool TaskIsOlderThanQueuedImmediateTasksLocked(const Task* task); |
| 244 | 244 |
| 245 // Returns true if |task| is older than the oldest delayed task. Must be | 245 // Returns true if |task| is older than the oldest delayed task. Must be |
| 246 // called from the main thread. | 246 // called from the main thread. |
| 247 bool TaskIsOlderThanQueuedDelayedTasks(const Task* task); | 247 bool TaskIsOlderThanQueuedDelayedTasks(const Task* task); |
| 248 | 248 |
| 249 // NOTE |any_thread_lock_| must be locked. | 249 // NOTE |any_thread_lock_| must be locked. |
| 250 bool ShouldAutoPumpImmediateQueueLocked(bool should_trigger_wakeup, | 250 bool ShouldAutoPumpImmediateQueueLocked(bool should_trigger_wakeup, |
| 251 const Task* previous_task); | 251 const Task* previous_task); |
| 252 | 252 |
| 253 // Must be called from the main thread. | 253 // Must be called from the main thread. |
| 254 bool ShouldAutoPumpDelayedQueue(bool should_trigger_wakeup, | 254 bool ShouldAutoPumpDelayedQueue(bool should_trigger_wakeup, |
| 255 const Task* previous_task); | 255 const Task* previous_task); |
| 256 | 256 |
| 257 // Push the task onto the |immediate_incoming_queue| and for auto pumped | 257 // Push the task onto the |immediate_incoming_queue| and for auto pumped |
| 258 // queues it calls MaybePostDoWorkOnMainRunner if the Incoming queue was | 258 // queues it calls MaybePostDoWorkOnMainRunner if the Incoming queue was |
| 259 // empty. | 259 // empty. |
| 260 void PushOntoImmediateIncomingQueueLocked(const Task& pending_task); | 260 void PushOntoImmediateIncomingQueueLocked(Task pending_task); |
| 261 | 261 |
| 262 void TraceQueueSize(bool is_locked) const; | 262 void TraceQueueSize(bool is_locked) const; |
| 263 static void QueueAsValueInto(const std::queue<Task>& queue, | 263 static void QueueAsValueInto(const std::queue<Task>& queue, |
| 264 base::trace_event::TracedValue* state); | 264 base::trace_event::TracedValue* state); |
| 265 static void QueueAsValueInto(const std::priority_queue<Task>& queue, | 265 static void QueueAsValueInto(const std::priority_queue<Task>& queue, |
| 266 base::trace_event::TracedValue* state); | 266 base::trace_event::TracedValue* state); |
| 267 static void TaskAsValueInto(const Task& task, | 267 static void TaskAsValueInto(const Task& task, |
| 268 base::trace_event::TracedValue* state); | 268 base::trace_event::TracedValue* state); |
| 269 | 269 |
| 270 const base::PlatformThreadId thread_id_; | 270 const base::PlatformThreadId thread_id_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 300 const bool should_notify_observers_; | 300 const bool should_notify_observers_; |
| 301 const bool should_report_when_execution_blocked_; | 301 const bool should_report_when_execution_blocked_; |
| 302 | 302 |
| 303 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); | 303 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 } // namespace internal | 306 } // namespace internal |
| 307 } // namespace scheduler | 307 } // namespace scheduler |
| 308 | 308 |
| 309 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ | 309 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ |
| OLD | NEW |