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