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

Differential Revision: https://phabricator.services.mozilla.com/D93989
This commit is contained in:
Simon Giesecke 2020-11-18 08:57:45 +00:00
Родитель 189e2e5353
Коммит 50d4600728
1 изменённых файлов: 15 добавлений и 14 удалений

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

@ -18321,35 +18321,36 @@ nsresult DatabaseOp::SendToIOThread() {
NS_IMETHODIMP
DatabaseOp::Run() {
nsresult rv;
const auto handleError = [this](const nsresult rv) {
if (mState != State::SendingResults) {
SetFailureCodeIfUnset(rv);
// Must set mState before dispatching otherwise we will race with the
// owning thread.
mState = State::SendingResults;
MOZ_ALWAYS_SUCCEEDS(
mOwningEventTarget->Dispatch(this, NS_DISPATCH_NORMAL));
}
};
switch (mState) {
case State::Initial:
rv = SendToIOThread();
IDB_TRY(SendToIOThread(), NS_OK, handleError);
break;
case State::DatabaseWork:
rv = DoDatabaseWork();
IDB_TRY(DoDatabaseWork(), NS_OK, handleError);
break;
case State::SendingResults:
SendResults();
return NS_OK;
break;
default:
MOZ_CRASH("Bad state!");
}
if (NS_WARN_IF(NS_FAILED(rv)) && mState != State::SendingResults) {
SetFailureCodeIfUnset(rv);
// Must set mState before dispatching otherwise we will race with the owning
// thread.
mState = State::SendingResults;
MOZ_ALWAYS_SUCCEEDS(mOwningEventTarget->Dispatch(this, NS_DISPATCH_NORMAL));
}
return NS_OK;
}