Remove virtual inheritance from RTCStatsCollector
Bug: none
Change-Id: I5c3d93f3cc64c588c2f8e750c70c51c991736023
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215961
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33814}
diff --git a/api/stats/rtc_stats_collector_callback.h b/api/stats/rtc_stats_collector_callback.h
index c3e0824..506cc63 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 b5b8c8c..5f13f54 100644
--- a/pc/rtc_stats_collector.h
+++ b/pc/rtc_stats_collector.h
@@ -53,7 +53,7 @@
// 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<RTCStatsCollector> Create(
diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc
index 3ccdde0..6a56839 100644
--- a/pc/rtc_stats_collector_unittest.cc
+++ b/pc/rtc_stats_collector_unittest.cc
@@ -3215,11 +3215,20 @@
static rtc::scoped_refptr<FakeRTCStatsCollector> Create(
PeerConnectionInternal* pc,
int64_t cache_lifetime_us) {
- return rtc::scoped_refptr<FakeRTCStatsCollector>(
- new rtc::RefCountedObject<FakeRTCStatsCollector>(pc,
- cache_lifetime_us));
+ return new rtc::RefCountedObject<FakeRTCStatsCollector>(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<const RTCStatsReport>& report) override {