| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/scheduler/child/scheduler_tqm_delegate_impl.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 namespace scheduler { | |
| 10 | |
| 11 // static | |
| 12 scoped_refptr<SchedulerTqmDelegateImpl> SchedulerTqmDelegateImpl::Create( | |
| 13 base::MessageLoop* message_loop, | |
| 14 std::unique_ptr<base::TickClock> time_source) { | |
| 15 return make_scoped_refptr( | |
| 16 new SchedulerTqmDelegateImpl(message_loop, std::move(time_source))); | |
| 17 } | |
| 18 | |
| 19 SchedulerTqmDelegateImpl::SchedulerTqmDelegateImpl( | |
| 20 base::MessageLoop* message_loop, | |
| 21 std::unique_ptr<base::TickClock> time_source) | |
| 22 : message_loop_(message_loop), | |
| 23 message_loop_task_runner_(message_loop->task_runner()), | |
| 24 time_source_(std::move(time_source)) {} | |
| 25 | |
| 26 SchedulerTqmDelegateImpl::~SchedulerTqmDelegateImpl() { | |
| 27 RestoreDefaultTaskRunner(); | |
| 28 } | |
| 29 | |
| 30 void SchedulerTqmDelegateImpl::SetDefaultTaskRunner( | |
| 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
| 32 message_loop_->SetTaskRunner(task_runner); | |
| 33 } | |
| 34 | |
| 35 void SchedulerTqmDelegateImpl::RestoreDefaultTaskRunner() { | |
| 36 if (base::MessageLoop::current() == message_loop_) | |
| 37 message_loop_->SetTaskRunner(message_loop_task_runner_); | |
| 38 } | |
| 39 | |
| 40 bool SchedulerTqmDelegateImpl::PostDelayedTask( | |
| 41 const tracked_objects::Location& from_here, | |
| 42 const base::Closure& task, | |
| 43 base::TimeDelta delay) { | |
| 44 return message_loop_task_runner_->PostDelayedTask(from_here, task, delay); | |
| 45 } | |
| 46 | |
| 47 bool SchedulerTqmDelegateImpl::PostNonNestableDelayedTask( | |
| 48 const tracked_objects::Location& from_here, | |
| 49 const base::Closure& task, | |
| 50 base::TimeDelta delay) { | |
| 51 return message_loop_task_runner_->PostNonNestableDelayedTask(from_here, task, | |
| 52 delay); | |
| 53 } | |
| 54 | |
| 55 bool SchedulerTqmDelegateImpl::RunsTasksOnCurrentThread() const { | |
| 56 return message_loop_task_runner_->RunsTasksOnCurrentThread(); | |
| 57 } | |
| 58 | |
| 59 bool SchedulerTqmDelegateImpl::IsNested() const { | |
| 60 return message_loop_->IsNested(); | |
| 61 } | |
| 62 | |
| 63 base::TimeTicks SchedulerTqmDelegateImpl::NowTicks() { | |
| 64 return time_source_->NowTicks(); | |
| 65 } | |
| 66 | |
| 67 } // namespace scheduler | |
| OLD | NEW |