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 #include "base/time/clock.h" | 9 #include "base/time/clock.h" |
10 #include "base/time/tick_clock.h" | 10 #include "base/time/tick_clock.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 // TestMockTimeTaskRunner ----------------------------------------------------- | 70 // TestMockTimeTaskRunner ----------------------------------------------------- |
71 | 71 |
72 bool TestMockTimeTaskRunner::TemporalOrder::operator()( | 72 bool TestMockTimeTaskRunner::TemporalOrder::operator()( |
73 const TestPendingTask& first_task, | 73 const TestPendingTask& first_task, |
74 const TestPendingTask& second_task) const { | 74 const TestPendingTask& second_task) const { |
75 return first_task.GetTimeToRun() > second_task.GetTimeToRun(); | 75 return first_task.GetTimeToRun() > second_task.GetTimeToRun(); |
76 } | 76 } |
77 | 77 |
78 TestMockTimeTaskRunner::TestMockTimeTaskRunner() | 78 TestMockTimeTaskRunner::TestMockTimeTaskRunner() : now_(Time::UnixEpoch()) { |
79 : now_(Time::UnixEpoch()) { | |
80 } | 79 } |
81 | 80 |
82 TestMockTimeTaskRunner::~TestMockTimeTaskRunner() { | 81 TestMockTimeTaskRunner::~TestMockTimeTaskRunner() { |
83 } | 82 } |
84 | 83 |
85 void TestMockTimeTaskRunner::FastForwardBy(TimeDelta delta) { | 84 void TestMockTimeTaskRunner::FastForwardBy(TimeDelta delta) { |
86 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
87 DCHECK_GE(delta, TimeDelta()); | 86 DCHECK_GE(delta, TimeDelta()); |
88 | 87 |
89 const TimeTicks original_now_ticks = now_ticks_; | 88 const TimeTicks original_now_ticks = now_ticks_; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 if (!tasks_.empty() && | 203 if (!tasks_.empty() && |
205 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { | 204 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { |
206 *next_task = tasks_.top(); | 205 *next_task = tasks_.top(); |
207 tasks_.pop(); | 206 tasks_.pop(); |
208 return true; | 207 return true; |
209 } | 208 } |
210 return false; | 209 return false; |
211 } | 210 } |
212 | 211 |
213 } // namespace base | 212 } // namespace base |
OLD | NEW |