Bug 1663924 - Use IDB_TRY in Maintenance::Run. r=dom-workers-and-storage-reviewers,ttung

Differential Revision: https://phabricator.services.mozilla.com/D93990
This commit is contained in:
Simon Giesecke 2020-11-18 08:58:37 +00:00
Родитель 50d4600728
Коммит 0777f29688
1 изменённых файлов: 24 добавлений и 24 удалений

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

@ -14155,54 +14155,54 @@ NS_IMETHODIMP
Maintenance::Run() {
MOZ_ASSERT(mState != State::Complete);
nsresult rv;
const auto handleError = [this](const nsresult rv) {
if (mState != State::Finishing) {
if (NS_SUCCEEDED(mResultCode)) {
mResultCode = rv;
}
// Must set mState before dispatching otherwise we will race with the
// owning thread.
mState = State::Finishing;
if (IsOnBackgroundThread()) {
Finish();
} else {
MOZ_ALWAYS_SUCCEEDS(mQuotaClient->BackgroundThread()->Dispatch(
this, NS_DISPATCH_NORMAL));
}
}
};
switch (mState) {
case State::Initial:
rv = Start();
IDB_TRY(Start(), NS_OK, handleError);
break;
case State::CreateIndexedDatabaseManager:
rv = CreateIndexedDatabaseManager();
IDB_TRY(CreateIndexedDatabaseManager(), NS_OK, handleError);
break;
case State::IndexedDatabaseManagerOpen:
rv = OpenDirectory();
IDB_TRY(OpenDirectory(), NS_OK, handleError);
break;
case State::DirectoryWorkOpen:
rv = DirectoryWork();
IDB_TRY(DirectoryWork(), NS_OK, handleError);
break;
case State::BeginDatabaseMaintenance:
rv = BeginDatabaseMaintenance();
IDB_TRY(BeginDatabaseMaintenance(), NS_OK, handleError);
break;
case State::Finishing:
Finish();
return NS_OK;
break;
default:
MOZ_CRASH("Bad state!");
}
if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::Finishing) {
if (NS_SUCCEEDED(mResultCode)) {
mResultCode = rv;
}
// Must set mState before dispatching otherwise we will race with the owning
// thread.
mState = State::Finishing;
if (IsOnBackgroundThread()) {
Finish();
} else {
MOZ_ALWAYS_SUCCEEDS(
mQuotaClient->BackgroundThread()->Dispatch(this, NS_DISPATCH_NORMAL));
}
}
return NS_OK;
}