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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 void IncomingTaskQueue::StartScheduling() { | 113 void IncomingTaskQueue::StartScheduling() { |
114 AutoLock lock(incoming_queue_lock_); | 114 AutoLock lock(incoming_queue_lock_); |
115 DCHECK(!is_ready_for_scheduling_); | 115 DCHECK(!is_ready_for_scheduling_); |
116 DCHECK(!message_loop_scheduled_); | 116 DCHECK(!message_loop_scheduled_); |
117 is_ready_for_scheduling_ = true; | 117 is_ready_for_scheduling_ = true; |
118 if (!incoming_queue_.empty()) | 118 if (!incoming_queue_.empty()) |
119 ScheduleWork(); | 119 ScheduleWork(); |
120 } | 120 } |
121 | 121 |
| 122 TimeTicks IncomingTaskQueue::GetNewlyAddedTaskDelay() { |
| 123 return !incoming_queue_.empty() ? incoming_queue_.front().delayed_run_time : |
| 124 TimeTicks(); |
| 125 } |
| 126 |
122 IncomingTaskQueue::~IncomingTaskQueue() { | 127 IncomingTaskQueue::~IncomingTaskQueue() { |
123 // Verify that WillDestroyCurrentMessageLoop() has been called. | 128 // Verify that WillDestroyCurrentMessageLoop() has been called. |
124 DCHECK(!message_loop_); | 129 DCHECK(!message_loop_); |
125 } | 130 } |
126 | 131 |
127 TimeTicks IncomingTaskQueue::CalculateDelayedRuntime(TimeDelta delay) { | 132 TimeTicks IncomingTaskQueue::CalculateDelayedRuntime(TimeDelta delay) { |
128 TimeTicks delayed_run_time; | 133 TimeTicks delayed_run_time; |
129 if (delay > TimeDelta()) | 134 if (delay > TimeDelta()) |
130 delayed_run_time = TimeTicks::Now() + delay; | 135 delayed_run_time = TimeTicks::Now() + delay; |
131 else | 136 else |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // After we've scheduled the message loop, we do not need to do so again | 178 // 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 | 179 // 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 | 180 // 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 | 181 // reload from the incoming queue before waiting again so we clear this flag |
177 // in ReloadWorkQueue(). | 182 // in ReloadWorkQueue(). |
178 message_loop_scheduled_ = true; | 183 message_loop_scheduled_ = true; |
179 } | 184 } |
180 | 185 |
181 } // namespace internal | 186 } // namespace internal |
182 } // namespace base | 187 } // namespace base |
OLD | NEW |