Bug 1221009. Part 3 - add assertions to functions that shouldn't be called after shutdown. r=roc.

This commit is contained in:
JW Wang 2015-11-16 07:51:22 +08:00
Родитель 14c8d627dd
Коммит 5dd1840487
1 изменённых файлов: 8 добавлений и 13 удалений

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

@ -476,6 +476,7 @@ void
MediaDecoder::SetInfinite(bool aInfinite) MediaDecoder::SetInfinite(bool aInfinite)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
mInfiniteStream = aInfinite; mInfiniteStream = aInfinite;
DurationChanged(); DurationChanged();
} }
@ -872,6 +873,7 @@ nsresult
MediaDecoder::FinishDecoderSetup(MediaResource* aResource) MediaDecoder::FinishDecoderSetup(MediaResource* aResource)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
HTMLMediaElement* element = mOwner->GetMediaElement(); HTMLMediaElement* element = mOwner->GetMediaElement();
NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
element->FinishDecoderSetup(this, aResource); element->FinishDecoderSetup(this, aResource);
@ -882,8 +884,7 @@ void
MediaDecoder::ResetConnectionState() MediaDecoder::ResetConnectionState()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) MOZ_ASSERT(!mShuttingDown);
return;
// Notify the media element that connection gets lost. // Notify the media element that connection gets lost.
mOwner->ResetConnectionState(); mOwner->ResetConnectionState();
@ -1027,9 +1028,7 @@ void
MediaDecoder::NotifySuspendedStatusChanged() MediaDecoder::NotifySuspendedStatusChanged()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) { MOZ_ASSERT(!mShuttingDown);
return;
}
if (mResource) { if (mResource) {
bool suspended = mResource->IsSuspendedByCache(); bool suspended = mResource->IsSuspendedByCache();
mOwner->NotifySuspendedByCache(suspended); mOwner->NotifySuspendedByCache(suspended);
@ -1051,10 +1050,7 @@ void
MediaDecoder::NotifyDownloadEnded(nsresult aStatus) MediaDecoder::NotifyDownloadEnded(nsresult aStatus)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
if (mShuttingDown) {
return;
}
DECODER_LOG("NotifyDownloadEnded, status=%x", aStatus); DECODER_LOG("NotifyDownloadEnded, status=%x", aStatus);
@ -1080,9 +1076,7 @@ void
MediaDecoder::NotifyPrincipalChanged() MediaDecoder::NotifyPrincipalChanged()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) { MOZ_ASSERT(!mShuttingDown);
return;
}
mOwner->NotifyDecoderPrincipalChanged(); mOwner->NotifyDecoderPrincipalChanged();
} }
@ -1090,8 +1084,9 @@ void
MediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!mShuttingDown);
if (mShuttingDown || mIgnoreProgressData) { if (mIgnoreProgressData) {
return; return;
} }