| 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 "base/test/test_mock_time_task_runner.h" | 5 #include "base/test/test_mock_time_task_runner.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 scoped_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const { | 95 scoped_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const { |
| 96 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
| 97 return make_scoped_ptr(new MockTickClock(this)); | 97 return make_scoped_ptr(new MockTickClock(this)); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool TestMockTimeTaskRunner::HasPendingTask() const { | 100 bool TestMockTimeTaskRunner::HasPendingTask() const { |
| 101 DCHECK(thread_checker_.CalledOnValidThread()); | 101 DCHECK(thread_checker_.CalledOnValidThread()); |
| 102 return !tasks_.empty(); | 102 return !tasks_.empty(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 size_t TestMockTimeTaskRunner::GetPendingTaskCount() const { |
| 106 DCHECK(thread_checker_.CalledOnValidThread()); |
| 107 return tasks_.size(); |
| 108 } |
| 109 |
| 105 TimeDelta TestMockTimeTaskRunner::NextPendingTaskDelay() const { | 110 TimeDelta TestMockTimeTaskRunner::NextPendingTaskDelay() const { |
| 106 DCHECK(thread_checker_.CalledOnValidThread()); | 111 DCHECK(thread_checker_.CalledOnValidThread()); |
| 107 return tasks_.empty() ? TimeDelta::Max() : tasks_.top().GetTimeToRun() - now_; | 112 return tasks_.empty() ? TimeDelta::Max() : tasks_.top().GetTimeToRun() - now_; |
| 108 } | 113 } |
| 109 | 114 |
| 110 bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const { | 115 bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const { |
| 111 return thread_checker_.CalledOnValidThread(); | 116 return thread_checker_.CalledOnValidThread(); |
| 112 } | 117 } |
| 113 | 118 |
| 114 bool TestMockTimeTaskRunner::PostDelayedTask( | 119 bool TestMockTimeTaskRunner::PostDelayedTask( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (!tasks_.empty() && | 153 if (!tasks_.empty() && |
| 149 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { | 154 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { |
| 150 *next_task = tasks_.top(); | 155 *next_task = tasks_.top(); |
| 151 tasks_.pop(); | 156 tasks_.pop(); |
| 152 return true; | 157 return true; |
| 153 } | 158 } |
| 154 return false; | 159 return false; |
| 155 } | 160 } |
| 156 | 161 |
| 157 } // namespace base | 162 } // namespace base |
| OLD | NEW |