diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h index 373b7586de..66a12f4fac 100644 --- a/api/peer_connection_interface.h +++ b/api/peer_connection_interface.h @@ -950,8 +950,6 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface { rtc::scoped_refptr selector, rtc::scoped_refptr callback) = 0; // Clear cached stats in the RTCStatsCollector. - // Exposed for testing while waiting for automatic cache clear to work. - // https://bugs.webrtc.org/8693 virtual void ClearStatsCache() {} // Create a data channel with the provided config, or default config if none diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 367341bbb3..1c0e695158 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -2985,6 +2985,9 @@ CryptoOptions PeerConnection::GetCryptoOptions() { void PeerConnection::ClearStatsCache() { RTC_DCHECK_RUN_ON(signaling_thread()); + if (legacy_stats_) { + legacy_stats_->InvalidateCache(); + } if (stats_collector_) { stats_collector_->ClearCachedStatsReport(); } diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h index bc1ce183e7..1bca156316 100644 --- a/pc/peer_connection_internal.h +++ b/pc/peer_connection_internal.h @@ -125,6 +125,8 @@ class PeerConnectionSdpMethods { virtual void ResetSctpDataMid() = 0; virtual const FieldTrialsView& trials() const = 0; + + virtual void ClearStatsCache() = 0; }; // Functions defined in this class are called by other objects, diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 6936029b50..9a5023cd0b 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -1488,10 +1488,10 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(desc); - // Invalidate the legacy stats cache to make sure that it gets updated next - // time getStats() gets called, as updating the session description affects - // the stats. - pc_->legacy_stats()->InvalidateCache(); + // Invalidate the stats caches to make sure that they get + // updated the next time getStats() gets called, as updating the session + // description affects the stats. + pc_->ClearStatsCache(); // Take a reference to the old local description since it's used below to // compare against the new local description. When setting the new local @@ -1823,10 +1823,10 @@ void SdpOfferAnswerHandler::ApplyRemoteDescription( RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(operation->description()); - // Invalidate the [legacy] stats cache to make sure that it gets updated next - // time getStats() gets called, as updating the session description affects - // the stats. - pc_->legacy_stats()->InvalidateCache(); + // Invalidate the stats caches to make sure that they get + // updated next time getStats() gets called, as updating the session + // description affects the stats. + pc_->ClearStatsCache(); if (!operation->ReplaceRemoteDescriptionAndCheckEror()) return;