Ensure that PC usage is recorded if a PC is alive for 60 seconds.


Bug: chromium:718508
Change-Id: Id2cbcb370b56cb8a6a6c821e0f89c51089cc8e6b
Reviewed-on: https://webrtc-review.googlesource.com/83140
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23723}
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index 5526d72..f4dcb51 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -106,8 +106,11 @@
   MSG_CREATE_SESSIONDESCRIPTION_FAILED,
   MSG_GETSTATS,
   MSG_FREE_DATACHANNELS,
+  MSG_REPORT_USAGE_PATTERN,
 };
 
+static const int REPORT_USAGE_PATTERN_DELAY_MS = 60000;
+
 struct SetSessionDescriptionMsg : public rtc::MessageData {
   explicit SetSessionDescriptionMsg(
       webrtc::SetSessionDescriptionObserver* observer)
@@ -1037,6 +1040,10 @@
         RtpTransceiverProxyWithInternal<RtpTransceiver>::Create(
             signaling_thread(), new RtpTransceiver(cricket::MEDIA_TYPE_VIDEO)));
   }
+  signaling_thread()->PostDelayed(
+      RTC_FROM_HERE,
+      return_histogram_very_quickly_ ? 0 : REPORT_USAGE_PATTERN_DELAY_MS, this,
+      MSG_REPORT_USAGE_PATTERN, nullptr);
   return true;
 }
 
@@ -3300,6 +3307,10 @@
       sctp_data_channels_to_free_.clear();
       break;
     }
+    case MSG_REPORT_USAGE_PATTERN: {
+      ReportUsagePattern();
+      break;
+    }
     default:
       RTC_NOTREACHED() << "Not implemented";
       break;