Add API to report "interesting" usage patterns to PC client

Bug: chromium:866792
Change-Id: Ic8bec5494aaa617c833c90be2b912f7367b44929
Reviewed-on: https://webrtc-review.googlesource.com/90246
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24111}
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index 6edc19a..9f38a5d 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -5948,6 +5948,17 @@
   RTC_HISTOGRAM_ENUMERATION_SPARSE("WebRTC.PeerConnection.UsagePattern",
                                    usage_event_accumulator_,
                                    static_cast<int>(UsageEvent::MAX_VALUE));
+  const int bad_bits =
+      static_cast<int>(UsageEvent::SET_LOCAL_DESCRIPTION_CALLED) |
+      static_cast<int>(UsageEvent::CANDIDATE_COLLECTED);
+  const int good_bits =
+      static_cast<int>(UsageEvent::SET_REMOTE_DESCRIPTION_CALLED) |
+      static_cast<int>(UsageEvent::REMOTE_CANDIDATE_ADDED) |
+      static_cast<int>(UsageEvent::ICE_STATE_CONNECTED);
+  if ((usage_event_accumulator_ & bad_bits) == bad_bits &&
+      (usage_event_accumulator_ & good_bits) == 0) {
+    observer_->OnInterestingUsage(usage_event_accumulator_);
+  }
 }
 
 void PeerConnection::ReportNegotiatedSdpSemantics(