From e6de5ae2d6f9a72d41b07598e08e3765bfefdd2c Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Thu, 22 Apr 2021 18:16:35 +0200 Subject: [PATCH] Remove virtual inheritance from RTCStatsCollector Bug: none Change-Id: I5c3d93f3cc64c588c2f8e750c70c51c991736023 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215961 Reviewed-by: Niels Moller Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#33814} --- api/stats/rtc_stats_collector_callback.h | 2 +- pc/rtc_stats_collector.h | 2 +- pc/rtc_stats_collector_unittest.cc | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/api/stats/rtc_stats_collector_callback.h b/api/stats/rtc_stats_collector_callback.h index c3e08245ea..506cc63e6f 100644 --- a/api/stats/rtc_stats_collector_callback.h +++ b/api/stats/rtc_stats_collector_callback.h @@ -17,7 +17,7 @@ namespace webrtc { -class RTCStatsCollectorCallback : public virtual rtc::RefCountInterface { +class RTCStatsCollectorCallback : public rtc::RefCountInterface { public: ~RTCStatsCollectorCallback() override = default; diff --git a/pc/rtc_stats_collector.h b/pc/rtc_stats_collector.h index b5b8c8c900..5f13f54d26 100644 --- a/pc/rtc_stats_collector.h +++ b/pc/rtc_stats_collector.h @@ -53,7 +53,7 @@ class RtpReceiverInternal; // Stats are gathered on the signaling, worker and network threads // asynchronously. The callback is invoked on the signaling thread. Resulting // reports are cached for |cache_lifetime_| ms. -class RTCStatsCollector : public virtual rtc::RefCountInterface, +class RTCStatsCollector : public rtc::RefCountInterface, public sigslot::has_slots<> { public: static rtc::scoped_refptr Create( diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 3ccdde0056..6a568390c0 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -3215,11 +3215,20 @@ class FakeRTCStatsCollector : public RTCStatsCollector, static rtc::scoped_refptr Create( PeerConnectionInternal* pc, int64_t cache_lifetime_us) { - return rtc::scoped_refptr( - new rtc::RefCountedObject(pc, - cache_lifetime_us)); + return new rtc::RefCountedObject(pc, + cache_lifetime_us); } + // Since FakeRTCStatsCollector inherits twice from RefCountInterface, once via + // RTCStatsCollector and once via RTCStatsCollectorCallback, scoped_refptr + // will get confused about which AddRef()/Release() methods to call. + // So to remove all doubt, we declare them here again in the class that we + // give to scoped_refptr. + // Satisfying the implementation of these methods and associating them with a + // reference counter, will be done by RefCountedObject. + virtual void AddRef() const = 0; + virtual rtc::RefCountReleaseStatus Release() const = 0; + // RTCStatsCollectorCallback implementation. void OnStatsDelivered( const rtc::scoped_refptr& report) override {