Bug 1769624 - Verify shutdown status before asserting r=nika

Differential Revision: https://phabricator.services.mozilla.com/D146567
This commit is contained in:
Alexandre Lissy 2022-05-17 20:44:24 +00:00
Родитель 5b3d5c09ae
Коммит 9ba8c615d5
1 изменённых файлов: 17 добавлений и 5 удалений

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

@ -126,6 +126,7 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessManager::LaunchProcess(
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
if (IsShutdown()) { if (IsShutdown()) {
NS_WARNING("Reject early LaunchProcess() for Shutdown");
return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__); __func__);
} }
@ -133,6 +134,7 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessManager::LaunchProcess(
RefPtr<ProcessFields> p = GetProcess(aSandbox); RefPtr<ProcessFields> p = GetProcess(aSandbox);
if (p && p->mNumProcessAttempts) { if (p && p->mNumProcessAttempts) {
// We failed to start the Utility process earlier, abort now. // We failed to start the Utility process earlier, abort now.
NS_WARNING("Reject LaunchProcess() for earlier mNumProcessAttempts");
return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__); __func__);
} }
@ -156,6 +158,7 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessManager::LaunchProcess(
if (!p->mProcess->Launch(extraArgs)) { if (!p->mProcess->Launch(extraArgs)) {
p->mNumProcessAttempts++; p->mNumProcessAttempts++;
DestroyProcess(aSandbox); DestroyProcess(aSandbox);
NS_WARNING("Reject LaunchProcess() for mNumProcessAttempts++");
return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE, return GenericNonExclusivePromise::CreateAndReject(NS_ERROR_NOT_AVAILABLE,
__func__); __func__);
} }
@ -165,11 +168,13 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessManager::LaunchProcess(
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
[self, p, aSandbox](bool) { [self, p, aSandbox](bool) {
if (self->IsShutdown()) { if (self->IsShutdown()) {
NS_WARNING("Reject LaunchProcess() after LaunchPromise() for Shutdown");
return GenericNonExclusivePromise::CreateAndReject( return GenericNonExclusivePromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__); NS_ERROR_NOT_AVAILABLE, __func__);
} }
if (self->IsProcessDestroyed(aSandbox)) { if (self->IsProcessDestroyed(aSandbox)) {
NS_WARNING("Reject LaunchProcess() after LaunchPromise() for destroyed process");
return GenericNonExclusivePromise::CreateAndReject( return GenericNonExclusivePromise::CreateAndReject(
NS_ERROR_NOT_AVAILABLE, __func__); NS_ERROR_NOT_AVAILABLE, __func__);
} }
@ -194,6 +199,7 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessManager::LaunchProcess(
p->mNumProcessAttempts++; p->mNumProcessAttempts++;
self->DestroyProcess(aSandbox); self->DestroyProcess(aSandbox);
} }
NS_WARNING("Reject LaunchProcess() for LaunchPromise() rejection");
return GenericNonExclusivePromise::CreateAndReject(aError, __func__); return GenericNonExclusivePromise::CreateAndReject(aError, __func__);
}); });
@ -244,8 +250,11 @@ RefPtr<GenericNonExclusivePromise> UtilityProcessManager::StartUtility(
return GenericNonExclusivePromise::CreateAndResolve(true, __func__); return GenericNonExclusivePromise::CreateAndResolve(true, __func__);
}, },
[](nsresult aError) { [self](nsresult aError) {
if (!self->IsShutdown()) {
MOZ_ASSERT_UNREACHABLE("Failure when starting actor"); MOZ_ASSERT_UNREACHABLE("Failure when starting actor");
}
NS_WARNING("Reject StartUtility() for LaunchProcess() rejection");
return GenericNonExclusivePromise::CreateAndReject(aError, __func__); return GenericNonExclusivePromise::CreateAndReject(aError, __func__);
}); });
} }
@ -289,9 +298,12 @@ UtilityProcessManager::StartAudioDecoding(base::ProcessId aOtherProcess) {
return AudioDecodingPromise::CreateAndResolve(std::move(childPipe), return AudioDecodingPromise::CreateAndResolve(std::move(childPipe),
__func__); __func__);
}, },
[](nsresult aError) { [self](nsresult aError) {
if (!self->IsShutdown()) {
MOZ_ASSERT_UNREACHABLE( MOZ_ASSERT_UNREACHABLE(
"PUtilityAudioDecoder: failure when starting actor"); "PUtilityAudioDecoder: failure when starting actor");
}
NS_WARNING("Reject StartAudioDecoding() for StartUtility() rejection");
return AudioDecodingPromise::CreateAndReject(aError, __func__); return AudioDecodingPromise::CreateAndReject(aError, __func__);
}); });
} }