зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1665565 - Replace ToResultInvoke with MOZ_TO_RESULT_INVOKE_TYPED; r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D90523
This commit is contained in:
Родитель
ecd6a4b573
Коммит
8993cde73d
|
@ -654,15 +654,14 @@ Result<mozilla::Ok, nsresult> CollectEachFileEntry(
|
||||||
AssertIsOnIOThread();
|
AssertIsOnIOThread();
|
||||||
|
|
||||||
QM_TRY_VAR(const auto entries,
|
QM_TRY_VAR(const auto entries,
|
||||||
ToResultInvoke<nsCOMPtr<nsIDirectoryEnumerator>>(
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIDirectoryEnumerator>,
|
||||||
std::mem_fn(&nsIFile::GetDirectoryEntries), aDirectory));
|
aDirectory, GetDirectoryEntries));
|
||||||
|
|
||||||
return CollectEach(
|
return CollectEach(
|
||||||
[&entries]() -> Result<nsCOMPtr<nsIFile>, nsresult> {
|
[&entries]() -> Result<nsCOMPtr<nsIFile>, nsresult> {
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto file,
|
||||||
const auto file,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, entries,
|
||||||
ToResultInvoke<nsCOMPtr<nsIFile>>(
|
GetNextFile));
|
||||||
std::mem_fn(&nsIDirectoryEnumerator::GetNextFile), entries));
|
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
},
|
},
|
||||||
|
@ -2576,8 +2575,8 @@ nsresult CreateDirectoryMetadata(nsIFile& aDirectory, int64_t aTimestamp,
|
||||||
|
|
||||||
MOZ_ASSERT(groupPrefix == originPrefix);
|
MOZ_ASSERT(groupPrefix == originPrefix);
|
||||||
|
|
||||||
QM_TRY_VAR(auto file, ToResultInvoke<nsCOMPtr<nsIFile>>(
|
QM_TRY_VAR(auto file,
|
||||||
std::mem_fn(&nsIFile::Clone), &aDirectory));
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||||
|
|
||||||
QM_TRY(file->Append(nsLiteralString(METADATA_TMP_FILE_NAME)));
|
QM_TRY(file->Append(nsLiteralString(METADATA_TMP_FILE_NAME)));
|
||||||
|
|
||||||
|
@ -2609,8 +2608,8 @@ nsresult CreateDirectoryMetadata2(nsIFile& aDirectory, int64_t aTimestamp,
|
||||||
const nsACString& aOrigin) {
|
const nsACString& aOrigin) {
|
||||||
AssertIsOnIOThread();
|
AssertIsOnIOThread();
|
||||||
|
|
||||||
QM_TRY_VAR(auto file, ToResultInvoke<nsCOMPtr<nsIFile>>(
|
QM_TRY_VAR(auto file,
|
||||||
std::mem_fn(&nsIFile::Clone), &aDirectory));
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||||
|
|
||||||
QM_TRY(file->Append(nsLiteralString(METADATA_V2_TMP_FILE_NAME)));
|
QM_TRY(file->Append(nsLiteralString(METADATA_V2_TMP_FILE_NAME)));
|
||||||
|
|
||||||
|
@ -2653,8 +2652,8 @@ Result<nsCOMPtr<nsIBinaryInputStream>, nsresult> GetBinaryInputStream(
|
||||||
nsIFile& aDirectory, const nsAString& aFilename) {
|
nsIFile& aDirectory, const nsAString& aFilename) {
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
MOZ_ASSERT(!NS_IsMainThread());
|
||||||
|
|
||||||
QM_TRY_VAR(auto file, ToResultInvoke<nsCOMPtr<nsIFile>>(
|
QM_TRY_VAR(auto file,
|
||||||
std::mem_fn(&nsIFile::Clone), aDirectory));
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||||
|
|
||||||
QM_TRY(file->Append(aFilename));
|
QM_TRY(file->Append(aFilename));
|
||||||
|
|
||||||
|
@ -4883,19 +4882,14 @@ nsresult QuotaManager::GetDirectoryMetadata2(
|
||||||
MOZ_TO_RESULT_INVOKE(binaryStream, Read32));
|
MOZ_TO_RESULT_INVOKE(binaryStream, Read32));
|
||||||
Unused << reservedData2;
|
Unused << reservedData2;
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto suffix,
|
||||||
const auto suffix,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
QM_TRY_VAR(auto group, ToResultInvoke<nsCString>(
|
QM_TRY_VAR(auto group,
|
||||||
std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto origin,
|
||||||
const auto origin,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
// Currently unused (used to be isApp).
|
// Currently unused (used to be isApp).
|
||||||
QM_TRY_VAR(const bool dummy, MOZ_TO_RESULT_INVOKE(binaryStream, ReadBoolean));
|
QM_TRY_VAR(const bool dummy, MOZ_TO_RESULT_INVOKE(binaryStream, ReadBoolean));
|
||||||
|
@ -6366,9 +6360,8 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||||
MOZ_STORAGE_SERVICE_CONTRACTID));
|
MOZ_STORAGE_SERVICE_CONTRACTID));
|
||||||
|
|
||||||
QM_TRY_VAR(auto connection,
|
QM_TRY_VAR(auto connection,
|
||||||
ToResultInvoke<nsCOMPtr<mozIStorageConnection>>(
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>, ss,
|
||||||
std::mem_fn(&mozIStorageService::OpenUnsharedDatabase), ss,
|
OpenUnsharedDatabase, storageFile)
|
||||||
storageFile)
|
|
||||||
.orElse(ErrToOkOrErr<NS_ERROR_FILE_CORRUPTED, nullptr,
|
.orElse(ErrToOkOrErr<NS_ERROR_FILE_CORRUPTED, nullptr,
|
||||||
nsCOMPtr<mozIStorageConnection>>));
|
nsCOMPtr<mozIStorageConnection>>));
|
||||||
|
|
||||||
|
@ -6376,11 +6369,9 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||||
// Nuke the database file.
|
// Nuke the database file.
|
||||||
QM_TRY(storageFile->Remove(false));
|
QM_TRY(storageFile->Remove(false));
|
||||||
|
|
||||||
// TODO: Can we simplify this syntax ?
|
|
||||||
QM_TRY_VAR(connection,
|
QM_TRY_VAR(connection,
|
||||||
ToResultInvoke<nsCOMPtr<mozIStorageConnection>>(
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>, ss,
|
||||||
std::mem_fn(&mozIStorageService::OpenUnsharedDatabase), ss,
|
OpenUnsharedDatabase, storageFile));
|
||||||
storageFile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want extra durability for this important file.
|
// We want extra durability for this important file.
|
||||||
|
@ -6561,13 +6552,12 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||||
if (insertStmt) {
|
if (insertStmt) {
|
||||||
MOZ_ALWAYS_SUCCEEDS(insertStmt->Reset());
|
MOZ_ALWAYS_SUCCEEDS(insertStmt->Reset());
|
||||||
} else {
|
} else {
|
||||||
// TODO: Can we simplify this syntax ?
|
QM_TRY_VAR(
|
||||||
QM_TRY_VAR(insertStmt,
|
insertStmt,
|
||||||
ToResultInvoke<nsCOMPtr<mozIStorageStatement>>(
|
MOZ_TO_RESULT_INVOKE_TYPED(
|
||||||
std::mem_fn(&mozIStorageConnection::CreateStatement),
|
nsCOMPtr<mozIStorageStatement>, connection, CreateStatement,
|
||||||
connection,
|
nsLiteralCString("INSERT INTO repository (id, name) "
|
||||||
nsLiteralCString("INSERT INTO repository (id, name) "
|
"VALUES (:id, :name)")));
|
||||||
"VALUES (:id, :name)")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QM_TRY(insertStmt->BindInt32ByName("id"_ns, persistenceType));
|
QM_TRY(insertStmt->BindInt32ByName("id"_ns, persistenceType));
|
||||||
|
@ -10401,15 +10391,11 @@ nsresult StorageOperationBase::GetDirectoryMetadata(nsIFile* aDirectory,
|
||||||
QM_TRY_VAR(const uint64_t timestamp,
|
QM_TRY_VAR(const uint64_t timestamp,
|
||||||
MOZ_TO_RESULT_INVOKE(binaryStream, Read64));
|
MOZ_TO_RESULT_INVOKE(binaryStream, Read64));
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto group,
|
||||||
const auto group,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto origin,
|
||||||
const auto origin,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
Nullable<bool> isApp;
|
Nullable<bool> isApp;
|
||||||
bool value;
|
bool value;
|
||||||
|
@ -10449,20 +10435,14 @@ nsresult StorageOperationBase::GetDirectoryMetadata2(
|
||||||
MOZ_TO_RESULT_INVOKE(binaryStream, Read32));
|
MOZ_TO_RESULT_INVOKE(binaryStream, Read32));
|
||||||
Unused << reservedData2;
|
Unused << reservedData2;
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto suffix,
|
||||||
const auto suffix,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto group,
|
||||||
const auto group,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto origin,
|
||||||
const auto origin,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&nsIBinaryInputStream::ReadCString),
|
|
||||||
binaryStream));
|
|
||||||
|
|
||||||
QM_TRY_VAR(const bool isApp, MOZ_TO_RESULT_INVOKE(binaryStream, ReadBoolean));
|
QM_TRY_VAR(const bool isApp, MOZ_TO_RESULT_INVOKE(binaryStream, ReadBoolean));
|
||||||
|
|
||||||
|
@ -10529,8 +10509,7 @@ nsresult StorageOperationBase::ProcessOriginDirectories() {
|
||||||
specURL->Origin(originNoSuffix);
|
specURL->Origin(originNoSuffix);
|
||||||
|
|
||||||
QM_TRY_VAR(const auto baseDomain,
|
QM_TRY_VAR(const auto baseDomain,
|
||||||
ToResultInvoke<nsCString>(std::mem_fn(&MozURL::BaseDomain),
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, specURL, BaseDomain));
|
||||||
specURL));
|
|
||||||
|
|
||||||
ContentPrincipalInfo contentPrincipalInfo;
|
ContentPrincipalInfo contentPrincipalInfo;
|
||||||
contentPrincipalInfo.attrs() = originProps.mAttrs;
|
contentPrincipalInfo.attrs() = originProps.mAttrs;
|
||||||
|
@ -11094,9 +11073,8 @@ nsresult RepositoryOperationBase::ProcessRepository() {
|
||||||
QM_TRY(CollectEachFileEntry(
|
QM_TRY(CollectEachFileEntry(
|
||||||
*mDirectory,
|
*mDirectory,
|
||||||
[](const auto& originFile) -> Result<mozilla::Ok, nsresult> {
|
[](const auto& originFile) -> Result<mozilla::Ok, nsresult> {
|
||||||
QM_TRY_VAR(const auto leafName,
|
QM_TRY_VAR(const auto leafName, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||||
ToResultInvoke<nsString>(std::mem_fn(&nsIFile::GetLeafName),
|
nsString, originFile, GetLeafName));
|
||||||
originFile));
|
|
||||||
|
|
||||||
// Unknown files during upgrade are allowed. Just warn if we find
|
// Unknown files during upgrade are allowed. Just warn if we find
|
||||||
// them.
|
// them.
|
||||||
|
@ -11154,9 +11132,8 @@ nsresult RepositoryOperationBase::MaybeUpgradeClients(
|
||||||
QM_TRY(CollectEachFileEntry(
|
QM_TRY(CollectEachFileEntry(
|
||||||
*aOriginProps.mDirectory,
|
*aOriginProps.mDirectory,
|
||||||
[](const auto& file) -> Result<mozilla::Ok, nsresult> {
|
[](const auto& file) -> Result<mozilla::Ok, nsresult> {
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto leafName,
|
||||||
const auto leafName,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsString, file, GetLeafName));
|
||||||
ToResultInvoke<nsString>(std::mem_fn(&nsIFile::GetLeafName), file));
|
|
||||||
|
|
||||||
if (!IsOriginMetadata(leafName) && !IsTempMetadata(leafName)) {
|
if (!IsOriginMetadata(leafName) && !IsTempMetadata(leafName)) {
|
||||||
UNKNOWN_FILE_WARNING(leafName);
|
UNKNOWN_FILE_WARNING(leafName);
|
||||||
|
@ -11166,9 +11143,8 @@ nsresult RepositoryOperationBase::MaybeUpgradeClients(
|
||||||
},
|
},
|
||||||
[quotaManager, &aMethod,
|
[quotaManager, &aMethod,
|
||||||
&self = *this](const auto& dir) -> Result<mozilla::Ok, nsresult> {
|
&self = *this](const auto& dir) -> Result<mozilla::Ok, nsresult> {
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(const auto leafName,
|
||||||
const auto leafName,
|
MOZ_TO_RESULT_INVOKE_TYPED(nsString, dir, GetLeafName));
|
||||||
ToResultInvoke<nsString>(std::mem_fn(&nsIFile::GetLeafName), dir));
|
|
||||||
|
|
||||||
QM_TRY_VAR(
|
QM_TRY_VAR(
|
||||||
const bool removed,
|
const bool removed,
|
||||||
|
@ -11474,8 +11450,8 @@ nsresult UpgradeStorageFrom0_0To1_0Helper::ProcessOriginDirectory(
|
||||||
aOriginProps.mGroup, aOriginProps.mOrigin));
|
aOriginProps.mGroup, aOriginProps.mOrigin));
|
||||||
|
|
||||||
QM_TRY_VAR(const auto oldName,
|
QM_TRY_VAR(const auto oldName,
|
||||||
ToResultInvoke<nsString>(std::mem_fn(&nsIFile::GetLeafName),
|
MOZ_TO_RESULT_INVOKE_TYPED(nsString, aOriginProps.mDirectory,
|
||||||
aOriginProps.mDirectory));
|
GetLeafName));
|
||||||
|
|
||||||
nsAutoCString originSanitized(aOriginProps.mOrigin);
|
nsAutoCString originSanitized(aOriginProps.mOrigin);
|
||||||
SanitizeOriginString(originSanitized);
|
SanitizeOriginString(originSanitized);
|
||||||
|
@ -11500,8 +11476,8 @@ nsresult UpgradeStorageFrom1_0To2_0Helper::MaybeRemoveMorgueDirectory(
|
||||||
// directories as part of this upgrade.
|
// directories as part of this upgrade.
|
||||||
|
|
||||||
QM_TRY_VAR(auto morgueDir,
|
QM_TRY_VAR(auto morgueDir,
|
||||||
ToResultInvoke<nsCOMPtr<nsIFile>>(std::mem_fn(&nsIFile::Clone),
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||||
aOriginProps.mDirectory));
|
aOriginProps.mDirectory, Clone));
|
||||||
|
|
||||||
QM_TRY(morgueDir->Append(u"morgue"_ns));
|
QM_TRY(morgueDir->Append(u"morgue"_ns));
|
||||||
|
|
||||||
|
@ -11584,8 +11560,8 @@ UpgradeStorageFrom1_0To2_0Helper::MaybeStripObsoleteOriginAttributes(
|
||||||
aOriginProps.mGroup, aOriginProps.mOrigin));
|
aOriginProps.mGroup, aOriginProps.mOrigin));
|
||||||
|
|
||||||
QM_TRY_VAR(auto newFile,
|
QM_TRY_VAR(auto newFile,
|
||||||
ToResultInvoke<nsCOMPtr<nsIFile>>(std::mem_fn(&nsIFile::GetParent),
|
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||||
aOriginProps.mDirectory));
|
aOriginProps.mDirectory, GetParent));
|
||||||
|
|
||||||
QM_TRY(newFile->Append(newLeafName));
|
QM_TRY(newFile->Append(newLeafName));
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче