Bug 1417305. P2 - move some code from NotifyDataEnded() into NotifyDownloadEnded() to make the code more readable. r=bechen,gerald

MozReview-Commit-ID: LveThVjuemq

--HG--
extra : rebase_source : 8a3164b767fa86468725de9401db308daeba591d
This commit is contained in:
JW Wang 2017-11-15 11:07:06 +08:00
Родитель e02c72ba9e
Коммит 15d26ae3e8
1 изменённых файлов: 9 добавлений и 18 удалений

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

@ -104,19 +104,8 @@ 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);
}
}
@ -305,19 +294,21 @@ ChannelMediaDecoder::NotifyDownloadEnded(nsresult aStatus)
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();
}