Bug 1876724 - Allow IdentityCredentialStorageCleaner to start up during shutdown, so long as it will still shut itself down later - r=pbz

Differential Revision: https://phabricator.services.mozilla.com/D200789
This commit is contained in:
Benjamin VanderSloot 2024-02-23 19:08:35 +00:00
parent 1aa077fc94
commit 57c8f700d1

View file

@ -125,18 +125,23 @@ IdentityCredentialStorageService::GetAsyncShutdownBarrier() const {
nsresult IdentityCredentialStorageService::Init() {
AssertIsOnMainThread();
if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) {
nsCOMPtr<nsIAsyncShutdownClient> asc = GetAsyncShutdownBarrier();
if (!asc) {
return NS_ERROR_NOT_AVAILABLE;
}
// We should only allow this service to start before its
// shutdown barrier is closed, so it never leaks.
bool closed;
nsresult rv = asc->GetIsClosed(&closed);
if (closed || NS_WARN_IF(NS_FAILED(rv))) {
MonitorAutoLock lock(mMonitor);
mShuttingDown.Flip();
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
}
nsCOMPtr<nsIAsyncShutdownClient> asc = GetAsyncShutdownBarrier();
if (!asc) {
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv = asc->AddBlocker(this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__),
__LINE__, u""_ns);
rv = asc->AddBlocker(this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u""_ns);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,