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 "components/scheduler/base/nestable_task_runner_for_test.h" | 5 #include "components/scheduler/base/nestable_task_runner_for_test.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 | 9 |
10 namespace scheduler { | 10 namespace scheduler { |
11 | 11 |
12 // static | 12 // static |
13 scoped_refptr<NestableTaskRunnerForTest> NestableTaskRunnerForTest::Create( | 13 scoped_refptr<NestableTaskRunnerForTest> NestableTaskRunnerForTest::Create( |
14 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 14 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
15 return make_scoped_refptr(new NestableTaskRunnerForTest(task_runner)); | 15 scoped_ptr<base::TickClock> time_source) { |
| 16 return make_scoped_refptr( |
| 17 new NestableTaskRunnerForTest(task_runner, time_source.Pass())); |
16 } | 18 } |
17 | 19 |
18 NestableTaskRunnerForTest::NestableTaskRunnerForTest( | 20 NestableTaskRunnerForTest::NestableTaskRunnerForTest( |
19 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 21 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
20 : task_runner_(task_runner) {} | 22 scoped_ptr<base::TickClock> time_source) |
| 23 : task_runner_(task_runner), time_source_(time_source.Pass()) {} |
21 | 24 |
22 NestableTaskRunnerForTest::~NestableTaskRunnerForTest() {} | 25 NestableTaskRunnerForTest::~NestableTaskRunnerForTest() {} |
23 | 26 |
24 bool NestableTaskRunnerForTest::PostDelayedTask( | 27 bool NestableTaskRunnerForTest::PostDelayedTask( |
25 const tracked_objects::Location& from_here, | 28 const tracked_objects::Location& from_here, |
26 const base::Closure& task, | 29 const base::Closure& task, |
27 base::TimeDelta delay) { | 30 base::TimeDelta delay) { |
28 return task_runner_->PostDelayedTask(from_here, task, delay); | 31 return task_runner_->PostDelayedTask(from_here, task, delay); |
29 } | 32 } |
30 | 33 |
31 bool NestableTaskRunnerForTest::PostNonNestableDelayedTask( | 34 bool NestableTaskRunnerForTest::PostNonNestableDelayedTask( |
32 const tracked_objects::Location& from_here, | 35 const tracked_objects::Location& from_here, |
33 const base::Closure& task, | 36 const base::Closure& task, |
34 base::TimeDelta delay) { | 37 base::TimeDelta delay) { |
35 return task_runner_->PostNonNestableDelayedTask(from_here, task, delay); | 38 return task_runner_->PostNonNestableDelayedTask(from_here, task, delay); |
36 } | 39 } |
37 | 40 |
38 bool NestableTaskRunnerForTest::RunsTasksOnCurrentThread() const { | 41 bool NestableTaskRunnerForTest::RunsTasksOnCurrentThread() const { |
39 return task_runner_->RunsTasksOnCurrentThread(); | 42 return task_runner_->RunsTasksOnCurrentThread(); |
40 } | 43 } |
41 | 44 |
42 bool NestableTaskRunnerForTest::IsNested() const { | 45 bool NestableTaskRunnerForTest::IsNested() const { |
43 return false; | 46 return false; |
44 } | 47 } |
45 | 48 |
| 49 base::TimeTicks NestableTaskRunnerForTest::NowTicks() { |
| 50 return time_source_->NowTicks(); |
| 51 } |
| 52 |
| 53 void NestableTaskRunnerForTest::OnNoMoreWork() {} |
| 54 |
46 } // namespace scheduler | 55 } // namespace scheduler |
OLD | NEW |