diff --git a/dom/media/MediaCache.cpp b/dom/media/MediaCache.cpp index 9c5b0db327ff..ce87c17a05c8 100644 --- a/dom/media/MediaCache.cpp +++ b/dom/media/MediaCache.cpp @@ -2561,17 +2561,13 @@ MediaCacheStream::Init(int64_t aContentLength) return NS_OK; } -nsresult +void MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal) { - if (!aOriginal->IsAvailableForSharing()) - return NS_ERROR_FAILURE; + MOZ_ASSERT(aOriginal->IsAvailableForSharing()); + MOZ_ASSERT(!mMediaCache, "Has been initialized."); + MOZ_ASSERT(aOriginal->mMediaCache, "Don't clone an uninitialized stream."); - if (mMediaCache) { - return NS_OK; - } - - NS_ASSERTION(aOriginal->mMediaCache, "Don't clone an uninitialized stream"); // Use the same MediaCache as our clone. mMediaCache = aOriginal->mMediaCache; @@ -2609,8 +2605,6 @@ MediaCacheStream::InitAsClone(MediaCacheStream* aOriginal) // stream offset is zero mMediaCache->AddBlockOwnerAsReadahead(cacheBlockIndex, this, i); } - - return NS_OK; } nsresult MediaCacheStream::GetCachedRanges(MediaByteRangeSet& aRanges) diff --git a/dom/media/MediaCache.h b/dom/media/MediaCache.h index 90c2962a32b5..486dd6899022 100644 --- a/dom/media/MediaCache.h +++ b/dom/media/MediaCache.h @@ -205,10 +205,10 @@ public: nsresult Init(int64_t aContentLength); // Set up this stream with the cache, assuming it's for the same data - // as the aOriginal stream. Can fail on OOM. + // as the aOriginal stream. // Exactly one of InitAsClone or Init must be called before any other method - // on this class. Does nothing if already initialized. - nsresult InitAsClone(MediaCacheStream* aOriginal); + // on this class. + void InitAsClone(MediaCacheStream* aOriginal); // These are called on the main thread. // Tell us whether the stream is seekable or not. Non-seekable streams