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

Unified Diff: webrtc/base/timeutils.cc

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.cc
diff --git a/webrtc/base/timeutils.cc b/webrtc/base/timeutils.cc
index de3e6afb28d824ecb9dfc26f1029dd0d0958fd24..a43158712d7776a0cb88bece684a8d6c369b6422 100644
--- a/webrtc/base/timeutils.cc
+++ b/webrtc/base/timeutils.cc
@@ -32,7 +32,16 @@ namespace rtc {
const uint32_t HALF = 0x80000000;
+ClockInterface* clock_ = nullptr;
+
+void SetClock(ClockInterface* clock) {
+ clock_ = clock;
+}
+
uint64_t TimeNanos() {
+ if (clock_) {
juberti2 2016/04/25 20:18:23 Do we need to mention that this is unsynchronized?
Taylor Brandstetter 2016/04/26 01:22:32 I mention in timeutils.h that SetClock (which is t
+ return clock_->TimeNanos();
+ }
int64_t ticks = 0;
#if defined(WEBRTC_MAC)
juberti2 2016/04/25 20:18:23 Should we factor this into a real clock implementa
Taylor Brandstetter 2016/04/26 01:22:32 Done.
static mach_timebase_info_data_t timebase;

Powered by Google App Engine
This is Rietveld 408576698