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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 LazySchedulerMessageLoopDelegateForTests:: | 32 LazySchedulerMessageLoopDelegateForTests:: |
33 ~LazySchedulerMessageLoopDelegateForTests() { | 33 ~LazySchedulerMessageLoopDelegateForTests() { |
34 RestoreDefaultTaskRunner(); | 34 RestoreDefaultTaskRunner(); |
35 } | 35 } |
36 | 36 |
37 base::MessageLoop* LazySchedulerMessageLoopDelegateForTests::EnsureMessageLoop() | 37 base::MessageLoop* LazySchedulerMessageLoopDelegateForTests::EnsureMessageLoop() |
38 const { | 38 const { |
39 if (message_loop_) | 39 if (message_loop_) |
40 return message_loop_; | 40 return message_loop_; |
41 DCHECK(RunsTasksOnCurrentThread()); | 41 DCHECK(RunsTasksInCurrentSequence()); |
42 message_loop_ = base::MessageLoop::current(); | 42 message_loop_ = base::MessageLoop::current(); |
43 DCHECK(message_loop_); | 43 DCHECK(message_loop_); |
44 original_task_runner_ = message_loop_->task_runner(); | 44 original_task_runner_ = message_loop_->task_runner(); |
45 if (pending_task_runner_) | 45 if (pending_task_runner_) |
46 message_loop_->SetTaskRunner(std::move(pending_task_runner_)); | 46 message_loop_->SetTaskRunner(std::move(pending_task_runner_)); |
47 if (pending_observer_) | 47 if (pending_observer_) |
48 base::RunLoop::AddNestingObserverOnCurrentThread(pending_observer_); | 48 base::RunLoop::AddNestingObserverOnCurrentThread(pending_observer_); |
49 return message_loop_; | 49 return message_loop_; |
50 } | 50 } |
51 | 51 |
(...skipping 26 matching lines...) Expand all Loading... |
78 | 78 |
79 bool LazySchedulerMessageLoopDelegateForTests::PostNonNestableDelayedTask( | 79 bool LazySchedulerMessageLoopDelegateForTests::PostNonNestableDelayedTask( |
80 const tracked_objects::Location& from_here, | 80 const tracked_objects::Location& from_here, |
81 base::OnceClosure task, | 81 base::OnceClosure task, |
82 base::TimeDelta delay) { | 82 base::TimeDelta delay) { |
83 EnsureMessageLoop(); | 83 EnsureMessageLoop(); |
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::RunsTasksOnCurrentThread() | 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(RunsTasksOnCurrentThread()); |
95 EnsureMessageLoop(); | 95 EnsureMessageLoop(); |
96 return base::RunLoop::IsNestedOnCurrentThread(); | 96 return base::RunLoop::IsNestedOnCurrentThread(); |
97 } | 97 } |
98 | 98 |
(...skipping 38 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 |