diff --git a/dom/media/ChannelMediaDecoder.cpp b/dom/media/ChannelMediaDecoder.cpp index b379e05df8fe..53b37647cd41 100644 --- a/dom/media/ChannelMediaDecoder.cpp +++ b/dom/media/ChannelMediaDecoder.cpp @@ -226,16 +226,6 @@ ChannelMediaDecoder::Shutdown() } } -nsresult -ChannelMediaDecoder::OpenResource(nsIStreamListener** aStreamListener) -{ - MOZ_ASSERT(NS_IsMainThread()); - if (aStreamListener) { - *aStreamListener = nullptr; - } - return mResource->Open(aStreamListener); -} - nsresult ChannelMediaDecoder::Load(nsIChannel* aChannel, bool aIsPrivateBrowsing, @@ -243,6 +233,7 @@ ChannelMediaDecoder::Load(nsIChannel* aChannel, { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!mResource); + MOZ_ASSERT(aStreamListener); mResource = BaseMediaResource::Create(mResourceCallback, aChannel, aIsPrivateBrowsing); @@ -255,7 +246,7 @@ ChannelMediaDecoder::Load(nsIChannel* aChannel, return rv; } - rv = OpenResource(aStreamListener); + rv = mResource->Open(aStreamListener); NS_ENSURE_SUCCESS(rv, rv); // Set mode to METADATA since we are about to read metadata. diff --git a/dom/media/ChannelMediaDecoder.h b/dom/media/ChannelMediaDecoder.h index 879cafff7c31..ce17b5abbe09 100644 --- a/dom/media/ChannelMediaDecoder.h +++ b/dom/media/ChannelMediaDecoder.h @@ -93,7 +93,6 @@ private: // Create a new state machine to run this decoder. MediaDecoderStateMachine* CreateStateMachine(); - nsresult OpenResource(nsIStreamListener** aStreamListener); nsresult Load(BaseMediaResource* aOriginal); // Called by MediaResource when the download has ended. diff --git a/dom/media/MediaCache.cpp b/dom/media/MediaCache.cpp index ce87c17a05c8..482a70fd8b1a 100644 --- a/dom/media/MediaCache.cpp +++ b/dom/media/MediaCache.cpp @@ -2536,10 +2536,7 @@ nsresult MediaCacheStream::Init(int64_t aContentLength) { NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); - - if (mMediaCache) { - return NS_OK; - } + MOZ_ASSERT(!mMediaCache, "Has been initialized."); if (aContentLength > 0) { uint32_t length = uint32_t(std::min(aContentLength, int64_t(UINT32_MAX))); diff --git a/dom/media/MediaResource.cpp b/dom/media/MediaResource.cpp index f6c9f198a1e6..9f6fbf39818c 100644 --- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -515,33 +515,27 @@ ChannelMediaResource::OnDataAvailable(nsIRequest* aRequest, return NS_OK; } -nsresult ChannelMediaResource::Open(nsIStreamListener **aStreamListener) +nsresult +ChannelMediaResource::Open(nsIStreamListener** aStreamListener) { NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); + MOZ_ASSERT(aStreamListener); + MOZ_ASSERT(mChannel); int64_t cl = -1; - if (mChannel) { - nsCOMPtr hc = do_QueryInterface(mChannel); - if (hc && !IsPayloadCompressed(hc)) { - if (NS_FAILED(hc->GetContentLength(&cl))) { - cl = -1; - } + nsCOMPtr hc = do_QueryInterface(mChannel); + if (hc && !IsPayloadCompressed(hc)) { + if (NS_FAILED(hc->GetContentLength(&cl))) { + cl = -1; } } nsresult rv = mCacheStream.Init(cl); - if (NS_FAILED(rv)) + if (NS_FAILED(rv)) { return rv; - NS_ASSERTION(mOffset == 0, "Who set mOffset already?"); - - if (!mChannel) { - // When we're a clone, the decoder might ask us to Open even though - // we haven't established an mChannel (because we might not need one) - NS_ASSERTION(!aStreamListener, - "Should have already been given a channel if we're to return a stream listener"); - return NS_OK; } + MOZ_ASSERT(mOffset == 0, "Who set mOffset already?"); return OpenChannel(aStreamListener); }