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
--- 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);