| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "base/message_loop/incoming_task_queue.h" | 5 #include "base/message_loop/incoming_task_queue.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | |
| 8 #include "base/location.h" | 7 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 10 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 11 | 10 |
| 12 namespace base { | 11 namespace base { |
| 13 namespace internal { | 12 namespace internal { |
| 14 | 13 |
| 15 IncomingTaskQueue::IncomingTaskQueue(MessageLoop* message_loop) | 14 IncomingTaskQueue::IncomingTaskQueue(MessageLoop* message_loop) |
| 16 : message_loop_(message_loop), | 15 : message_loop_(message_loop), |
| 17 next_sequence_num_(0) { | 16 next_sequence_num_(0) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (!message_loop_) { | 122 if (!message_loop_) { |
| 124 pending_task->task.Reset(); | 123 pending_task->task.Reset(); |
| 125 return false; | 124 return false; |
| 126 } | 125 } |
| 127 | 126 |
| 128 // Initialize the sequence number. The sequence number is used for delayed | 127 // Initialize the sequence number. The sequence number is used for delayed |
| 129 // tasks (to faciliate FIFO sorting when two tasks have the same | 128 // tasks (to faciliate FIFO sorting when two tasks have the same |
| 130 // delayed_run_time value) and for identifying the task in about:tracing. | 129 // delayed_run_time value) and for identifying the task in about:tracing. |
| 131 pending_task->sequence_num = next_sequence_num_++; | 130 pending_task->sequence_num = next_sequence_num_++; |
| 132 | 131 |
| 133 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), | 132 message_loop_->task_annotator()->DidQueueTask("MessageLoop::PostTask", |
| 134 "MessageLoop::PostTask", | 133 *pending_task); |
| 135 TRACE_ID_MANGLE(message_loop_->GetTaskTraceID(*pending_task))); | |
| 136 | 134 |
| 137 bool was_empty = incoming_queue_.empty(); | 135 bool was_empty = incoming_queue_.empty(); |
| 138 incoming_queue_.push(*pending_task); | 136 incoming_queue_.push(*pending_task); |
| 139 pending_task->task.Reset(); | 137 pending_task->task.Reset(); |
| 140 | 138 |
| 141 // Wake up the pump. | 139 // Wake up the pump. |
| 142 message_loop_->ScheduleWork(was_empty); | 140 message_loop_->ScheduleWork(was_empty); |
| 143 | 141 |
| 144 return true; | 142 return true; |
| 145 } | 143 } |
| 146 | 144 |
| 147 } // namespace internal | 145 } // namespace internal |
| 148 } // namespace base | 146 } // namespace base |
| OLD | NEW |