Bug 1366930 - Correct error handling in mozilla::MediaShutdownManager::InitStatics. r=gerald

Resetting sInstance in MediaShutdownManager::InitStatics() will cause
MediaShutdownManager::Instance().Register() to crash immediately without
a chance to handle the error in Register().

Instead, we keep an error code to know whether to bail out in Register().

MozReview-Commit-ID: EGqL1407Gh

--HG--
extra : rebase_source : 055dfc35d854c93013067971f0c9f813c8654708
This commit is contained in:
JW Wang 2017-05-23 11:02:56 +08:00
Родитель e008ecdf2f
Коммит 975c6c5f18
2 изменённых файлов: 3 добавлений и 2 удалений

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

@ -78,7 +78,7 @@ MediaShutdownManager::InitStatics()
NS_LITERAL_STRING("MediaShutdownManager shutdown"));
if (NS_FAILED(rv)) {
LOGW("Failed to add shutdown blocker! rv=%x", uint32_t(rv));
sInstance = nullptr;
sInstance->mError = rv;
}
}
@ -99,7 +99,7 @@ nsresult
MediaShutdownManager::Register(MediaDecoder* aDecoder)
{
MOZ_ASSERT(NS_IsMainThread());
if (!sInstance) {
if (NS_FAILED(mError)) {
return NS_ERROR_NOT_INITIALIZED;
}
if (mIsDoingXPCOMShutDown) {

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

@ -83,6 +83,7 @@ private:
nsTHashtable<nsRefPtrHashKey<MediaDecoder>> mDecoders;
bool mIsDoingXPCOMShutDown = false;
nsresult mError = NS_OK;
};
} // namespace mozilla