Bug 1290809 - Remove MediaDecoder::IsEndedOrShutdown(). r=gerald

MozReview-Commit-ID: 4XUcJyQlmfk

--HG--
extra : rebase_source : fc2a044ca2776744ef0fff32300faf647666e73c
This commit is contained in:
JW Wang 2016-08-01 15:22:32 +08:00
Родитель 40cb773d8f
Коммит aace2f0c8d
3 изменённых файлов: 10 добавлений и 25 удалений

Просмотреть файл

@ -870,11 +870,7 @@ HTMLMediaElement::Ended()
return stream->IsFinished(); return stream->IsFinished();
} }
if (mDecoder) { return mDecoder && mDecoder->IsEnded();
return mDecoder->IsEndedOrShutdown();
}
return false;
} }
NS_IMETHODIMP HTMLMediaElement::GetEnded(bool* aEnded) NS_IMETHODIMP HTMLMediaElement::GetEnded(bool* aEnded)
@ -2670,7 +2666,7 @@ HTMLMediaElement::PlayInternal(bool aCallerIsChrome)
// Even if we just did Load() or ResumeLoad(), we could already have a decoder // Even if we just did Load() or ResumeLoad(), we could already have a decoder
// here if we managed to clone an existing decoder. // here if we managed to clone an existing decoder.
if (mDecoder) { if (mDecoder) {
if (mDecoder->IsEndedOrShutdown()) { if (mDecoder->IsEnded()) {
SetCurrentTime(0); SetCurrentTime(0);
} }
if (!mPausedForInactiveDocumentOrChannel) { if (!mPausedForInactiveDocumentOrChannel) {
@ -4083,7 +4079,7 @@ void HTMLMediaElement::PlaybackEnded()
// We changed state which can affect AddRemoveSelfReference // We changed state which can affect AddRemoveSelfReference
AddRemoveSelfReference(); AddRemoveSelfReference();
NS_ASSERTION(!mDecoder || mDecoder->IsEndedOrShutdown(), NS_ASSERTION(!mDecoder || mDecoder->IsEnded(),
"Decoder fired ended, but not in ended state"); "Decoder fired ended, but not in ended state");
// Discard all output streams that have finished now. // Discard all output streams that have finished now.
@ -4350,7 +4346,8 @@ HTMLMediaElement::UpdateReadyStateInternal()
return; return;
} }
if (mDownloadSuspendedByCache && mDecoder && !mDecoder->IsEndedOrShutdown() && if (mDownloadSuspendedByCache &&
mDecoder && !mDecoder->IsEnded() &&
mFirstFrameLoaded) { mFirstFrameLoaded) {
// The decoder has signaled that the download has been suspended by the // The decoder has signaled that the download has been suspended by the
// media cache. So move readyState into HAVE_ENOUGH_DATA, in case there's // media cache. So move readyState into HAVE_ENOUGH_DATA, in case there's
@ -4756,7 +4753,7 @@ bool HTMLMediaElement::IsPlaybackEnded() const
// the current playback position is equal to the effective end of the media resource. // the current playback position is equal to the effective end of the media resource.
// See bug 449157. // See bug 449157.
return mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA && return mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA &&
mDecoder ? mDecoder->IsEndedOrShutdown() : false; mDecoder && mDecoder->IsEnded();
} }
already_AddRefed<nsIPrincipal> HTMLMediaElement::GetCurrentPrincipal() already_AddRefed<nsIPrincipal> HTMLMediaElement::GetCurrentPrincipal()
@ -4870,7 +4867,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
#endif #endif
if (mDecoder) { if (mDecoder) {
mDecoder->Resume(); mDecoder->Resume();
if (!mPaused && !mDecoder->IsEndedOrShutdown()) { if (!mPaused && !mDecoder->IsEnded()) {
mDecoder->Play(); mDecoder->Play();
} }
} }
@ -4956,7 +4953,7 @@ void HTMLMediaElement::AddRemoveSelfReference()
bool needSelfReference = !mShuttingDown && bool needSelfReference = !mShuttingDown &&
ownerDoc->IsActive() && ownerDoc->IsActive() &&
(mDelayingLoadEvent || (mDelayingLoadEvent ||
(!mPaused && mDecoder && !mDecoder->IsEndedOrShutdown()) || (!mPaused && mDecoder && !mDecoder->IsEnded()) ||
(!mPaused && mSrcStream && !mSrcStream->IsFinished()) || (!mPaused && mSrcStream && !mSrcStream->IsFinished()) ||
(mDecoder && mDecoder->IsSeeking()) || (mDecoder && mDecoder->IsSeeking()) ||
CanActivateAutoplay() || CanActivateAutoplay() ||

Просмотреть файл

@ -1075,13 +1075,6 @@ MediaDecoder::IsSeeking() const
return mLogicallySeeking; return mLogicallySeeking;
} }
bool
MediaDecoder::IsEndedOrShutdown() const
{
MOZ_ASSERT(NS_IsMainThread());
return IsEnded() || IsShutdown();
}
bool bool
MediaDecoder::OwnerHasError() const MediaDecoder::OwnerHasError() const
{ {

Просмотреть файл

@ -241,10 +241,8 @@ public:
// Call on the main thread only. // Call on the main thread only.
bool IsSeeking() const; bool IsSeeking() const;
// Return true if the decoder has reached the end of playback or the decoder // Return true if the decoder has reached the end of playback.
// has shutdown. bool IsEnded() const;
// Call on the main thread only.
bool IsEndedOrShutdown() const;
// Return true if the MediaDecoderOwner's error attribute is not null. // Return true if the MediaDecoderOwner's error attribute is not null.
// Must be called before Shutdown(). // Must be called before Shutdown().
@ -531,9 +529,6 @@ protected:
// Cancel a timer for heuristic dormant. // Cancel a timer for heuristic dormant.
void CancelDormantTimer(); void CancelDormantTimer();
// Return true if the decoder has reached the end of playback
bool IsEnded() const;
bool IsShutdown() const; bool IsShutdown() const;
// Called by the state machine to notify the decoder that the duration // Called by the state machine to notify the decoder that the duration