Bug 1244768 part 7 - refactor the Play() and PlayInternal() methods; r=jwwang

MozReview-Commit-ID: CP00vERdWMv

--HG--
extra : rebase_source : 87a269a7183ad73b703aad6e3e873df7d79e4c62
extra : intermediate-source : 339778ed6f0b202d03b87436845fe0046e1ccc2c
extra : source : 3c3d972cd4a09ca6e3ec1ef60fdf679023229208
This commit is contained in:
Kaku Kuo 2016-08-08 14:52:00 +08:00
Родитель a68e2e663c
Коммит 89e7d04f16
2 изменённых файлов: 14 добавлений и 12 удалений

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

@ -3698,17 +3698,16 @@ HTMLMediaElement::Play(ErrorResult& aRv)
return;
}
nsresult rv = PlayInternal();
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
PlayInternal(aRv);
UpdateCustomPolicyAfterPlayed();
}
nsresult
HTMLMediaElement::PlayInternal()
void
HTMLMediaElement::PlayInternal(ErrorResult& aRv)
{
MOZ_ASSERT(!aRv.Failed());
if (!IsAllowedToPlay()) {
// NOTE: for promise-based-play, will return a rejected promise here.
return NS_OK;
@ -3734,7 +3733,8 @@ HTMLMediaElement::PlayInternal()
if (!mPausedForInactiveDocumentOrChannel) {
nsresult rv = mDecoder->Play();
if (NS_FAILED(rv)) {
return rv;
aRv.Throw(rv);
return;
}
}
}
@ -3774,7 +3774,7 @@ HTMLMediaElement::PlayInternal()
}
}
return NS_OK;
return;
}
void
@ -3793,9 +3793,10 @@ NS_IMETHODIMP HTMLMediaElement::Play()
return NS_OK;
}
nsresult rv = PlayInternal();
if (NS_FAILED(rv)) {
return rv;
ErrorResult rv;
PlayInternal(rv);
if (rv.Failed()) {
return rv.StealNSResult();
}
UpdateCustomPolicyAfterPlayed();

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

@ -810,7 +810,8 @@ protected:
nsTArray<Pair<nsString, RefPtr<MediaInputPort>>> mTrackPorts;
};
nsresult PlayInternal();
// Will make this method return a already_AddRefed<Promise> in next patch.
void PlayInternal(ErrorResult& aRv);
/** Use this method to change the mReadyState member, so required
* events can be fired.