Bug 1371882 - Move MEDIACACHESTREAM_NOTIFIED_LENGTH telemetry collection to MediaCacheStream::Init - r=cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 12 Jun 2017 14:27:46 +1200
changeset 595155 cad3880119afe6dee6e2478a1cdc8c8998815ea4
parent 595154 09c1f126c7da491ed7db18c76fb397f7673e431c
child 595156 6b975af79ceafe876e3ea780a6d3a1ce7d319281
push id64265
push usergsquelart@mozilla.com
push dateFri, 16 Jun 2017 03:37:56 +0000
reviewerscpearce
bugs1371882
milestone56.0a1
Bug 1371882 - Move MEDIACACHESTREAM_NOTIFIED_LENGTH telemetry collection to MediaCacheStream::Init - r=cpearce The initial telemetry collection was done in NotifyDataLength() because that was the first point where the length was introduced; but some extra code was needed to ensure that were collecting the first length. Now that this initial length is passed directly to Init(), we can report that number instead. In the "worst" case, it will actually be a bit more correct about what we initially wanted to report, i.e., the initial length given by the HTTP response header; and it's what we really want to know, now that we are using this number to make a decision about which MediaCache to use. MozReview-Commit-ID: 11Th8pensZt
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1840,26 +1840,16 @@ MediaCache::NoteSeek(MediaCacheStream* a
   }
 }
 
 void
 MediaCacheStream::NotifyDataLength(int64_t aLength)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  if (mStreamLength < 0 && aLength >= 0) {
-    uint32_t length = uint32_t(std::min(aLength, int64_t(UINT32_MAX)));
-    LOG("MediaCacheStream::NotifyDataLength(this=%p) "
-        "MEDIACACHESTREAM_NOTIFIED_LENGTH=%" PRIu32,
-        this,
-        length);
-    Telemetry::Accumulate(
-      Telemetry::HistogramID::MEDIACACHESTREAM_NOTIFIED_LENGTH, length);
-  }
-
   ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
   mStreamLength = aLength;
 }
 
 void
 MediaCacheStream::NotifyDataStarted(int64_t aOffset)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
@@ -2548,16 +2538,24 @@ MediaCacheStream::Init(int64_t aContentL
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   if (mMediaCache) {
     return NS_OK;
   }
 
   if (aContentLength > 0) {
+    uint32_t length = uint32_t(std::min(aContentLength, int64_t(UINT32_MAX)));
+    LOG("MediaCacheStream::NotifyDataLength(this=%p) "
+        "MEDIACACHESTREAM_NOTIFIED_LENGTH=%" PRIu32,
+        this,
+        length);
+    Telemetry::Accumulate(
+      Telemetry::HistogramID::MEDIACACHESTREAM_NOTIFIED_LENGTH, length);
+
     mStreamLength = aContentLength;
   }
 
   mMediaCache = MediaCache::GetMediaCache(aContentLength);
   if (!mMediaCache) {
     return NS_ERROR_FAILURE;
   }
   mMediaCache->OpenStream(this);