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

Unified Diff: webrtc/base/timeutils.h

Issue 1895933003: Adding the ability to use a simulated clock for unit tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months 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: webrtc/base/timeutils.h
diff --git a/webrtc/base/timeutils.h b/webrtc/base/timeutils.h
index 4af0d9538f058f9d969f954cd9a7fb5620463fd7..180d3e6e675d38f75038b2849c64a54ab05686ce 100644
--- a/webrtc/base/timeutils.h
+++ b/webrtc/base/timeutils.h
@@ -31,6 +31,19 @@ static const int64_t kNumNanosecsPerMicrosec =
typedef uint32_t TimeStamp;
+class ClockInterface {
+ public:
+ virtual ~ClockInterface() {}
+ virtual uint64_t TimeNanos() const = 0;
+};
+
+// Sets the global source of time. This is useful mainly for unit tests.
+// SetClock(nullptr) should be called before the ClockInterface is deleted.
+// This method is not thread-safe; it should only be used when no other thread
+// is running (for example, at the start/end of a unit test, or start/end of
+// main()).
+void SetClock(ClockInterface* clock);
+
// Returns the current time in milliseconds in 32 bits.
uint32_t Time32();

Powered by Google App Engine
This is Rietveld 408576698