peerconnection: invalidate stats cache during SLD/SRD

which may allow caching some relatively persistent statistics
such as codec statistics that only change during renegotiation.

BUG=webrtc:8693

Change-Id: Ifd68c9d666d9f328d0efecb64e4201d003788ca8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273324
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37981}
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 6936029..9a5023c 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -1488,10 +1488,10 @@
   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 @@
   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;