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 <nisse@webrtc.org>
Commit-Queue: Paul Hallak <phallak@google.com>
Cr-Commit-Position: refs/heads/master@{#34065}
This commit is contained in:
Paul Hallak
2021-05-19 14:36:50 +02:00
committed by WebRTC LUCI CQ
parent 8ed1e9336e
commit 0de1ed0244
3 changed files with 4 additions and 17 deletions

View File

@ -34,22 +34,13 @@ class RTC_EXPORT Clock {
virtual ~Clock() {} virtual ~Clock() {}
// Return a timestamp relative to an unspecified epoch. // Return a timestamp relative to an unspecified epoch.
// TODO(bugs.webrtc.org/11327): Make this a pure virtual function. virtual Timestamp CurrentTime() = 0;
virtual Timestamp CurrentTime() { int64_t TimeInMilliseconds() { return CurrentTime().ms(); }
return Timestamp::Micros(TimeInMicroseconds()); int64_t TimeInMicroseconds() { return CurrentTime().us(); }
}
// 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(); }
// Retrieve an NTP absolute timestamp (with an epoch of Jan 1, 1900). // Retrieve an NTP absolute timestamp (with an epoch of Jan 1, 1900).
virtual NtpTime CurrentNtpTime() = 0; virtual NtpTime CurrentNtpTime() = 0;
int64_t CurrentNtpInMilliseconds() { return CurrentNtpTime().ToMs(); }
// TODO(bugs.webrtc.org/11327): Make the following method non-virtual
// or completely remove it.
virtual int64_t CurrentNtpInMilliseconds() { return CurrentNtpTime().ToMs(); }
// Returns an instance of the real-time system clock implementation. // Returns an instance of the real-time system clock implementation.
static Clock* GetRealTimeClock(); static Clock* GetRealTimeClock();

View File

@ -42,8 +42,5 @@ NtpTime DriftingClock::CurrentNtpTime() {
return NtpTime(total_fractions); return NtpTime(total_fractions);
} }
int64_t DriftingClock::CurrentNtpInMilliseconds() {
return clock_->CurrentNtpInMilliseconds() + Drift().ms();
}
} // namespace test } // namespace test
} // namespace webrtc } // namespace webrtc

View File

@ -32,7 +32,6 @@ class DriftingClock : public Clock {
Timestamp CurrentTime() override; Timestamp CurrentTime() override;
NtpTime CurrentNtpTime() override; NtpTime CurrentNtpTime() override;
int64_t CurrentNtpInMilliseconds() override;
private: private:
TimeDelta Drift() const; TimeDelta Drift() const;