| 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/test/lazy_scheduler_message_loop_delegate_for_tests
.h" | 5 #include "platform/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests
.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return original_task_runner_->PostNonNestableDelayedTask( | 84 return original_task_runner_->PostNonNestableDelayedTask( |
| 85 from_here, std::move(task), delay); | 85 from_here, std::move(task), delay); |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool LazySchedulerMessageLoopDelegateForTests::RunsTasksInCurrentSequence() | 88 bool LazySchedulerMessageLoopDelegateForTests::RunsTasksInCurrentSequence() |
| 89 const { | 89 const { |
| 90 return thread_id_ == base::PlatformThread::CurrentId(); | 90 return thread_id_ == base::PlatformThread::CurrentId(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool LazySchedulerMessageLoopDelegateForTests::IsNested() const { | 93 bool LazySchedulerMessageLoopDelegateForTests::IsNested() const { |
| 94 DCHECK(RunsTasksOnCurrentThread()); | 94 DCHECK(RunsTasksInCurrentSequence()); |
| 95 EnsureMessageLoop(); | 95 EnsureMessageLoop(); |
| 96 return base::RunLoop::IsNestedOnCurrentThread(); | 96 return base::RunLoop::IsNestedOnCurrentThread(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void LazySchedulerMessageLoopDelegateForTests::AddNestingObserver( | 99 void LazySchedulerMessageLoopDelegateForTests::AddNestingObserver( |
| 100 base::RunLoop::NestingObserver* observer) { | 100 base::RunLoop::NestingObserver* observer) { |
| 101 // While |observer| _could_ be associated with the current thread regardless | 101 // While |observer| _could_ be associated with the current thread regardless |
| 102 // of the presence of a MessageLoop, the association is delayed until | 102 // of the presence of a MessageLoop, the association is delayed until |
| 103 // EnsureMessageLoop() is invoked. This works around a state issue where | 103 // EnsureMessageLoop() is invoked. This works around a state issue where |
| 104 // otherwise many tests fail because of the following sequence: | 104 // otherwise many tests fail because of the following sequence: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 base::RunLoop::RemoveNestingObserverOnCurrentThread(observer); | 138 base::RunLoop::RemoveNestingObserverOnCurrentThread(observer); |
| 139 } | 139 } |
| 140 | 140 |
| 141 base::TimeTicks LazySchedulerMessageLoopDelegateForTests::NowTicks() { | 141 base::TimeTicks LazySchedulerMessageLoopDelegateForTests::NowTicks() { |
| 142 return time_source_->NowTicks(); | 142 return time_source_->NowTicks(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace scheduler | 145 } // namespace scheduler |
| 146 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |