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 #ifndef BASE_TEST_SCOPED_TIME_CONTROLLER_H_ | |
6 #define BASE_TEST_SCOPED_TIME_CONTROLLER_H_ | |
7 | |
8 #include "base/time.h" | |
9 | |
10 namespace base { | |
11 namespace test { | |
12 | |
13 // Sets itself as a TimeFactory construction, and restores the previous one | |
14 // on destruction. | |
15 class BASE_EXPORT ScopedTimeController : public base::TimeFactory { | |
16 public: | |
17 ScopedTimeController(); | |
18 ~ScopedTimeController(); | |
Daniel Erat
2012/12/10 23:56:52
nit: need 'virtual' here
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
Done.
| |
19 | |
20 // Advances inner time for |delta|. | |
21 void Advance(base::TimeDelta delta); | |
22 | |
23 // TimeFactory overrides | |
24 virtual base::Time TimeNow(); | |
25 virtual base::TimeTicks TimeTicksNow(); | |
26 virtual base::TimeTicks TimeTicksHighResNow(); | |
27 | |
28 private: | |
29 base::TimeTicks current_timeticks_; | |
30 base::Time current_time_; | |
31 | |
32 base::TimeFactory* replaced_instance_; | |
33 | |
34 DISALLOW_COPY_AND_ASSIGN(ScopedTimeController); | |
35 }; | |
36 | |
37 } // namespace test | |
38 } // namespace base | |
39 | |
40 #endif // BASE_TEST_SCOPED_TIME_CONTROLLER_H_ | |
OLD | NEW |