Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2355)

Unified Diff: base/test/scoped_time_controller.h

Issue 11453012: Fix black background when locking with fullscreen window: (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename undo/stop to cancel Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..569a3c877229e75a8315adfcba0b5e44a1f9062b
--- /dev/null
+++ b/base/test/scoped_time_controller.h
@@ -0,0 +1,43 @@
+// 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/compiler_specific.h"
+#include "base/time.h"
+
+namespace base {
+namespace test {
+
+// TimeFactory that captures and freeses current time, and let to advance it
+// manually. Sets itself as a TimeFactory instance on construction, and
+// restores the previous one on destruction.
+// Use it with care, as it might break assumed time monotonicity after deletion.
+// The best way is to set it first in SetUp and remove it last at the
+// TearDown method.
+class ScopedTimeController : public base::TimeFactory {
+ public:
+ ScopedTimeController();
+ virtual ~ScopedTimeController();
+
+ // Advances inner time for |delta|. |Delta| have to be non-negative.
+ void Advance(base::TimeDelta delta);
+
+ // TimeFactory overrides
+ virtual base::Time TimeNow() OVERRIDE;
+ virtual base::TimeTicks TimeTicksNow() OVERRIDE;
+ private:
+ base::Time current_time_;
+ base::TimeTicks current_timeticks_;
+
+ base::TimeFactory* replaced_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedTimeController);
+};
+
+} // namespace test
+} // namespace base
+
+#endif // BASE_TEST_SCOPED_TIME_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698