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_task_runner_delegate_impl.h" | |
6 | |
7 namespace scheduler { | |
8 | |
9 // static | |
10 scoped_refptr<SchedulerTaskRunnerDelegateImpl> | |
11 SchedulerTaskRunnerDelegateImpl::Create(base::MessageLoop* message_loop) { | |
12 return make_scoped_refptr(new SchedulerTaskRunnerDelegateImpl(message_loop)); | |
13 } | |
14 | |
15 SchedulerTaskRunnerDelegateImpl::SchedulerTaskRunnerDelegateImpl( | |
16 base::MessageLoop* message_loop) | |
17 : message_loop_(message_loop), | |
18 message_loop_task_runner_(message_loop->task_runner()) {} | |
19 | |
20 SchedulerTaskRunnerDelegateImpl::~SchedulerTaskRunnerDelegateImpl() { | |
21 RestoreDefaultTaskRunner(); | |
22 } | |
23 | |
24 void SchedulerTaskRunnerDelegateImpl::SetDefaultTaskRunner( | |
25 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
26 message_loop_->SetTaskRunner(task_runner); | |
27 } | |
28 | |
29 void SchedulerTaskRunnerDelegateImpl::RestoreDefaultTaskRunner() { | |
30 if (base::MessageLoop::current() == message_loop_) | |
31 message_loop_->SetTaskRunner(message_loop_task_runner_); | |
32 } | |
33 | |
34 bool SchedulerTaskRunnerDelegateImpl::PostDelayedTask( | |
35 const tracked_objects::Location& from_here, | |
36 const base::Closure& task, | |
37 base::TimeDelta delay) { | |
38 return message_loop_task_runner_->PostDelayedTask(from_here, task, delay); | |
39 } | |
40 | |
41 bool SchedulerTaskRunnerDelegateImpl::PostNonNestableDelayedTask( | |
42 const tracked_objects::Location& from_here, | |
43 const base::Closure& task, | |
44 base::TimeDelta delay) { | |
45 return message_loop_task_runner_->PostNonNestableDelayedTask(from_here, task, | |
46 delay); | |
47 } | |
48 | |
49 bool SchedulerTaskRunnerDelegateImpl::RunsTasksOnCurrentThread() const { | |
50 return message_loop_task_runner_->RunsTasksOnCurrentThread(); | |
51 } | |
52 | |
53 bool SchedulerTaskRunnerDelegateImpl::IsNested() const { | |
54 return message_loop_->IsNested(); | |
55 } | |
56 | |
57 } // namespace scheduler | |
OLD | NEW |