OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/logging.h" | |
6 #include "base/test/scoped_time_controller.h" | |
7 | |
8 namespace base { | |
9 namespace test { | |
10 | |
11 ScopedTimeController::ScopedTimeController() | |
12 : current_time_(Time::Now()), | |
13 current_timeticks_(TimeTicks::Now()) { | |
14 replaced_instance_ = TimeFactory::instance_; | |
15 TimeFactory::instance_ = this; | |
16 } | |
17 | |
18 ScopedTimeController::~ScopedTimeController() { | |
19 TimeFactory::instance_ = replaced_instance_; | |
20 } | |
21 | |
22 void ScopedTimeController::Advance(base::TimeDelta delta) { | |
23 DCHECK(delta >= base::TimeDelta()); | |
24 current_time_ += delta; | |
25 current_timeticks_ += delta; | |
26 } | |
27 | |
28 Time ScopedTimeController::TimeNow() { | |
29 return current_time_; | |
30 } | |
31 | |
32 TimeTicks ScopedTimeController::TimeTicksNow() { | |
33 return current_timeticks_; | |
34 } | |
35 | |
36 } // namespace base | |
brettw
2012/12/13 21:39:16
Flip the order of these two lines :)
| |
37 } // namespace test | |
OLD | NEW |