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

Unified Diff: webrtc/base/timeutils.cc

Issue 2016863003: Implemented ScopedFakeTime, faking rtc::TimeNanos. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Created 4 years, 7 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 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;

Powered by Google App Engine
This is Rietveld 408576698