зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1671367 - Change GetUsageFile to return a Result and Use LS_TRY. r=dom-workers-and-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D94132
This commit is contained in:
Родитель
4c1da92e19
Коммит
0704913795
|
@ -1170,25 +1170,16 @@ nsresult DetachShadowDatabase(mozIStorageConnection* aConnection) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult GetUsageFile(const nsAString& aDirectoryPath, nsIFile** aUsageFile) {
|
||||
Result<nsCOMPtr<nsIFile>, nsresult> GetUsageFile(
|
||||
const nsAString& aDirectoryPath) {
|
||||
MOZ_ASSERT(IsOnIOThread() || IsOnConnectionThread());
|
||||
MOZ_ASSERT(!aDirectoryPath.IsEmpty());
|
||||
MOZ_ASSERT(aUsageFile);
|
||||
|
||||
auto usageFileOrErr = QM_NewLocalFile(aDirectoryPath);
|
||||
if (NS_WARN_IF(usageFileOrErr.isErr())) {
|
||||
return usageFileOrErr.unwrapErr();
|
||||
}
|
||||
LS_TRY_UNWRAP(auto usageFile, QM_NewLocalFile(aDirectoryPath));
|
||||
|
||||
nsCOMPtr<nsIFile> usageFile = usageFileOrErr.unwrap();
|
||||
LS_TRY(usageFile->Append(kUsageFileName));
|
||||
|
||||
nsresult rv = usageFile->Append(kUsageFileName);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
usageFile.forget(aUsageFile);
|
||||
return NS_OK;
|
||||
return usageFile;
|
||||
}
|
||||
|
||||
nsresult GetUsageJournalFile(const nsAString& aDirectoryPath,
|
||||
|
@ -4442,11 +4433,7 @@ nsresult Connection::EnsureStorageConnection() {
|
|||
MOZ_ASSERT(!exists);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIFile> usageFile;
|
||||
rv = GetUsageFile(mDirectoryPath, getter_AddRefs(usageFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
LS_TRY_INSPECT(const auto& usageFile, GetUsageFile(mDirectoryPath));
|
||||
|
||||
nsCOMPtr<mozIStorageConnection> storageConnection;
|
||||
bool removedUsageFile;
|
||||
|
@ -4758,11 +4745,8 @@ nsresult Connection::FlushOp::DoDatastoreWork() {
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> usageFile;
|
||||
rv = GetUsageFile(mConnection->DirectoryPath(), getter_AddRefs(usageFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
LS_TRY_INSPECT(const auto& usageFile,
|
||||
GetUsageFile(mConnection->DirectoryPath()));
|
||||
|
||||
nsCOMPtr<nsIFile> usageJournalFile;
|
||||
rv = GetUsageJournalFile(mConnection->DirectoryPath(),
|
||||
|
@ -7515,11 +7499,7 @@ nsresult PrepareDatastoreOp::DatabaseWork() {
|
|||
// from now on.
|
||||
RefPtr<QuotaObject> quotaObject;
|
||||
|
||||
nsCOMPtr<nsIFile> usageFile;
|
||||
rv = GetUsageFile(directoryPath, getter_AddRefs(usageFile));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
LS_TRY_INSPECT(const auto& usageFile, GetUsageFile(directoryPath));
|
||||
|
||||
nsCOMPtr<nsIFile> usageJournalFile;
|
||||
rv = GetUsageJournalFile(directoryPath, getter_AddRefs(usageJournalFile));
|
||||
|
@ -8911,8 +8891,7 @@ Result<UsageInfo, nsresult> QuotaClient::InitOrigin(
|
|||
LS_TRY_INSPECT(const auto& directoryPath,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsString, directory, GetPath));
|
||||
|
||||
LS_TRY_INSPECT(const auto& usageFile, ToResultInvoke<nsCOMPtr<nsIFile>>(
|
||||
GetUsageFile, directoryPath));
|
||||
LS_TRY_INSPECT(const auto& usageFile, GetUsageFile(directoryPath));
|
||||
|
||||
// XXX Try to make usageFileExists const
|
||||
LS_TRY_UNWRAP(bool usageFileExists, ExistsAsFile(*usageFile));
|
||||
|
|
Загрузка…
Ссылка в новой задаче