Bug 1662087 - Replace explicit error handling involving `mozilla::Result::isErr` with IDB_TRY/IDB_TRY_VAR in IDBObjectStore.cpp; r=dom-workers-and-storage-reviewers,sg

Differential Revision: https://phabricator.services.mozilla.com/D88830
This commit is contained in:
Jan Varga 2020-09-07 15:52:39 +00:00
Родитель 87245d7d42
Коммит 30a12fc766
1 изменённых файлов: 54 добавлений и 54 удалений

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

@ -21,6 +21,7 @@
#include "IndexedDatabase.h"
#include "IndexedDatabaseInlines.h"
#include "IndexedDatabaseManager.h"
#include "IndexedDBCommon.h"
#include "KeyPath.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
@ -30,6 +31,7 @@
#include "js/StructuredClone.h"
#include "mozilla/EndianUtils.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/File.h"
@ -837,8 +839,9 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
IDBDatabase* const database = mTransaction->Database();
for (auto& file : files) {
auto fileAddInfoOrErr = [&file,
database]() -> Result<FileAddInfo, nsresult> {
IDB_TRY_VAR(
auto fileAddInfo,
([&file, database]() -> Result<FileAddInfo, nsresult> {
switch (file.Type()) {
case StructuredCloneFileBase::eBlob: {
MOZ_ASSERT(file.HasBlob());
@ -887,13 +890,10 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
default:
MOZ_CRASH("Should never get here!");
}
}();
}()),
nullptr, [&aRv](auto& result) { aRv = result.unwrapErr(); });
if (fileAddInfoOrErr.isErr()) {
aRv = fileAddInfoOrErr.unwrapErr();
return nullptr;
}
fileAddInfos.AppendElement(fileAddInfoOrErr.unwrap());
fileAddInfos.AppendElement(std::move(fileAddInfo));
}
}