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 #include "components/scheduler/child/task_queue_impl.h" | 5 #include "components/scheduler/child/task_queue_impl.h" |
6 | 6 |
7 #include "components/scheduler/child/task_queue_manager.h" | 7 #include "components/scheduler/child/task_queue_manager.h" |
8 | 8 |
9 namespace scheduler { | 9 namespace scheduler { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 TaskQueueImpl::TaskQueueImpl( | 12 TaskQueueImpl::TaskQueueImpl( |
13 TaskQueueManager* task_queue_manager, | 13 TaskQueueManager* task_queue_manager, |
14 const Spec& spec, | 14 const Spec& spec, |
15 const char* disabled_by_default_tracing_category, | 15 const char* disabled_by_default_tracing_category, |
16 const char* disabled_by_default_verbose_tracing_category) | 16 const char* disabled_by_default_verbose_tracing_category) |
17 : thread_id_(base::PlatformThread::CurrentId()), | 17 : thread_id_(base::PlatformThread::CurrentId()), |
18 task_queue_manager_(task_queue_manager), | 18 task_queue_manager_(task_queue_manager), |
19 pump_policy_(spec.pump_policy), | 19 pump_policy_(spec.pump_policy), |
20 delayed_task_sequence_number_(0), | |
21 name_(spec.name), | 20 name_(spec.name), |
22 disabled_by_default_tracing_category_( | 21 disabled_by_default_tracing_category_( |
23 disabled_by_default_tracing_category), | 22 disabled_by_default_tracing_category), |
24 disabled_by_default_verbose_tracing_category_( | 23 disabled_by_default_verbose_tracing_category_( |
25 disabled_by_default_verbose_tracing_category), | 24 disabled_by_default_verbose_tracing_category), |
26 wakeup_policy_(spec.wakeup_policy), | 25 wakeup_policy_(spec.wakeup_policy), |
27 set_index_(0), | 26 set_index_(0), |
28 should_monitor_quiescence_(spec.should_monitor_quiescence), | 27 should_monitor_quiescence_(spec.should_monitor_quiescence), |
29 should_notify_observers_(spec.should_notify_observers) {} | 28 should_notify_observers_(spec.should_notify_observers) {} |
30 | 29 |
31 TaskQueueImpl::~TaskQueueImpl() {} | 30 TaskQueueImpl::~TaskQueueImpl() {} |
32 | 31 |
32 TaskQueueImpl::Task::Task(const tracked_objects::Location& posted_from, | |
33 const base::Closure& task, | |
34 int sequence_number, | |
35 bool nestable) | |
36 : PendingTask(posted_from, task, base::TimeTicks(), nestable), | |
37 enqueue_order(0) { | |
38 sequence_num = sequence_number; | |
39 } | |
40 | |
33 void TaskQueueImpl::WillDeleteTaskQueueManager() { | 41 void TaskQueueImpl::WillDeleteTaskQueueManager() { |
34 base::AutoLock lock(lock_); | 42 base::AutoLock lock(lock_); |
35 task_queue_manager_ = nullptr; | 43 task_queue_manager_ = nullptr; |
36 delayed_task_queue_ = base::DelayedTaskQueue(); | 44 delayed_task_queue_ = std::priority_queue<Task>(); |
37 incoming_queue_ = base::TaskQueue(); | 45 incoming_queue_ = std::queue<Task>(); |
38 work_queue_ = base::TaskQueue(); | 46 work_queue_ = std::queue<Task>(); |
39 } | 47 } |
40 | 48 |
41 bool TaskQueueImpl::RunsTasksOnCurrentThread() const { | 49 bool TaskQueueImpl::RunsTasksOnCurrentThread() const { |
42 base::AutoLock lock(lock_); | 50 base::AutoLock lock(lock_); |
43 return base::PlatformThread::CurrentId() == thread_id_; | 51 return base::PlatformThread::CurrentId() == thread_id_; |
44 } | 52 } |
45 | 53 |
46 bool TaskQueueImpl::PostDelayedTask(const tracked_objects::Location& from_here, | 54 bool TaskQueueImpl::PostDelayedTask(const tracked_objects::Location& from_here, |
47 const base::Closure& task, | 55 const base::Closure& task, |
48 base::TimeDelta delay) { | 56 base::TimeDelta delay) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 } | 93 } |
86 | 94 |
87 bool TaskQueueImpl::PostDelayedTaskLocked( | 95 bool TaskQueueImpl::PostDelayedTaskLocked( |
88 LazyNow* lazy_now, | 96 LazyNow* lazy_now, |
89 const tracked_objects::Location& from_here, | 97 const tracked_objects::Location& from_here, |
90 const base::Closure& task, | 98 const base::Closure& task, |
91 base::TimeTicks desired_run_time, | 99 base::TimeTicks desired_run_time, |
92 TaskType task_type) { | 100 TaskType task_type) { |
93 lock_.AssertAcquired(); | 101 lock_.AssertAcquired(); |
94 DCHECK(task_queue_manager_); | 102 DCHECK(task_queue_manager_); |
95 | 103 Task pending_task(from_here, task, |
96 base::PendingTask pending_task(from_here, task, base::TimeTicks(), | 104 task_queue_manager_->GetNextSequenceNumber(), |
Sami
2015/08/05 14:51:15
Is the indentation right here?
alex clarke (OOO till 29th)
2015/08/05 15:33:05
Done.
| |
97 task_type != TaskType::NON_NESTABLE); | 105 task_type != TaskType::NON_NESTABLE); |
98 task_queue_manager_->DidQueueTask(pending_task); | 106 task_queue_manager_->DidQueueTask(pending_task); |
99 | 107 |
100 if (!desired_run_time.is_null()) { | 108 if (!desired_run_time.is_null()) { |
101 pending_task.delayed_run_time = std::max(lazy_now->Now(), desired_run_time); | 109 pending_task.delayed_run_time = std::max(lazy_now->Now(), desired_run_time); |
102 pending_task.sequence_num = delayed_task_sequence_number_++; | 110 // TODO(alexclarke): consider emplace() when C++11 library features allowed. |
103 delayed_task_queue_.push(pending_task); | 111 delayed_task_queue_.push(pending_task); |
104 TraceQueueSize(true); | 112 TraceQueueSize(true); |
105 // If we changed the topmost task, then it is time to reschedule. | 113 // If we changed the topmost task, then it is time to reschedule. |
106 if (delayed_task_queue_.top().task.Equals(pending_task.task)) | 114 if (delayed_task_queue_.top().task.Equals(pending_task.task)) |
107 ScheduleDelayedWorkLocked(lazy_now); | 115 ScheduleDelayedWorkLocked(lazy_now); |
108 return true; | 116 return true; |
109 } | 117 } |
110 EnqueueTaskLocked(pending_task); | 118 pending_task.enqueue_order = pending_task.sequence_num; |
119 EnqueueTaskLocked(pending_task, EnqueueOrderPolicy::DONT_SET_ENQUEUE_ORDER); | |
111 return true; | 120 return true; |
112 } | 121 } |
113 | 122 |
114 void TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue() { | 123 void TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue() { |
115 DCHECK(main_thread_checker_.CalledOnValidThread()); | 124 DCHECK(main_thread_checker_.CalledOnValidThread()); |
116 base::AutoLock lock(lock_); | 125 base::AutoLock lock(lock_); |
117 if (!task_queue_manager_) | 126 if (!task_queue_manager_) |
118 return; | 127 return; |
119 | 128 |
120 LazyNow lazy_now(task_queue_manager_); | 129 LazyNow lazy_now(task_queue_manager_); |
121 MoveReadyDelayedTasksToIncomingQueueLocked(&lazy_now); | 130 MoveReadyDelayedTasksToIncomingQueueLocked(&lazy_now); |
122 } | 131 } |
123 | 132 |
124 void TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueueLocked( | 133 void TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueueLocked( |
125 LazyNow* lazy_now) { | 134 LazyNow* lazy_now) { |
126 lock_.AssertAcquired(); | 135 lock_.AssertAcquired(); |
127 // Enqueue all delayed tasks that should be running now. | 136 // Enqueue all delayed tasks that should be running now. |
128 while (!delayed_task_queue_.empty() && | 137 while (!delayed_task_queue_.empty() && |
129 delayed_task_queue_.top().delayed_run_time <= lazy_now->Now()) { | 138 delayed_task_queue_.top().delayed_run_time <= lazy_now->Now()) { |
130 in_flight_kick_delayed_tasks_.erase( | 139 in_flight_kick_delayed_tasks_.erase( |
131 delayed_task_queue_.top().delayed_run_time); | 140 delayed_task_queue_.top().delayed_run_time); |
132 EnqueueTaskLocked(delayed_task_queue_.top()); | 141 // TODO(alexclarke): consider std::move() when allowed. |
142 EnqueueTaskLocked(delayed_task_queue_.top(), | |
143 EnqueueOrderPolicy::SET_ENQUEUE_ORDER); | |
133 delayed_task_queue_.pop(); | 144 delayed_task_queue_.pop(); |
134 } | 145 } |
135 TraceQueueSize(true); | 146 TraceQueueSize(true); |
136 ScheduleDelayedWorkLocked(lazy_now); | 147 ScheduleDelayedWorkLocked(lazy_now); |
137 } | 148 } |
138 | 149 |
139 void TaskQueueImpl::ScheduleDelayedWorkLocked(LazyNow* lazy_now) { | 150 void TaskQueueImpl::ScheduleDelayedWorkLocked(LazyNow* lazy_now) { |
140 lock_.AssertAcquired(); | 151 lock_.AssertAcquired(); |
141 // Any remaining tasks are in the future, so queue a task to kick them. | 152 // Any remaining tasks are in the future, so queue a task to kick them. |
142 if (!delayed_task_queue_.empty()) { | 153 if (!delayed_task_queue_.empty()) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 // A null task is passed when UpdateQueue is called before any task is run. | 197 // A null task is passed when UpdateQueue is called before any task is run. |
187 // In this case we don't want to pump an after_wakeup queue, so return true | 198 // In this case we don't want to pump an after_wakeup queue, so return true |
188 // here. | 199 // here. |
189 if (!task) | 200 if (!task) |
190 return true; | 201 return true; |
191 | 202 |
192 // Return false if there are no task in the incoming queue. | 203 // Return false if there are no task in the incoming queue. |
193 if (incoming_queue_.empty()) | 204 if (incoming_queue_.empty()) |
194 return false; | 205 return false; |
195 | 206 |
196 base::PendingTask oldest_queued_task = incoming_queue_.front(); | 207 const TaskQueueImpl::Task& oldest_queued_task = incoming_queue_.front(); |
197 DCHECK(oldest_queued_task.delayed_run_time.is_null()); | 208 return task->sequence_num < oldest_queued_task.sequence_num; |
Sami
2015/08/05 14:51:14
Isn't this where we should look at the enqueue_ord
alex clarke (OOO till 29th)
2015/08/05 15:33:05
Done.
| |
198 DCHECK(task->delayed_run_time.is_null()); | |
199 | |
200 // Note: the comparison is correct due to the fact that the PendingTask | |
201 // operator inverts its comparison operation in order to work well in a heap | |
202 // based priority queue. | |
203 return oldest_queued_task < *task; | |
204 } | 209 } |
205 | 210 |
206 bool TaskQueueImpl::ShouldAutoPumpQueueLocked( | 211 bool TaskQueueImpl::ShouldAutoPumpQueueLocked( |
207 bool should_trigger_wakeup, | 212 bool should_trigger_wakeup, |
208 const base::PendingTask* previous_task) { | 213 const base::PendingTask* previous_task) { |
209 lock_.AssertAcquired(); | 214 lock_.AssertAcquired(); |
210 if (pump_policy_ == PumpPolicy::MANUAL) | 215 if (pump_policy_ == PumpPolicy::MANUAL) |
211 return false; | 216 return false; |
212 if (pump_policy_ == PumpPolicy::AFTER_WAKEUP && | 217 if (pump_policy_ == PumpPolicy::AFTER_WAKEUP && |
213 (!should_trigger_wakeup || TaskIsOlderThanQueuedTasks(previous_task))) | 218 (!should_trigger_wakeup || TaskIsOlderThanQueuedTasks(previous_task))) |
(...skipping 13 matching lines...) Expand all Loading... | |
227 } | 232 } |
228 | 233 |
229 void TaskQueueImpl::UpdateWorkQueue(LazyNow* lazy_now, | 234 void TaskQueueImpl::UpdateWorkQueue(LazyNow* lazy_now, |
230 bool should_trigger_wakeup, | 235 bool should_trigger_wakeup, |
231 const base::PendingTask* previous_task) { | 236 const base::PendingTask* previous_task) { |
232 DCHECK(work_queue_.empty()); | 237 DCHECK(work_queue_.empty()); |
233 base::AutoLock lock(lock_); | 238 base::AutoLock lock(lock_); |
234 if (!ShouldAutoPumpQueueLocked(should_trigger_wakeup, previous_task)) | 239 if (!ShouldAutoPumpQueueLocked(should_trigger_wakeup, previous_task)) |
235 return; | 240 return; |
236 MoveReadyDelayedTasksToIncomingQueueLocked(lazy_now); | 241 MoveReadyDelayedTasksToIncomingQueueLocked(lazy_now); |
237 work_queue_.Swap(&incoming_queue_); | 242 std::swap(work_queue_, incoming_queue_); |
238 // |incoming_queue_| is now empty so TaskQueueManager::UpdateQueues no | 243 // |incoming_queue_| is now empty so TaskQueueManager::UpdateQueues no |
239 // longer needs to consider this queue for reloading. | 244 // longer needs to consider this queue for reloading. |
240 task_queue_manager_->UnregisterAsUpdatableTaskQueue(this); | 245 task_queue_manager_->UnregisterAsUpdatableTaskQueue(this); |
241 if (!work_queue_.empty()) { | 246 if (!work_queue_.empty()) { |
242 DCHECK(task_queue_manager_); | 247 DCHECK(task_queue_manager_); |
243 task_queue_manager_->selector_.GetTaskQueueSets()->OnPushQueue(this); | 248 task_queue_manager_->selector_.GetTaskQueueSets()->OnPushQueue(this); |
244 TraceQueueSize(true); | 249 TraceQueueSize(true); |
245 } | 250 } |
246 } | 251 } |
247 | 252 |
248 base::PendingTask TaskQueueImpl::TakeTaskFromWorkQueue() { | 253 TaskQueueImpl::Task TaskQueueImpl::TakeTaskFromWorkQueue() { |
249 base::PendingTask pending_task = work_queue_.front(); | 254 // TODO(alexclarke): consider std::move() when allowed. |
255 Task pending_task = work_queue_.front(); | |
250 work_queue_.pop(); | 256 work_queue_.pop(); |
251 DCHECK(task_queue_manager_); | 257 DCHECK(task_queue_manager_); |
252 task_queue_manager_->selector_.GetTaskQueueSets()->OnPopQueue(this); | 258 task_queue_manager_->selector_.GetTaskQueueSets()->OnPopQueue(this); |
253 TraceQueueSize(false); | 259 TraceQueueSize(false); |
254 return pending_task; | 260 return pending_task; |
255 } | 261 } |
256 | 262 |
257 void TaskQueueImpl::TraceQueueSize(bool is_locked) const { | 263 void TaskQueueImpl::TraceQueueSize(bool is_locked) const { |
258 bool is_tracing; | 264 bool is_tracing; |
259 TRACE_EVENT_CATEGORY_GROUP_ENABLED(disabled_by_default_tracing_category_, | 265 TRACE_EVENT_CATEGORY_GROUP_ENABLED(disabled_by_default_tracing_category_, |
260 &is_tracing); | 266 &is_tracing); |
261 if (!is_tracing) | 267 if (!is_tracing) |
262 return; | 268 return; |
263 if (!is_locked) | 269 if (!is_locked) |
264 lock_.Acquire(); | 270 lock_.Acquire(); |
265 else | 271 else |
266 lock_.AssertAcquired(); | 272 lock_.AssertAcquired(); |
267 TRACE_COUNTER1( | 273 TRACE_COUNTER1( |
268 disabled_by_default_tracing_category_, GetName(), | 274 disabled_by_default_tracing_category_, GetName(), |
269 incoming_queue_.size() + work_queue_.size() + delayed_task_queue_.size()); | 275 incoming_queue_.size() + work_queue_.size() + delayed_task_queue_.size()); |
270 if (!is_locked) | 276 if (!is_locked) |
271 lock_.Release(); | 277 lock_.Release(); |
272 } | 278 } |
273 | 279 |
274 void TaskQueueImpl::EnqueueTaskLocked(const base::PendingTask& pending_task) { | 280 void TaskQueueImpl::EnqueueTaskLocked(const Task& pending_task, |
281 EnqueueOrderPolicy enqueue_order_policy) { | |
275 lock_.AssertAcquired(); | 282 lock_.AssertAcquired(); |
276 if (!task_queue_manager_) | 283 if (!task_queue_manager_) |
277 return; | 284 return; |
278 if (incoming_queue_.empty()) | 285 if (incoming_queue_.empty()) |
279 task_queue_manager_->RegisterAsUpdatableTaskQueue(this); | 286 task_queue_manager_->RegisterAsUpdatableTaskQueue(this); |
280 if (pump_policy_ == PumpPolicy::AUTO && incoming_queue_.empty()) | 287 if (pump_policy_ == PumpPolicy::AUTO && incoming_queue_.empty()) |
281 task_queue_manager_->MaybePostDoWorkOnMainRunner(); | 288 task_queue_manager_->MaybePostDoWorkOnMainRunner(); |
289 // TODO(alexclarke): consider std::move() when allowed. | |
282 incoming_queue_.push(pending_task); | 290 incoming_queue_.push(pending_task); |
283 incoming_queue_.back().sequence_num = | 291 if (enqueue_order_policy == EnqueueOrderPolicy::SET_ENQUEUE_ORDER) { |
284 task_queue_manager_->GetNextSequenceNumber(); | 292 incoming_queue_.back().enqueue_order = |
285 | 293 task_queue_manager_->GetNextSequenceNumber(); |
286 if (!pending_task.delayed_run_time.is_null()) { | |
287 // Clear the delayed run time because we've already applied the delay | |
288 // before getting here. | |
289 incoming_queue_.back().delayed_run_time = base::TimeTicks(); | |
290 } | 294 } |
291 TraceQueueSize(true); | 295 TraceQueueSize(true); |
292 } | 296 } |
293 | 297 |
294 void TaskQueueImpl::SetPumpPolicy(PumpPolicy pump_policy) { | 298 void TaskQueueImpl::SetPumpPolicy(PumpPolicy pump_policy) { |
295 base::AutoLock lock(lock_); | 299 base::AutoLock lock(lock_); |
296 if (pump_policy == PumpPolicy::AUTO && pump_policy_ != PumpPolicy::AUTO) { | 300 if (pump_policy == PumpPolicy::AUTO && pump_policy_ != PumpPolicy::AUTO) { |
297 PumpQueueLocked(); | 301 PumpQueueLocked(); |
298 } | 302 } |
299 pump_policy_ = pump_policy; | 303 pump_policy_ = pump_policy; |
300 } | 304 } |
301 | 305 |
302 void TaskQueueImpl::PumpQueueLocked() { | 306 void TaskQueueImpl::PumpQueueLocked() { |
303 lock_.AssertAcquired(); | 307 lock_.AssertAcquired(); |
304 if (!task_queue_manager_) | 308 if (!task_queue_manager_) |
305 return; | 309 return; |
306 | 310 |
307 LazyNow lazy_now(task_queue_manager_); | 311 LazyNow lazy_now(task_queue_manager_); |
308 MoveReadyDelayedTasksToIncomingQueueLocked(&lazy_now); | 312 MoveReadyDelayedTasksToIncomingQueueLocked(&lazy_now); |
309 | 313 |
310 bool was_empty = work_queue_.empty(); | 314 bool was_empty = work_queue_.empty(); |
311 while (!incoming_queue_.empty()) { | 315 while (!incoming_queue_.empty()) { |
316 // TODO(alexclarke): consider std::move() when allowed. | |
312 work_queue_.push(incoming_queue_.front()); | 317 work_queue_.push(incoming_queue_.front()); |
313 incoming_queue_.pop(); | 318 incoming_queue_.pop(); |
314 } | 319 } |
315 // |incoming_queue_| is now empty so TaskQueueManager::UpdateQueues no longer | 320 // |incoming_queue_| is now empty so TaskQueueManager::UpdateQueues no longer |
316 // needs to consider this queue for reloading. | 321 // needs to consider this queue for reloading. |
317 task_queue_manager_->UnregisterAsUpdatableTaskQueue(this); | 322 task_queue_manager_->UnregisterAsUpdatableTaskQueue(this); |
318 if (!work_queue_.empty()) { | 323 if (!work_queue_.empty()) { |
319 if (was_empty) | 324 if (was_empty) |
320 task_queue_manager_->selector_.GetTaskQueueSets()->OnPushQueue(this); | 325 task_queue_manager_->selector_.GetTaskQueueSets()->OnPushQueue(this); |
321 task_queue_manager_->MaybePostDoWorkOnMainRunner(); | 326 task_queue_manager_->MaybePostDoWorkOnMainRunner(); |
322 } | 327 } |
323 } | 328 } |
324 | 329 |
325 void TaskQueueImpl::PumpQueue() { | 330 void TaskQueueImpl::PumpQueue() { |
326 base::AutoLock lock(lock_); | 331 base::AutoLock lock(lock_); |
327 PumpQueueLocked(); | 332 PumpQueueLocked(); |
328 } | 333 } |
329 | 334 |
330 const char* TaskQueueImpl::GetName() const { | 335 const char* TaskQueueImpl::GetName() const { |
331 return name_; | 336 return name_; |
332 } | 337 } |
333 | 338 |
334 bool TaskQueueImpl::GetWorkQueueFrontTaskAge(int* age) const { | 339 bool TaskQueueImpl::GetWorkQueueFrontTaskEnqueueOrder( |
340 int* enqueue_order) const { | |
335 if (work_queue_.empty()) | 341 if (work_queue_.empty()) |
336 return false; | 342 return false; |
337 *age = work_queue_.front().sequence_num; | 343 *enqueue_order = work_queue_.front().enqueue_order; |
338 return true; | 344 return true; |
339 } | 345 } |
340 | 346 |
341 void TaskQueueImpl::PushTaskOntoWorkQueueForTest( | 347 void TaskQueueImpl::PushTaskOntoWorkQueueForTest(const Task& task) { |
342 const base::PendingTask& task) { | |
343 work_queue_.push(task); | 348 work_queue_.push(task); |
344 } | 349 } |
345 | 350 |
346 void TaskQueueImpl::PopTaskFromWorkQueueForTest() { | 351 void TaskQueueImpl::PopTaskFromWorkQueueForTest() { |
347 work_queue_.pop(); | 352 work_queue_.pop(); |
348 } | 353 } |
349 | 354 |
350 void TaskQueueImpl::SetQueuePriority(QueuePriority priority) { | 355 void TaskQueueImpl::SetQueuePriority(QueuePriority priority) { |
351 DCHECK(main_thread_checker_.CalledOnValidThread()); | 356 DCHECK(main_thread_checker_.CalledOnValidThread()); |
352 if (!task_queue_manager_) | 357 if (!task_queue_manager_) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 state->BeginArray("delayed_task_queue"); | 431 state->BeginArray("delayed_task_queue"); |
427 QueueAsValueInto(delayed_task_queue_, state); | 432 QueueAsValueInto(delayed_task_queue_, state); |
428 state->EndArray(); | 433 state->EndArray(); |
429 } | 434 } |
430 state->SetString("priority", | 435 state->SetString("priority", |
431 PriorityToString(static_cast<QueuePriority>(set_index_))); | 436 PriorityToString(static_cast<QueuePriority>(set_index_))); |
432 state->EndDictionary(); | 437 state->EndDictionary(); |
433 } | 438 } |
434 | 439 |
435 // static | 440 // static |
436 void TaskQueueImpl::QueueAsValueInto(const base::TaskQueue& queue, | 441 void TaskQueueImpl::QueueAsValueInto(const std::queue<Task>& queue, |
437 base::trace_event::TracedValue* state) { | 442 base::trace_event::TracedValue* state) { |
438 base::TaskQueue queue_copy(queue); | 443 std::queue<Task> queue_copy(queue); |
439 while (!queue_copy.empty()) { | 444 while (!queue_copy.empty()) { |
440 TaskAsValueInto(queue_copy.front(), state); | 445 TaskAsValueInto(queue_copy.front(), state); |
441 queue_copy.pop(); | 446 queue_copy.pop(); |
442 } | 447 } |
443 } | 448 } |
444 | 449 |
445 // static | 450 // static |
446 void TaskQueueImpl::QueueAsValueInto(const base::DelayedTaskQueue& queue, | 451 void TaskQueueImpl::QueueAsValueInto( |
447 base::trace_event::TracedValue* state) { | 452 const std::priority_queue<Task>& queue, |
448 base::DelayedTaskQueue queue_copy(queue); | 453 base::trace_event::TracedValue* state) { |
454 std::priority_queue<Task> queue_copy(queue); | |
449 while (!queue_copy.empty()) { | 455 while (!queue_copy.empty()) { |
450 TaskAsValueInto(queue_copy.top(), state); | 456 TaskAsValueInto(queue_copy.top(), state); |
451 queue_copy.pop(); | 457 queue_copy.pop(); |
452 } | 458 } |
453 } | 459 } |
454 | 460 |
455 // static | 461 // static |
456 void TaskQueueImpl::TaskAsValueInto(const base::PendingTask& task, | 462 void TaskQueueImpl::TaskAsValueInto(const Task& task, |
457 base::trace_event::TracedValue* state) { | 463 base::trace_event::TracedValue* state) { |
458 state->BeginDictionary(); | 464 state->BeginDictionary(); |
459 state->SetString("posted_from", task.posted_from.ToString()); | 465 state->SetString("posted_from", task.posted_from.ToString()); |
466 state->SetInteger("enqueue_order", task.enqueue_order); | |
460 state->SetInteger("sequence_num", task.sequence_num); | 467 state->SetInteger("sequence_num", task.sequence_num); |
461 state->SetBoolean("nestable", task.nestable); | 468 state->SetBoolean("nestable", task.nestable); |
462 state->SetBoolean("is_high_res", task.is_high_res); | 469 state->SetBoolean("is_high_res", task.is_high_res); |
463 state->SetDouble( | 470 state->SetDouble( |
464 "delayed_run_time", | 471 "delayed_run_time", |
465 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); | 472 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); |
466 state->EndDictionary(); | 473 state->EndDictionary(); |
467 } | 474 } |
468 | 475 |
469 } // namespace internal | 476 } // namespace internal |
470 } // namespace scheduler | 477 } // namespace scheduler |
OLD | NEW |