Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.cc

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/time/default_tick_clock.h" 10 #include "base/time/default_tick_clock.h"
(...skipping 19 matching lines...) Expand all
30 30
31 LazySchedulerMessageLoopDelegateForTests:: 31 LazySchedulerMessageLoopDelegateForTests::
32 ~LazySchedulerMessageLoopDelegateForTests() { 32 ~LazySchedulerMessageLoopDelegateForTests() {
33 RestoreDefaultTaskRunner(); 33 RestoreDefaultTaskRunner();
34 } 34 }
35 35
36 base::MessageLoop* LazySchedulerMessageLoopDelegateForTests::EnsureMessageLoop() 36 base::MessageLoop* LazySchedulerMessageLoopDelegateForTests::EnsureMessageLoop()
37 const { 37 const {
38 if (message_loop_) 38 if (message_loop_)
39 return message_loop_; 39 return message_loop_;
40 DCHECK(RunsTasksOnCurrentThread()); 40 DCHECK(RunsTasksInCurrentSequence());
41 message_loop_ = base::MessageLoop::current(); 41 message_loop_ = base::MessageLoop::current();
42 DCHECK(message_loop_); 42 DCHECK(message_loop_);
43 original_task_runner_ = message_loop_->task_runner(); 43 original_task_runner_ = message_loop_->task_runner();
44 if (pending_task_runner_) 44 if (pending_task_runner_)
45 message_loop_->SetTaskRunner(std::move(pending_task_runner_)); 45 message_loop_->SetTaskRunner(std::move(pending_task_runner_));
46 if (pending_observer_) 46 if (pending_observer_)
47 message_loop_->AddNestingObserver(pending_observer_); 47 message_loop_->AddNestingObserver(pending_observer_);
48 return message_loop_; 48 return message_loop_;
49 } 49 }
50 50
(...skipping 26 matching lines...) Expand all
77 77
78 bool LazySchedulerMessageLoopDelegateForTests::PostNonNestableDelayedTask( 78 bool LazySchedulerMessageLoopDelegateForTests::PostNonNestableDelayedTask(
79 const tracked_objects::Location& from_here, 79 const tracked_objects::Location& from_here,
80 base::OnceClosure task, 80 base::OnceClosure task,
81 base::TimeDelta delay) { 81 base::TimeDelta delay) {
82 EnsureMessageLoop(); 82 EnsureMessageLoop();
83 return original_task_runner_->PostNonNestableDelayedTask( 83 return original_task_runner_->PostNonNestableDelayedTask(
84 from_here, std::move(task), delay); 84 from_here, std::move(task), delay);
85 } 85 }
86 86
87 bool LazySchedulerMessageLoopDelegateForTests::RunsTasksOnCurrentThread() 87 bool LazySchedulerMessageLoopDelegateForTests::RunsTasksInCurrentSequence()
88 const { 88 const {
89 return thread_id_ == base::PlatformThread::CurrentId(); 89 return thread_id_ == base::PlatformThread::CurrentId();
90 } 90 }
91 91
92 bool LazySchedulerMessageLoopDelegateForTests::IsNested() const { 92 bool LazySchedulerMessageLoopDelegateForTests::IsNested() const {
93 return EnsureMessageLoop()->IsNested(); 93 return EnsureMessageLoop()->IsNested();
94 } 94 }
95 95
96 void LazySchedulerMessageLoopDelegateForTests::AddNestingObserver( 96 void LazySchedulerMessageLoopDelegateForTests::AddNestingObserver(
97 base::MessageLoop::NestingObserver* observer) { 97 base::MessageLoop::NestingObserver* observer) {
(...skipping 13 matching lines...) Expand all
111 } 111 }
112 message_loop_->RemoveNestingObserver(observer); 112 message_loop_->RemoveNestingObserver(observer);
113 } 113 }
114 114
115 base::TimeTicks LazySchedulerMessageLoopDelegateForTests::NowTicks() { 115 base::TimeTicks LazySchedulerMessageLoopDelegateForTests::NowTicks() {
116 return time_source_->NowTicks(); 116 return time_source_->NowTicks();
117 } 117 }
118 118
119 } // namespace scheduler 119 } // namespace scheduler
120 } // namespace blink 120 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698