Index: webrtc/base/timeutils.cc |
diff --git a/webrtc/base/timeutils.cc b/webrtc/base/timeutils.cc |
index a9fe49d6075a2341a387247ccb8e941677ee3544..fedbe85e0caa161330290797c5452ac7ed02ef36 100644 |
--- a/webrtc/base/timeutils.cc |
+++ b/webrtc/base/timeutils.cc |
@@ -30,7 +30,26 @@ |
namespace rtc { |
+namespace test { |
+ |
+namespace { |
+FakeTimeInterface* g_fake_time = nullptr; |
+} // Anonymous |
+ |
+void SetFakeTime(FakeTimeInterface* fake_time) { |
+ // Allow setting g_fake_time non-null only if old value is null. |
+ if (fake_time) |
+ RTC_CHECK(!g_fake_time); |
+ |
+ g_fake_time = fake_time; |
+} |
+ |
+} // namespace test |
+ |
uint64_t TimeNanos() { |
+ if (test::g_fake_time) |
+ return test::g_fake_time->TimeNanos(); |
+ |
int64_t ticks = 0; |
#if defined(WEBRTC_MAC) |
static mach_timebase_info_data_t timebase; |