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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/threading/thread_id_name_manager.h" |
8 | 9 |
9 namespace base { | 10 namespace base { |
10 | 11 |
11 TestSimpleTaskRunner::TestSimpleTaskRunner() {} | 12 TestSimpleTaskRunner::TestSimpleTaskRunner() {} |
12 | 13 |
13 TestSimpleTaskRunner::~TestSimpleTaskRunner() { | 14 TestSimpleTaskRunner::~TestSimpleTaskRunner() { |
14 DCHECK(thread_checker_.CalledOnValidThread()); | 15 DCHECK(thread_checker_.CalledOnValidThread()); |
15 } | 16 } |
16 | 17 |
17 bool TestSimpleTaskRunner::PostDelayedTask( | 18 bool TestSimpleTaskRunner::PostDelayedTask( |
(...skipping 16 matching lines...) Expand all Loading... |
34 TestPendingTask(from_here, task, TimeTicks(), delay, | 35 TestPendingTask(from_here, task, TimeTicks(), delay, |
35 TestPendingTask::NON_NESTABLE)); | 36 TestPendingTask::NON_NESTABLE)); |
36 return true; | 37 return true; |
37 } | 38 } |
38 | 39 |
39 bool TestSimpleTaskRunner::RunsTasksOnCurrentThread() const { | 40 bool TestSimpleTaskRunner::RunsTasksOnCurrentThread() const { |
40 DCHECK(thread_checker_.CalledOnValidThread()); | 41 DCHECK(thread_checker_.CalledOnValidThread()); |
41 return true; | 42 return true; |
42 } | 43 } |
43 | 44 |
| 45 std::string TestSimpleTaskRunner::GetThreadName() const { |
| 46 DCHECK(thread_checker_.CalledOnValidThread()); |
| 47 return ThreadIdNameManager::GetInstance()->GetName( |
| 48 PlatformThread::CurrentId()); |
| 49 } |
| 50 |
44 const std::deque<TestPendingTask>& | 51 const std::deque<TestPendingTask>& |
45 TestSimpleTaskRunner::GetPendingTasks() const { | 52 TestSimpleTaskRunner::GetPendingTasks() const { |
46 DCHECK(thread_checker_.CalledOnValidThread()); | 53 DCHECK(thread_checker_.CalledOnValidThread()); |
47 return pending_tasks_; | 54 return pending_tasks_; |
48 } | 55 } |
49 | 56 |
50 bool TestSimpleTaskRunner::HasPendingTask() const { | 57 bool TestSimpleTaskRunner::HasPendingTask() const { |
51 DCHECK(thread_checker_.CalledOnValidThread()); | 58 DCHECK(thread_checker_.CalledOnValidThread()); |
52 return !pending_tasks_.empty(); | 59 return !pending_tasks_.empty(); |
53 } | 60 } |
(...skipping 19 matching lines...) Expand all Loading... |
73 } | 80 } |
74 } | 81 } |
75 | 82 |
76 void TestSimpleTaskRunner::RunUntilIdle() { | 83 void TestSimpleTaskRunner::RunUntilIdle() { |
77 while (!pending_tasks_.empty()) { | 84 while (!pending_tasks_.empty()) { |
78 RunPendingTasks(); | 85 RunPendingTasks(); |
79 } | 86 } |
80 } | 87 } |
81 | 88 |
82 } // namespace base | 89 } // namespace base |
OLD | NEW |