Loading dom/fs/parent/datamodel/FileSystemDatabaseManagerVersion001.cpp +18 −7 Original line number Diff line number Diff line Loading @@ -329,14 +329,23 @@ Result<EntryId, QMResult> FindEntryId(const FileSystemConnection& aConnection, return entryId; } bool IsSame(const FileSystemConnection& aConnection, Result<bool, QMResult> IsSame(const FileSystemConnection& aConnection, const FileSystemEntryMetadata& aHandle, const FileSystemChildMetadata& aNewHandle, bool aIsFile) { const FileSystemChildMetadata& aNewHandle, bool aIsFile) { MOZ_ASSERT(!aNewHandle.parentId().IsEmpty()); QM_TRY_UNWRAP(EntryId entryId, FindEntryId(aConnection, aNewHandle, aIsFile), false); // Typically aNewHandle does not exist which is not an error QM_TRY_RETURN(QM_OR_ELSE_LOG_VERBOSE_IF( // Expression. FindEntryId(aConnection, aNewHandle, aIsFile) .map([&aHandle](const EntryId& entryId) { return entryId == aHandle.entryId(); }), // Predicate. IsSpecificError<NS_ERROR_DOM_NOT_FOUND_ERR>, // Fallback. ErrToOkFromQMResult<false>)); } Result<bool, QMResult> IsFile(const FileSystemConnection& aConnection, Loading Loading @@ -1338,7 +1347,9 @@ Result<bool, QMResult> FileSystemDatabaseManagerVersion001::MoveEntry( // If the rename doesn't change the name or directory, just return success. // XXX Needs to be added to the spec if (IsSame(mConnection, aHandle, aNewDesignation, isFile)) { QM_WARNONLY_TRY_UNWRAP(Maybe<bool> maybeSame, IsSame(mConnection, aHandle, aNewDesignation, isFile)); if (maybeSame && maybeSame.value()) { return true; } Loading dom/quota/QuotaCommon.h +12 −0 Original line number Diff line number Diff line Loading @@ -1061,6 +1061,13 @@ bool IsSpecificError(const nsresult aValue) { return aValue == ErrorValue; } #ifdef QM_ERROR_STACKS_ENABLED template <nsresult ErrorValue> bool IsSpecificError(const QMResult& aValue) { return aValue.NSResult() == ErrorValue; } #endif // Helper template function so that QM_TRY fallback functions that are // converting errors into specific in-band success values can be concisely // written as ErrToOk<SuccessValueToReturn> (with the return type inferred). Loading @@ -1073,6 +1080,11 @@ auto ErrToOk(const nsresult aValue) -> Result<V, nsresult> { return V{SuccessValue}; } template <auto SuccessValue, typename V = decltype(SuccessValue)> auto ErrToOkFromQMResult(const QMResult& aValue) -> Result<V, QMResult> { return V{SuccessValue}; } // Helper template function so that QM_TRY fallback functions that are // suppressing errors by converting them into (generic) success can be // concisely written as ErrToDefaultOk<>. Loading Loading
dom/fs/parent/datamodel/FileSystemDatabaseManagerVersion001.cpp +18 −7 Original line number Diff line number Diff line Loading @@ -329,14 +329,23 @@ Result<EntryId, QMResult> FindEntryId(const FileSystemConnection& aConnection, return entryId; } bool IsSame(const FileSystemConnection& aConnection, Result<bool, QMResult> IsSame(const FileSystemConnection& aConnection, const FileSystemEntryMetadata& aHandle, const FileSystemChildMetadata& aNewHandle, bool aIsFile) { const FileSystemChildMetadata& aNewHandle, bool aIsFile) { MOZ_ASSERT(!aNewHandle.parentId().IsEmpty()); QM_TRY_UNWRAP(EntryId entryId, FindEntryId(aConnection, aNewHandle, aIsFile), false); // Typically aNewHandle does not exist which is not an error QM_TRY_RETURN(QM_OR_ELSE_LOG_VERBOSE_IF( // Expression. FindEntryId(aConnection, aNewHandle, aIsFile) .map([&aHandle](const EntryId& entryId) { return entryId == aHandle.entryId(); }), // Predicate. IsSpecificError<NS_ERROR_DOM_NOT_FOUND_ERR>, // Fallback. ErrToOkFromQMResult<false>)); } Result<bool, QMResult> IsFile(const FileSystemConnection& aConnection, Loading Loading @@ -1338,7 +1347,9 @@ Result<bool, QMResult> FileSystemDatabaseManagerVersion001::MoveEntry( // If the rename doesn't change the name or directory, just return success. // XXX Needs to be added to the spec if (IsSame(mConnection, aHandle, aNewDesignation, isFile)) { QM_WARNONLY_TRY_UNWRAP(Maybe<bool> maybeSame, IsSame(mConnection, aHandle, aNewDesignation, isFile)); if (maybeSame && maybeSame.value()) { return true; } Loading
dom/quota/QuotaCommon.h +12 −0 Original line number Diff line number Diff line Loading @@ -1061,6 +1061,13 @@ bool IsSpecificError(const nsresult aValue) { return aValue == ErrorValue; } #ifdef QM_ERROR_STACKS_ENABLED template <nsresult ErrorValue> bool IsSpecificError(const QMResult& aValue) { return aValue.NSResult() == ErrorValue; } #endif // Helper template function so that QM_TRY fallback functions that are // converting errors into specific in-band success values can be concisely // written as ErrToOk<SuccessValueToReturn> (with the return type inferred). Loading @@ -1073,6 +1080,11 @@ auto ErrToOk(const nsresult aValue) -> Result<V, nsresult> { return V{SuccessValue}; } template <auto SuccessValue, typename V = decltype(SuccessValue)> auto ErrToOkFromQMResult(const QMResult& aValue) -> Result<V, QMResult> { return V{SuccessValue}; } // Helper template function so that QM_TRY fallback functions that are // suppressing errors by converting them into (generic) success can be // concisely written as ErrToDefaultOk<>. Loading