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