| 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 "platform/scheduler/base/task_queue_impl.h" | 5 #include "platform/scheduler/base/task_queue_impl.h" |
| 6 | 6 |
| 7 #include "base/trace_event/blame_context.h" | 7 #include "base/trace_event/blame_context.h" |
| 8 #include "platform/scheduler/base/task_queue_manager.h" | 8 #include "platform/scheduler/base/task_queue_manager.h" |
| 9 #include "platform/scheduler/base/task_queue_manager_delegate.h" | 9 #include "platform/scheduler/base/task_queue_manager_delegate.h" |
| 10 #include "platform/scheduler/base/time_domain.h" | 10 #include "platform/scheduler/base/time_domain.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 void TaskQueueImpl::RemoveTaskObserver( | 500 void TaskQueueImpl::RemoveTaskObserver( |
| 501 base::MessageLoop::TaskObserver* task_observer) { | 501 base::MessageLoop::TaskObserver* task_observer) { |
| 502 main_thread_only().task_observers.RemoveObserver(task_observer); | 502 main_thread_only().task_observers.RemoveObserver(task_observer); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void TaskQueueImpl::NotifyWillProcessTask( | 505 void TaskQueueImpl::NotifyWillProcessTask( |
| 506 const base::PendingTask& pending_task) { | 506 const base::PendingTask& pending_task) { |
| 507 DCHECK(should_notify_observers_); | 507 DCHECK(should_notify_observers_); |
| 508 if (main_thread_only().blame_context) | 508 if (main_thread_only().blame_context) |
| 509 main_thread_only().blame_context->Enter(); | 509 main_thread_only().blame_context->Enter(); |
| 510 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, | 510 for (auto& observer : main_thread_only().task_observers) |
| 511 main_thread_only().task_observers, | 511 observer.WillProcessTask(pending_task); |
| 512 WillProcessTask(pending_task)); | |
| 513 } | 512 } |
| 514 | 513 |
| 515 void TaskQueueImpl::NotifyDidProcessTask( | 514 void TaskQueueImpl::NotifyDidProcessTask( |
| 516 const base::PendingTask& pending_task) { | 515 const base::PendingTask& pending_task) { |
| 517 DCHECK(should_notify_observers_); | 516 DCHECK(should_notify_observers_); |
| 518 FOR_EACH_OBSERVER(base::MessageLoop::TaskObserver, | 517 for (auto& observer : main_thread_only().task_observers) |
| 519 main_thread_only().task_observers, | 518 observer.DidProcessTask(pending_task); |
| 520 DidProcessTask(pending_task)); | |
| 521 if (main_thread_only().blame_context) | 519 if (main_thread_only().blame_context) |
| 522 main_thread_only().blame_context->Leave(); | 520 main_thread_only().blame_context->Leave(); |
| 523 } | 521 } |
| 524 | 522 |
| 525 void TaskQueueImpl::SetTimeDomain(TimeDomain* time_domain) { | 523 void TaskQueueImpl::SetTimeDomain(TimeDomain* time_domain) { |
| 526 { | 524 { |
| 527 base::AutoLock lock(any_thread_lock_); | 525 base::AutoLock lock(any_thread_lock_); |
| 528 DCHECK(time_domain); | 526 DCHECK(time_domain); |
| 529 // NOTE this is similar to checking |any_thread().task_queue_manager| but | 527 // NOTE this is similar to checking |any_thread().task_queue_manager| but |
| 530 // the TaskQueueSelectorTests constructs TaskQueueImpl directly with a null | 528 // the TaskQueueSelectorTests constructs TaskQueueImpl directly with a null |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 state->SetBoolean("is_cancelled", task.task.IsCancelled()); | 694 state->SetBoolean("is_cancelled", task.task.IsCancelled()); |
| 697 state->SetDouble( | 695 state->SetDouble( |
| 698 "delayed_run_time", | 696 "delayed_run_time", |
| 699 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); | 697 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); |
| 700 state->EndDictionary(); | 698 state->EndDictionary(); |
| 701 } | 699 } |
| 702 | 700 |
| 703 } // namespace internal | 701 } // namespace internal |
| 704 } // namespace scheduler | 702 } // namespace scheduler |
| 705 } // namespace blink | 703 } // namespace blink |
| OLD | NEW |