OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/test/test_simple_task_runner.h" | 5 #include "base/test/test_simple_task_runner.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 TestSimpleTaskRunner::TestSimpleTaskRunner() = default; | 15 TestSimpleTaskRunner::TestSimpleTaskRunner() = default; |
16 | 16 |
17 TestSimpleTaskRunner::~TestSimpleTaskRunner() = default; | 17 TestSimpleTaskRunner::~TestSimpleTaskRunner() = default; |
18 | 18 |
19 bool TestSimpleTaskRunner::PostDelayedTask( | 19 bool TestSimpleTaskRunner::PostDelayedTask( |
20 const tracked_objects::Location& from_here, | 20 const tracked_objects::Location& from_here, |
21 Closure task, | 21 OnceClosure task, |
22 TimeDelta delay) { | 22 TimeDelta delay) { |
23 AutoLock auto_lock(lock_); | 23 AutoLock auto_lock(lock_); |
24 pending_tasks_.push_back(TestPendingTask(from_here, std::move(task), | 24 pending_tasks_.push_back(TestPendingTask(from_here, std::move(task), |
25 TimeTicks(), delay, | 25 TimeTicks(), delay, |
26 TestPendingTask::NESTABLE)); | 26 TestPendingTask::NESTABLE)); |
27 return true; | 27 return true; |
28 } | 28 } |
29 | 29 |
30 bool TestSimpleTaskRunner::PostNonNestableDelayedTask( | 30 bool TestSimpleTaskRunner::PostNonNestableDelayedTask( |
31 const tracked_objects::Location& from_here, | 31 const tracked_objects::Location& from_here, |
32 Closure task, | 32 OnceClosure task, |
33 TimeDelta delay) { | 33 TimeDelta delay) { |
34 AutoLock auto_lock(lock_); | 34 AutoLock auto_lock(lock_); |
35 pending_tasks_.push_back(TestPendingTask(from_here, std::move(task), | 35 pending_tasks_.push_back(TestPendingTask(from_here, std::move(task), |
36 TimeTicks(), delay, | 36 TimeTicks(), delay, |
37 TestPendingTask::NON_NESTABLE)); | 37 TestPendingTask::NON_NESTABLE)); |
38 return true; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 // TODO(gab): Use SequenceToken here to differentiate between tasks running in | 41 // TODO(gab): Use SequenceToken here to differentiate between tasks running in |
42 // the scope of this TestSimpleTaskRunner and other task runners sharing this | 42 // the scope of this TestSimpleTaskRunner and other task runners sharing this |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 std::move(task.task).Run(); | 97 std::move(task.task).Run(); |
98 } | 98 } |
99 | 99 |
100 void TestSimpleTaskRunner::RunUntilIdle() { | 100 void TestSimpleTaskRunner::RunUntilIdle() { |
101 while (!pending_tasks_.empty()) { | 101 while (!pending_tasks_.empty()) { |
102 RunPendingTasks(); | 102 RunPendingTasks(); |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 } // namespace base | 106 } // namespace base |
OLD | NEW |