Bug 1648432 - Make use of Result::propagateErr. r=dom-workers-and-storage-reviewers,ttung

Differential Revision: https://phabricator.services.mozilla.com/D81298
This commit is contained in:
Simon Giesecke 2020-06-26 15:15:37 +00:00
Родитель d790918c7c
Коммит 150e174361
1 изменённых файлов: 18 добавлений и 19 удалений

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

@ -4071,7 +4071,7 @@ OpenDatabaseAndHandleBusy(mozIStorageService& aStorageService,
} }
if (NS_WARN_IF(connectionOrErr.isErr())) { if (NS_WARN_IF(connectionOrErr.isErr())) {
return Err(connectionOrErr.unwrapErr()); return connectionOrErr.propagateErr();
} }
return connectionOrErr; return connectionOrErr;
@ -4092,7 +4092,7 @@ CreateStorageConnection(nsIFile& aDBFile, nsIFile& aFMDirectory,
auto dbFileUrlOrErr = auto dbFileUrlOrErr =
GetDatabaseFileURL(aDBFile, aDirectoryLockId, aTelemetryId); GetDatabaseFileURL(aDBFile, aDirectoryLockId, aTelemetryId);
if (NS_WARN_IF(dbFileUrlOrErr.isErr())) { if (NS_WARN_IF(dbFileUrlOrErr.isErr())) {
return Err(dbFileUrlOrErr.unwrapErr()); return dbFileUrlOrErr.propagateErr();
} }
auto dbFileUrl = dbFileUrlOrErr.unwrap(); auto dbFileUrl = dbFileUrlOrErr.unwrap();
@ -4146,7 +4146,7 @@ CreateStorageConnection(nsIFile& aDBFile, nsIFile& aFMDirectory,
} }
if (NS_WARN_IF(connectionOrErr.isErr())) { if (NS_WARN_IF(connectionOrErr.isErr())) {
return Err(connectionOrErr.unwrapErr()); return connectionOrErr.propagateErr();
} }
} }
@ -4562,7 +4562,7 @@ GetStorageConnection(nsIFile& aDatabaseFile, const int64_t aDirectoryLockId,
auto dbFileUrlOrErr = auto dbFileUrlOrErr =
GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId, aTelemetryId); GetDatabaseFileURL(aDatabaseFile, aDirectoryLockId, aTelemetryId);
if (NS_WARN_IF(dbFileUrlOrErr.isErr())) { if (NS_WARN_IF(dbFileUrlOrErr.isErr())) {
return Err(dbFileUrlOrErr.unwrapErr()); return dbFileUrlOrErr.propagateErr();
} }
nsCOMPtr<mozIStorageService> ss = nsCOMPtr<mozIStorageService> ss =
@ -4574,7 +4574,7 @@ GetStorageConnection(nsIFile& aDatabaseFile, const int64_t aDirectoryLockId,
auto connectionOrErr = auto connectionOrErr =
OpenDatabaseAndHandleBusy(*ss, *dbFileUrlOrErr.inspect()); OpenDatabaseAndHandleBusy(*ss, *dbFileUrlOrErr.inspect());
if (NS_WARN_IF(connectionOrErr.isErr())) { if (NS_WARN_IF(connectionOrErr.isErr())) {
return Err(connectionOrErr.unwrapErr()); return connectionOrErr.propagateErr();
} }
auto connection = connectionOrErr.unwrap().unwrapBasePtr(); auto connection = connectionOrErr.unwrap().unwrapBasePtr();
@ -9152,8 +9152,7 @@ DeserializeStructuredCloneFiles(const FileManager& aFileManager,
auto structuredCloneFileOrErr = auto structuredCloneFileOrErr =
DeserializeStructuredCloneFile(aFileManager, token); DeserializeStructuredCloneFile(aFileManager, token);
if (NS_WARN_IF(structuredCloneFileOrErr.isErr())) { if (NS_WARN_IF(structuredCloneFileOrErr.isErr())) {
// XXX Can't this be written in a simpler way? return structuredCloneFileOrErr.propagateErr();
return Err(structuredCloneFileOrErr.unwrapErr());
} }
result.EmplaceBack(structuredCloneFileOrErr.unwrap()); result.EmplaceBack(structuredCloneFileOrErr.unwrap());
@ -9309,7 +9308,7 @@ SerializeStructuredCloneFiles(PBackgroundParent* aBackgroundActor,
} }
}); });
if (res.isErr()) { if (res.isErr()) {
return Err(res.unwrapErr()); return res.propagateErr();
} }
return std::move(serializedStructuredCloneFiles); return std::move(serializedStructuredCloneFiles);
@ -12024,7 +12023,7 @@ ConnectionPool::GetOrCreateConnection(const Database& aDatabase) {
GetStorageConnection(aDatabase.FilePath(), aDatabase.DirectoryLockId(), GetStorageConnection(aDatabase.FilePath(), aDatabase.DirectoryLockId(),
aDatabase.TelemetryId()); aDatabase.TelemetryId());
if (NS_WARN_IF(storageConnectionOrErr.isErr())) { if (NS_WARN_IF(storageConnectionOrErr.isErr())) {
return Err(storageConnectionOrErr.unwrapErr()); return storageConnectionOrErr.propagateErr();
} }
RefPtr<DatabaseConnection> connection = new DatabaseConnection( RefPtr<DatabaseConnection> connection = new DatabaseConnection(
@ -19296,7 +19295,7 @@ DatabaseOperationBase::GetStructuredCloneReadInfoFromBlob(
if (!aFileIds.IsVoid()) { if (!aFileIds.IsVoid()) {
auto filesOrErr = DeserializeStructuredCloneFiles(aFileManager, aFileIds); auto filesOrErr = DeserializeStructuredCloneFiles(aFileManager, aFileIds);
if (NS_WARN_IF(filesOrErr.isErr())) { if (NS_WARN_IF(filesOrErr.isErr())) {
return Err(filesOrErr.unwrapErr()); return filesOrErr.propagateErr();
} }
files = filesOrErr.unwrap(); files = filesOrErr.unwrap();
@ -19322,7 +19321,7 @@ DatabaseOperationBase::GetStructuredCloneReadInfoFromExternalBlob(
if (!aFileIds.IsVoid()) { if (!aFileIds.IsVoid()) {
auto filesOrErr = DeserializeStructuredCloneFiles(aFileManager, aFileIds); auto filesOrErr = DeserializeStructuredCloneFiles(aFileManager, aFileIds);
if (NS_WARN_IF(filesOrErr.isErr())) { if (NS_WARN_IF(filesOrErr.isErr())) {
return Err(filesOrErr.unwrapErr()); return filesOrErr.propagateErr();
} }
files = filesOrErr.unwrap(); files = filesOrErr.unwrap();
@ -22108,7 +22107,7 @@ Result<DatabaseSpec, nsresult> OpenDatabaseOp::MetadataToSpec() const {
fallible); fallible);
if (NS_WARN_IF(indexesOrErr.isErr())) { if (NS_WARN_IF(indexesOrErr.isErr())) {
return Err(indexesOrErr.unwrapErr()); return indexesOrErr.propagateErr();
} }
// XXX Assign rather than use the ctor, since the ctor always copies // XXX Assign rather than use the ctor, since the ctor always copies
// indexes. // indexes.
@ -22118,7 +22117,7 @@ Result<DatabaseSpec, nsresult> OpenDatabaseOp::MetadataToSpec() const {
}, },
fallible); fallible);
if (NS_WARN_IF(objectStoresOrErr.isErr())) { if (NS_WARN_IF(objectStoresOrErr.isErr())) {
return Err(objectStoresOrErr.unwrapErr()); return objectStoresOrErr.propagateErr();
} }
// XXX Assign rather than use the ctor, since the ctor always copies // XXX Assign rather than use the ctor, since the ctor always copies
@ -24105,7 +24104,7 @@ CreateIndexOp::UpdateIndexDataValuesFunction::OnFunctionCall(
/* aDataIndex */ 3, /* aDataIndex */ 3,
/* aFileIdsIndex */ 2, *mOp->mFileManager); /* aFileIdsIndex */ 2, *mOp->mFileManager);
if (NS_WARN_IF(cloneInfoOrErr.isErr())) { if (NS_WARN_IF(cloneInfoOrErr.isErr())) {
return Err(cloneInfoOrErr.unwrapErr()); return cloneInfoOrErr.propagateErr();
} }
auto cloneInfo = cloneInfoOrErr.unwrap(); auto cloneInfo = cloneInfoOrErr.unwrap();
@ -25526,7 +25525,7 @@ Result<T, nsresult> ObjectStoreGetRequestOp::ConvertResponse(
SerializeStructuredCloneFiles(mBackgroundParent, mDatabase, aInfo.Files(), SerializeStructuredCloneFiles(mBackgroundParent, mDatabase, aInfo.Files(),
std::is_same_v<T, PreprocessInfo>); std::is_same_v<T, PreprocessInfo>);
if (NS_WARN_IF(res.isErr())) { if (NS_WARN_IF(res.isErr())) {
return Err(res.unwrapErr()); return res.propagateErr();
} }
result.files() = res.unwrap(); result.files() = res.unwrap();
@ -25582,7 +25581,7 @@ nsresult ObjectStoreGetRequestOp::DoDatabaseWork(
auto cloneInfoOrErr = GetStructuredCloneReadInfoFromStatement( auto cloneInfoOrErr = GetStructuredCloneReadInfoFromStatement(
&*stmt, 1, 0, mDatabase->GetFileManager()); &*stmt, 1, 0, mDatabase->GetFileManager());
if (NS_WARN_IF(cloneInfoOrErr.isErr())) { if (NS_WARN_IF(cloneInfoOrErr.isErr())) {
return Err(cloneInfoOrErr.unwrapErr()); return cloneInfoOrErr.propagateErr();
} }
if (cloneInfoOrErr.inspect().HasPreprocessInfo()) { if (cloneInfoOrErr.inspect().HasPreprocessInfo()) {
@ -25631,7 +25630,7 @@ ObjectStoreGetRequestOp::GetPreprocessParams() {
}); });
if (NS_WARN_IF(res.isErr())) { if (NS_WARN_IF(res.isErr())) {
return Err(res.unwrapErr()); return res.propagateErr();
} }
return PreprocessParams{std::move(params)}; return PreprocessParams{std::move(params)};
@ -25641,7 +25640,7 @@ ObjectStoreGetRequestOp::GetPreprocessParams() {
auto res = ConvertResponse<PreprocessInfo>(std::move(mResponse[0])); auto res = ConvertResponse<PreprocessInfo>(std::move(mResponse[0]));
if (NS_WARN_IF(res.isErr())) { if (NS_WARN_IF(res.isErr())) {
return Err(res.unwrapErr()); return res.propagateErr();
} }
params.preprocessInfo() = res.unwrap(); params.preprocessInfo() = res.unwrap();
@ -26194,7 +26193,7 @@ void IndexGetRequestOp::GetResponse(RequestResponse& aResponse,
auto res = SerializeStructuredCloneFiles(mBackgroundParent, mDatabase, auto res = SerializeStructuredCloneFiles(mBackgroundParent, mDatabase,
info.Files(), false); info.Files(), false);
if (NS_WARN_IF(res.isErr())) { if (NS_WARN_IF(res.isErr())) {
return Err(res.unwrapErr()); return res.propagateErr();
} }
result.files() = res.unwrap(); result.files() = res.unwrap();