Index: base/test/scoped_time_controller.h |
diff --git a/base/test/scoped_time_controller.h b/base/test/scoped_time_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..211dbd73dcf7daee2f2fb3391dde8b3d270ba921 |
--- /dev/null |
+++ b/base/test/scoped_time_controller.h |
@@ -0,0 +1,40 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_TEST_SCOPED_TIME_CONTROLLER_H_ |
+#define BASE_TEST_SCOPED_TIME_CONTROLLER_H_ |
+ |
+#include "base/time.h" |
+ |
+namespace base { |
+namespace test { |
+ |
+// Sets itself as a TimeFactory construction, and restores the previous one |
+// on destruction. |
+class BASE_EXPORT ScopedTimeController : public base::TimeFactory { |
+ public: |
+ ScopedTimeController(); |
+ ~ScopedTimeController(); |
Daniel Erat
2012/12/10 23:56:52
nit: need 'virtual' here
Denis Kuznetsov (DE-MUC)
2012/12/11 13:27:57
Done.
|
+ |
+ // Advances inner time for |delta|. |
+ void Advance(base::TimeDelta delta); |
+ |
+ // TimeFactory overrides |
+ virtual base::Time TimeNow(); |
+ virtual base::TimeTicks TimeTicksNow(); |
+ virtual base::TimeTicks TimeTicksHighResNow(); |
+ |
+ private: |
+ base::TimeTicks current_timeticks_; |
+ base::Time current_time_; |
+ |
+ base::TimeFactory* replaced_instance_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedTimeController); |
+}; |
+ |
+} // namespace test |
+} // namespace base |
+ |
+#endif // BASE_TEST_SCOPED_TIME_CONTROLLER_H_ |