Bug 1417305. P2 - move some code from NotifyDataEnded() into NotifyDownloadEnded() to make the code more readable.
MozReview-Commit-ID: LveThVjuemq
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -99,29 +99,18 @@ ChannelMediaDecoder::ResourceCallback::N
TimerCallback, this, sDelay, nsITimer::TYPE_ONE_SHOT,
"ChannelMediaDecoder::ResourceCallback::TimerCallback");
}
void
ChannelMediaDecoder::ResourceCallback::NotifyDataEnded(nsresult aStatus)
{
MOZ_ASSERT(NS_IsMainThread());
- if (!mDecoder) {
- return;
- }
- mDecoder->NotifyDownloadEnded(aStatus);
- if (NS_SUCCEEDED(aStatus)) {
- MediaDecoderOwner* owner = GetMediaOwner();
- MOZ_ASSERT(owner);
- owner->DownloadSuspended();
-
- // NotifySuspendedStatusChanged will tell the element that download
- // has been suspended "by the cache", which is true since we never
- // download anything. The element can then transition to HAVE_ENOUGH_DATA.
- owner->NotifySuspendedByCache(true);
+ if (mDecoder) {
+ mDecoder->NotifyDownloadEnded(aStatus);
}
}
void
ChannelMediaDecoder::ResourceCallback::NotifyPrincipalChanged()
{
MOZ_ASSERT(NS_IsMainThread());
if (mDecoder) {
@@ -300,29 +289,31 @@ void
ChannelMediaDecoder::NotifyDownloadEnded(nsresult aStatus)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
AbstractThread::AutoEnter context(AbstractMainThread());
LOG("NotifyDownloadEnded, status=%" PRIx32, static_cast<uint32_t>(aStatus));
+ MediaDecoderOwner* owner = GetOwner();
if (aStatus == NS_BINDING_ABORTED) {
// Download has been cancelled by user.
- GetOwner()->LoadAborted();
+ owner->LoadAborted();
return;
}
UpdatePlaybackRate();
if (NS_SUCCEEDED(aStatus)) {
- // A final progress event will be fired by the MediaResource calling
- // DownloadSuspended on the element.
- // Also NotifySuspendedStatusChanged() will be called to update readyState
- // if download ended with success.
+ owner->DownloadSuspended();
+ // NotifySuspendedStatusChanged will tell the element that download
+ // has been suspended "by the cache", which is true since we never
+ // download anything. The element can then transition to HAVE_ENOUGH_DATA.
+ owner->NotifySuspendedByCache(true);
} else if (aStatus != NS_BASE_STREAM_CLOSED) {
NetworkError();
}
}
void
ChannelMediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
{