From 0de1ed0244a8da395811ad8952e5f5f8a2643e2a Mon Sep 17 00:00:00 2001 From: Paul Hallak Date: Wed, 19 May 2021 14:36:50 +0200 Subject: [PATCH] Have only two pure virtual methods for webrtc::Clock, `CurrentTime` and `CurrentNtpTime`. Make all other methods non-virtual. Bug: webrtc:11327 Change-Id: I391d9eaec1ba27ec4f8e1901498c68c28a7ec4ff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/219466 Reviewed-by: Niels Moller Commit-Queue: Paul Hallak Cr-Commit-Position: refs/heads/master@{#34065} --- system_wrappers/include/clock.h | 17 ++++------------- test/drifting_clock.cc | 3 --- test/drifting_clock.h | 1 - 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h index bcb7feaa7d..914fbda922 100644 --- a/system_wrappers/include/clock.h +++ b/system_wrappers/include/clock.h @@ -34,22 +34,13 @@ class RTC_EXPORT Clock { virtual ~Clock() {} // Return a timestamp relative to an unspecified epoch. - // TODO(bugs.webrtc.org/11327): Make this a pure virtual function. - virtual Timestamp CurrentTime() { - return Timestamp::Micros(TimeInMicroseconds()); - } - - // TODO(bugs.webrtc.org/11327): Make the following two methods non-virtual - // or completely remove them. - virtual int64_t TimeInMilliseconds() { return CurrentTime().ms(); } - virtual int64_t TimeInMicroseconds() { return CurrentTime().us(); } + virtual Timestamp CurrentTime() = 0; + int64_t TimeInMilliseconds() { return CurrentTime().ms(); } + int64_t TimeInMicroseconds() { return CurrentTime().us(); } // Retrieve an NTP absolute timestamp (with an epoch of Jan 1, 1900). virtual NtpTime CurrentNtpTime() = 0; - - // TODO(bugs.webrtc.org/11327): Make the following method non-virtual - // or completely remove it. - virtual int64_t CurrentNtpInMilliseconds() { return CurrentNtpTime().ToMs(); } + int64_t CurrentNtpInMilliseconds() { return CurrentNtpTime().ToMs(); } // Returns an instance of the real-time system clock implementation. static Clock* GetRealTimeClock(); diff --git a/test/drifting_clock.cc b/test/drifting_clock.cc index 1a5154557e..29b28ddc89 100644 --- a/test/drifting_clock.cc +++ b/test/drifting_clock.cc @@ -42,8 +42,5 @@ NtpTime DriftingClock::CurrentNtpTime() { return NtpTime(total_fractions); } -int64_t DriftingClock::CurrentNtpInMilliseconds() { - return clock_->CurrentNtpInMilliseconds() + Drift().ms(); -} } // namespace test } // namespace webrtc diff --git a/test/drifting_clock.h b/test/drifting_clock.h index 2539b61786..820b2f0550 100644 --- a/test/drifting_clock.h +++ b/test/drifting_clock.h @@ -32,7 +32,6 @@ class DriftingClock : public Clock { Timestamp CurrentTime() override; NtpTime CurrentNtpTime() override; - int64_t CurrentNtpInMilliseconds() override; private: TimeDelta Drift() const;