| 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 { |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 state->EndArray(); | 430 state->EndArray(); |
| 431 state->BeginArray("delayed_task_queue"); | 431 state->BeginArray("delayed_task_queue"); |
| 432 QueueAsValueInto(delayed_task_queue_, state); | 432 QueueAsValueInto(delayed_task_queue_, state); |
| 433 state->EndArray(); | 433 state->EndArray(); |
| 434 } | 434 } |
| 435 state->SetString("priority", | 435 state->SetString("priority", |
| 436 PriorityToString(static_cast<QueuePriority>(set_index_))); | 436 PriorityToString(static_cast<QueuePriority>(set_index_))); |
| 437 state->EndDictionary(); | 437 state->EndDictionary(); |
| 438 } | 438 } |
| 439 | 439 |
| 440 void TaskQueueImpl::AddTaskObserver( |
| 441 base::MessageLoop::TaskObserver* task_observer) { |
| 442 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 443 task_observers_.AddObserver(task_observer); |
| 444 } |
| 445 |
| 446 void TaskQueueImpl::RemoveTaskObserver( |
| 447 base::MessageLoop::TaskObserver* task_observer) { |
| 448 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 449 task_observers_.RemoveObserver(task_observer); |
| 450 } |
| 451 |
| 452 void TaskQueueImpl::NotifyWillProcessTask( |
| 453 const base::PendingTask& pending_task) { |
| 454 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 455 DCHECK(should_notify_observers_); |
| 456 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_, |
| 457 WillProcessTask(pending_task)); |
| 458 } |
| 459 |
| 460 void TaskQueueImpl::NotifyDidProcessTask( |
| 461 const base::PendingTask& pending_task) { |
| 462 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 463 DCHECK(should_notify_observers_); |
| 464 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, task_observers_, |
| 465 DidProcessTask(pending_task)); |
| 466 } |
| 467 |
| 440 // static | 468 // static |
| 441 void TaskQueueImpl::QueueAsValueInto(const std::queue<Task>& queue, | 469 void TaskQueueImpl::QueueAsValueInto(const std::queue<Task>& queue, |
| 442 base::trace_event::TracedValue* state) { | 470 base::trace_event::TracedValue* state) { |
| 443 std::queue<Task> queue_copy(queue); | 471 std::queue<Task> queue_copy(queue); |
| 444 while (!queue_copy.empty()) { | 472 while (!queue_copy.empty()) { |
| 445 TaskAsValueInto(queue_copy.front(), state); | 473 TaskAsValueInto(queue_copy.front(), state); |
| 446 queue_copy.pop(); | 474 queue_copy.pop(); |
| 447 } | 475 } |
| 448 } | 476 } |
| 449 | 477 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 467 state->SetBoolean("nestable", task.nestable); | 495 state->SetBoolean("nestable", task.nestable); |
| 468 state->SetBoolean("is_high_res", task.is_high_res); | 496 state->SetBoolean("is_high_res", task.is_high_res); |
| 469 state->SetDouble( | 497 state->SetDouble( |
| 470 "delayed_run_time", | 498 "delayed_run_time", |
| 471 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); | 499 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); |
| 472 state->EndDictionary(); | 500 state->EndDictionary(); |
| 473 } | 501 } |
| 474 | 502 |
| 475 } // namespace internal | 503 } // namespace internal |
| 476 } // namespace scheduler | 504 } // namespace scheduler |
| OLD | NEW |