From 2834911596c6a9c387175956351d139c2ba5d8a3 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Thu, 17 Aug 2017 15:41:22 +0800 Subject: [PATCH] Bug 1391170 - lessen the assertion in AddMediaElementToURITable() so we can move MediaDecoder::GetResource() to private. r=gerald If AddMediaElementToURITable() is called after the decoder Load failed, mDecoder will be reset and it is sufficient to assert mDecoder only. MozReview-Commit-ID: 58WT8zFeiFj --HG-- extra : rebase_source : 712579b544e9a9ce971778b85795d06e58bd4ea5 extra : intermediate-source : 470e2d8a20010e11d7a7dce5540957e89439811e extra : source : 59f4b2b33212794aa1cf3e8782737a2d4af8c241 --- dom/html/HTMLMediaElement.cpp | 2 +- dom/media/ChannelMediaDecoder.h | 4 ++-- dom/media/MediaDecoder.h | 18 +++++++++--------- dom/media/hls/HLSDecoder.h | 4 ++-- dom/media/mediasource/MediaSourceDecoder.h | 3 +-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index f869eafeb231..5c3012b9b4bc 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3693,7 +3693,7 @@ MediaElementTableCount(HTMLMediaElement* aElement, nsIURI* aURI) void HTMLMediaElement::AddMediaElementToURITable() { - NS_ASSERTION(mDecoder && mDecoder->GetResource(), "Call this only with decoder Load called"); + NS_ASSERTION(mDecoder, "Call this only with decoder Load called"); NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 0, "Should not have entry for element in element table before addition"); if (!gElementTable) { diff --git a/dom/media/ChannelMediaDecoder.h b/dom/media/ChannelMediaDecoder.h index 9677023478a2..615cca25a03b 100644 --- a/dom/media/ChannelMediaDecoder.h +++ b/dom/media/ChannelMediaDecoder.h @@ -67,8 +67,6 @@ protected: public: explicit ChannelMediaDecoder(MediaDecoderInit& aInit); - MediaResource* GetResource() const override final; - void Shutdown() override; bool CanClone(); @@ -85,6 +83,8 @@ public: void Resume() override; private: + MediaResource* GetResource() const override final; + // Create a new state machine to run this decoder. MediaDecoderStateMachine* CreateStateMachine(); diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index bd1a628b384d..9ad3150c63cb 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -120,15 +120,6 @@ public: // Called if the media file encounters a network error. void NetworkError(); - // Get the current MediaResource being used. - // Note: The MediaResource is refcounted, but it outlives the MediaDecoder, - // so it's OK to use the reference returned by this function without - // refcounting, *unless* you need to store and use the reference after the - // MediaDecoder has been destroyed. You might need to do this if you're - // wrapping the MediaResource in some kind of byte stream interface to be - // passed to a platform decoder. - virtual MediaResource* GetResource() const = 0; - // Return the principal of the current URI being played or downloaded. virtual already_AddRefed GetCurrentPrincipal(); @@ -490,6 +481,15 @@ protected: media::TimeUnit::FromMicroseconds(250000); private: + // Get the current MediaResource being used. + // Note: The MediaResource is refcounted, but it outlives the MediaDecoder, + // so it's OK to use the reference returned by this function without + // refcounting, *unless* you need to store and use the reference after the + // MediaDecoder has been destroyed. You might need to do this if you're + // wrapping the MediaResource in some kind of byte stream interface to be + // passed to a platform decoder. + virtual MediaResource* GetResource() const = 0; + nsCString GetDebugInfo(); // Called when the owner's activity changed. diff --git a/dom/media/hls/HLSDecoder.h b/dom/media/hls/HLSDecoder.h index 24ddb3611f01..4e5614cac27f 100644 --- a/dom/media/hls/HLSDecoder.h +++ b/dom/media/hls/HLSDecoder.h @@ -21,8 +21,6 @@ public: { } - MediaResource* GetResource() const override final; - void Shutdown() override; // Returns true if the HLS backend is pref'ed on. @@ -43,6 +41,8 @@ public: void Resume() override; private: + MediaResource* GetResource() const override final; + MediaDecoderStateMachine* CreateStateMachine(); bool CanPlayThroughImpl() override final diff --git a/dom/media/mediasource/MediaSourceDecoder.h b/dom/media/mediasource/MediaSourceDecoder.h index 13e2e6f540d3..5a7937927293 100644 --- a/dom/media/mediasource/MediaSourceDecoder.h +++ b/dom/media/mediasource/MediaSourceDecoder.h @@ -27,8 +27,6 @@ class MediaSourceDecoder : public MediaDecoder public: explicit MediaSourceDecoder(MediaDecoderInit& aInit); - MediaResource* GetResource() const override final; - nsresult Load(nsIPrincipal* aPrincipal); media::TimeIntervals GetSeekable() override; media::TimeIntervals GetBuffered() override; @@ -64,6 +62,7 @@ public: void NotifyInitDataArrived(); private: + MediaResource* GetResource() const override final; MediaDecoderStateMachine* CreateStateMachine(); void DoSetMediaSourceDuration(double aDuration); media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);