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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 // This should only be called while the lock is taken. | 141 // This should only be called while the lock is taken. |
142 incoming_queue_lock_.AssertAcquired(); | 142 incoming_queue_lock_.AssertAcquired(); |
143 | 143 |
144 if (!message_loop_) { | 144 if (!message_loop_) { |
145 pending_task->task.Reset(); | 145 pending_task->task.Reset(); |
146 return false; | 146 return false; |
147 } | 147 } |
148 | 148 |
149 // Initialize the sequence number. The sequence number is used for delayed | 149 // Initialize the sequence number. The sequence number is used for delayed |
150 // tasks (to faciliate FIFO sorting when two tasks have the same | 150 // tasks (to facilitate FIFO sorting when two tasks have the same |
151 // delayed_run_time value) and for identifying the task in about:tracing. | 151 // delayed_run_time value) and for identifying the task in about:tracing. |
152 pending_task->sequence_num = next_sequence_num_++; | 152 pending_task->sequence_num = next_sequence_num_++; |
153 | 153 |
154 message_loop_->task_annotator()->DidQueueTask("MessageLoop::PostTask", | 154 message_loop_->task_annotator()->DidQueueTask("MessageLoop::PostTask", |
155 *pending_task); | 155 *pending_task); |
156 | 156 |
157 bool was_empty = incoming_queue_.empty(); | 157 bool was_empty = incoming_queue_.empty(); |
158 incoming_queue_.push(*pending_task); | 158 incoming_queue_.push(*pending_task); |
159 pending_task->task.Reset(); | 159 pending_task->task.Reset(); |
160 | 160 |
(...skipping 12 matching lines...) Expand all Loading... |
173 // After we've scheduled the message loop, we do not need to do so again | 173 // After we've scheduled the message loop, we do not need to do so again |
174 // until we know it has processed all of the work in our queue and is | 174 // until we know it has processed all of the work in our queue and is |
175 // waiting for more work again. The message loop will always attempt to | 175 // waiting for more work again. The message loop will always attempt to |
176 // reload from the incoming queue before waiting again so we clear this flag | 176 // reload from the incoming queue before waiting again so we clear this flag |
177 // in ReloadWorkQueue(). | 177 // in ReloadWorkQueue(). |
178 message_loop_scheduled_ = true; | 178 message_loop_scheduled_ = true; |
179 } | 179 } |
180 | 180 |
181 } // namespace internal | 181 } // namespace internal |
182 } // namespace base | 182 } // namespace base |
OLD | NEW |