Bug 1536796 - P3 - Use QM_NewLocalFile in QM and its clients; r=janv,dom-workers-and-storage-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D67875

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Tung 2020-04-01 07:26:27 +00:00
parent 4e96941288
commit 94e4123950
3 changed files with 176 additions and 156 deletions

View File

@ -4619,13 +4619,12 @@ nsresult CreateStorageConnection(nsIFile* aDBFile, nsIFile* aFMDirectory,
nsCOMPtr<nsIFile> GetFileForPath(const nsAString& aPath) {
MOZ_ASSERT(!aPath.IsEmpty());
nsCOMPtr<nsIFile> file;
if (NS_WARN_IF(
NS_FAILED(NS_NewLocalFile(aPath, false, getter_AddRefs(file))))) {
auto fileOrErr = QM_NewLocalFile(aPath);
if (NS_WARN_IF(fileOrErr.isErr())) {
return nullptr;
}
return file;
return fileOrErr.unwrap();
}
nsresult GetStorageConnection(nsIFile* aDatabaseFile, int64_t aDirectoryLockId,
@ -11419,16 +11418,17 @@ nsresult DatabaseConnection::GetFileSize(const nsAString& aPath,
MOZ_ASSERT(!aPath.IsEmpty());
MOZ_ASSERT(aResult);
nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(aPath, false, getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto fileOrErr = QM_NewLocalFile(aPath);
if (NS_WARN_IF(fileOrErr.isErr())) {
return fileOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> file = fileOrErr.unwrap();
int64_t fileSize;
bool exists;
rv = file->Exists(&exists);
nsresult rv = file->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -642,15 +642,15 @@ nsresult GetStorageConnection(const nsAString& aDatabaseFilePath,
MOZ_ASSERT(StringEndsWith(aDatabaseFilePath, NS_LITERAL_STRING(".sqlite")));
MOZ_ASSERT(aConnection);
nsCOMPtr<nsIFile> databaseFile;
nsresult rv =
NS_NewLocalFile(aDatabaseFilePath, false, getter_AddRefs(databaseFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto databaseFileOrErr = QM_NewLocalFile(aDatabaseFilePath);
if (NS_WARN_IF(databaseFileOrErr.isErr())) {
return databaseFileOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> databaseFile = databaseFileOrErr.unwrap();
bool exists;
rv = databaseFile->Exists(&exists);
nsresult rv = databaseFile->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -685,14 +685,14 @@ nsresult GetArchiveFile(const nsAString& aStoragePath, nsIFile** aArchiveFile) {
MOZ_ASSERT(!aStoragePath.IsEmpty());
MOZ_ASSERT(aArchiveFile);
nsCOMPtr<nsIFile> archiveFile;
nsresult rv =
NS_NewLocalFile(aStoragePath, false, getter_AddRefs(archiveFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto archiveFileOrErr = QM_NewLocalFile(aStoragePath);
if (NS_WARN_IF(archiveFileOrErr.isErr())) {
return archiveFileOrErr.unwrapErr();
}
rv = archiveFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
nsCOMPtr<nsIFile> archiveFile = archiveFileOrErr.unwrap();
nsresult rv = archiveFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -826,13 +826,15 @@ nsresult GetShadowFile(const nsAString& aBasePath, nsIFile** aArchiveFile) {
MOZ_ASSERT(!aBasePath.IsEmpty());
MOZ_ASSERT(aArchiveFile);
nsCOMPtr<nsIFile> archiveFile;
nsresult rv = NS_NewLocalFile(aBasePath, false, getter_AddRefs(archiveFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto archiveFileOrErr = QM_NewLocalFile(aBasePath);
if (NS_WARN_IF(archiveFileOrErr.isErr())) {
return archiveFileOrErr.unwrapErr();
}
rv = archiveFile->Append(NS_LITERAL_STRING(WEB_APPS_STORE_FILE_NAME));
nsCOMPtr<nsIFile> archiveFile = archiveFileOrErr.unwrap();
nsresult rv =
archiveFile->Append(NS_LITERAL_STRING(WEB_APPS_STORE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1102,14 +1104,14 @@ nsresult GetUsageFile(const nsAString& aDirectoryPath, nsIFile** aUsageFile) {
MOZ_ASSERT(!aDirectoryPath.IsEmpty());
MOZ_ASSERT(aUsageFile);
nsCOMPtr<nsIFile> usageFile;
nsresult rv =
NS_NewLocalFile(aDirectoryPath, false, getter_AddRefs(usageFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto usageFileOrErr = QM_NewLocalFile(aDirectoryPath);
if (NS_WARN_IF(usageFileOrErr.isErr())) {
return usageFileOrErr.unwrapErr();
}
rv = usageFile->Append(NS_LITERAL_STRING(USAGE_FILE_NAME));
nsCOMPtr<nsIFile> usageFile = usageFileOrErr.unwrap();
nsresult rv = usageFile->Append(NS_LITERAL_STRING(USAGE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1124,14 +1126,15 @@ nsresult GetUsageJournalFile(const nsAString& aDirectoryPath,
MOZ_ASSERT(!aDirectoryPath.IsEmpty());
MOZ_ASSERT(aUsageJournalFile);
nsCOMPtr<nsIFile> usageJournalFile;
nsresult rv =
NS_NewLocalFile(aDirectoryPath, false, getter_AddRefs(usageJournalFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto usageJournalFileOrErr = QM_NewLocalFile(aDirectoryPath);
if (NS_WARN_IF(usageJournalFileOrErr.isErr())) {
return usageJournalFileOrErr.unwrapErr();
}
rv = usageJournalFile->Append(NS_LITERAL_STRING(USAGE_JOURNAL_FILE_NAME));
nsCOMPtr<nsIFile> usageJournalFile = usageJournalFileOrErr.unwrap();
nsresult rv =
usageJournalFile->Append(NS_LITERAL_STRING(USAGE_JOURNAL_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4271,13 +4274,13 @@ nsresult Connection::EnsureStorageConnection() {
return rv;
}
nsCOMPtr<nsIFile> directoryEntry;
rv = NS_NewLocalFile(originDirectoryPath, false,
getter_AddRefs(directoryEntry));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto directoryEntryOrErr = QM_NewLocalFile(originDirectoryPath);
if (NS_WARN_IF(directoryEntryOrErr.isErr())) {
return directoryEntryOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> directoryEntry = directoryEntryOrErr.unwrap();
rv = directoryEntry->Append(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

View File

@ -512,14 +512,14 @@ nsresult GetLocalStorageArchiveFile(const nsAString& aDirectoryPath,
MOZ_ASSERT(!aDirectoryPath.IsEmpty());
MOZ_ASSERT(aLsArchiveFile);
nsCOMPtr<nsIFile> lsArchiveFile;
nsresult rv =
NS_NewLocalFile(aDirectoryPath, false, getter_AddRefs(lsArchiveFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto lsArchiveFileOrErr = QM_NewLocalFile(aDirectoryPath);
if (NS_WARN_IF(lsArchiveFileOrErr.isErr())) {
return lsArchiveFileOrErr.unwrapErr();
}
rv = lsArchiveFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
nsCOMPtr<nsIFile> lsArchiveFile = lsArchiveFileOrErr.unwrap();
nsresult rv = lsArchiveFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -534,14 +534,15 @@ nsresult GetLocalStorageArchiveTmpFile(const nsAString& aDirectoryPath,
MOZ_ASSERT(!aDirectoryPath.IsEmpty());
MOZ_ASSERT(aLsArchiveTmpFile);
nsCOMPtr<nsIFile> lsArchiveTmpFile;
nsresult rv =
NS_NewLocalFile(aDirectoryPath, false, getter_AddRefs(lsArchiveTmpFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto lsArchiveTempFileOrErr = QM_NewLocalFile(aDirectoryPath);
if (NS_WARN_IF(lsArchiveTempFileOrErr.isErr())) {
return lsArchiveTempFileOrErr.unwrapErr();
}
rv = lsArchiveTmpFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_TMP_FILE_NAME));
nsCOMPtr<nsIFile> lsArchiveTmpFile = lsArchiveTempFileOrErr.unwrap();
nsresult rv =
lsArchiveTmpFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3939,14 +3940,15 @@ void QuotaManager::CollectPendingOriginsForListing(P aPredicate) {
nsresult QuotaManager::Init(const nsAString& aBasePath) {
mBasePath = aBasePath;
nsCOMPtr<nsIFile> baseDir;
nsresult rv = NS_NewLocalFile(aBasePath, false, getter_AddRefs(baseDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto baseDirOrErr = QM_NewLocalFile(aBasePath);
if (NS_WARN_IF(baseDirOrErr.isErr())) {
return baseDirOrErr.unwrapErr();
}
rv = CloneStoragePath(baseDir, NS_LITERAL_STRING(INDEXEDDB_DIRECTORY_NAME),
mIndexedDBPath);
nsCOMPtr<nsIFile> baseDir = baseDirOrErr.unwrap();
nsresult rv = CloneStoragePath(
baseDir, NS_LITERAL_STRING(INDEXEDDB_DIRECTORY_NAME), mIndexedDBPath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4780,9 +4782,12 @@ already_AddRefed<QuotaObject> QuotaManager::GetQuotaObject(
*aFileSizeOut = 0;
}
nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(aPath, false, getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, nullptr);
auto fileOrErr = QM_NewLocalFile(aPath);
if (NS_WARN_IF(fileOrErr.isErr())) {
return nullptr;
}
nsCOMPtr<nsIFile> file = fileOrErr.unwrap();
return GetQuotaObject(aPersistenceType, aGroup, aOrigin, aClientType, file,
aFileSize, aFileSizeOut);
@ -4855,15 +4860,17 @@ void QuotaManager::AbortOperationsForProcess(ContentParentId aContentParentId) {
nsresult QuotaManager::GetDirectoryForOrigin(PersistenceType aPersistenceType,
const nsACString& aASCIIOrigin,
nsIFile** aDirectory) const {
nsCOMPtr<nsIFile> directory;
nsresult rv = NS_NewLocalFile(GetStoragePath(aPersistenceType), false,
getter_AddRefs(directory));
NS_ENSURE_SUCCESS(rv, rv);
auto directoryOrErr = QM_NewLocalFile(GetStoragePath(aPersistenceType));
if (NS_WARN_IF(directoryOrErr.isErr())) {
return directoryOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
nsAutoCString originSanitized(aASCIIOrigin);
SanitizeOriginString(originSanitized);
rv = directory->Append(NS_ConvertASCIItoUTF16(originSanitized));
nsresult rv = directory->Append(NS_ConvertASCIItoUTF16(originSanitized));
NS_ENSURE_SUCCESS(rv, rv);
directory.forget(aDirectory);
@ -5065,16 +5072,16 @@ nsresult QuotaManager::InitializeRepository(PersistenceType aPersistenceType) {
MOZ_ASSERT(aPersistenceType == PERSISTENCE_TYPE_TEMPORARY ||
aPersistenceType == PERSISTENCE_TYPE_DEFAULT);
nsCOMPtr<nsIFile> directory;
nsresult rv = NS_NewLocalFile(GetStoragePath(aPersistenceType), false,
getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
auto directoryOrErr = QM_NewLocalFile(GetStoragePath(aPersistenceType));
if (NS_WARN_IF(directoryOrErr.isErr())) {
REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, Rep_NewLocalFile);
return rv;
return directoryOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
bool created;
rv = EnsureDirectory(directory, &created);
nsresult rv = EnsureDirectory(directory, &created);
if (NS_WARN_IF(NS_FAILED(rv))) {
REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, Rep_EnsureDirectory);
return rv;
@ -5316,10 +5323,12 @@ QuotaManager::UpgradeFromIndexedDBDirectoryToPersistentStorageDirectory(
return NS_OK;
}
nsCOMPtr<nsIFile> persistentStorageDir;
rv = NS_NewLocalFile(mStoragePath, false,
getter_AddRefs(persistentStorageDir));
NS_ENSURE_SUCCESS(rv, rv);
auto persistentStorageDirOrErr = QM_NewLocalFile(mStoragePath);
if (NS_WARN_IF(persistentStorageDirOrErr.isErr())) {
return persistentStorageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> persistentStorageDir = persistentStorageDirOrErr.unwrap();
rv = persistentStorageDir->Append(
NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
@ -5374,13 +5383,13 @@ QuotaManager::UpgradeFromPersistentStorageDirectoryToDefaultStorageDirectory(
return NS_OK;
}
nsCOMPtr<nsIFile> defaultStorageDir;
rv = NS_NewLocalFile(mDefaultStoragePath, false,
getter_AddRefs(defaultStorageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto defaultStorageDirOrErr = QM_NewLocalFile(mDefaultStoragePath);
if (NS_WARN_IF(defaultStorageDirOrErr.isErr())) {
return defaultStorageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> defaultStorageDir = defaultStorageDirOrErr.unwrap();
bool exists;
rv = defaultStorageDir->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -5409,13 +5418,13 @@ QuotaManager::UpgradeFromPersistentStorageDirectoryToDefaultStorageDirectory(
}
// Upgrade metadata files for origin directories in temporary storage.
nsCOMPtr<nsIFile> temporaryStorageDir;
rv = NS_NewLocalFile(mTemporaryStoragePath, false,
getter_AddRefs(temporaryStorageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto temporaryStorageDirOrErr = QM_NewLocalFile(mTemporaryStoragePath);
if (NS_WARN_IF(temporaryStorageDirOrErr.isErr())) {
return temporaryStorageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> temporaryStorageDir = temporaryStorageDirOrErr.unwrap();
rv = temporaryStorageDir->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -5464,13 +5473,13 @@ nsresult QuotaManager::UpgradeStorage(const int32_t aOldVersion,
nsresult rv;
for (const PersistenceType persistenceType : kAllPersistenceTypes) {
nsCOMPtr<nsIFile> directory;
rv = NS_NewLocalFile(GetStoragePath(persistenceType), false,
getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto directoryOrErr = QM_NewLocalFile(GetStoragePath(persistenceType));
if (NS_WARN_IF(directoryOrErr.isErr())) {
return directoryOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
bool exists;
rv = directory->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -5741,15 +5750,15 @@ nsresult QuotaManager::MaybeRemoveLocalStorageData() {
nsresult QuotaManager::MaybeRemoveLocalStorageDirectories() {
AssertIsOnIOThread();
nsCOMPtr<nsIFile> defaultStorageDir;
nsresult rv = NS_NewLocalFile(mDefaultStoragePath, false,
getter_AddRefs(defaultStorageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto defaultStorageDirOrErr = QM_NewLocalFile(mDefaultStoragePath);
if (NS_WARN_IF(defaultStorageDirOrErr.isErr())) {
return defaultStorageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> defaultStorageDir = defaultStorageDirOrErr.unwrap();
bool exists;
rv = defaultStorageDir->Exists(&exists);
nsresult rv = defaultStorageDir->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -5894,12 +5903,13 @@ nsresult QuotaManager::CreateLocalStorageArchiveConnectionFromWebAppsStore(
}
// Get the web apps store file.
nsCOMPtr<nsIFile> webAppsStoreFile;
rv = NS_NewLocalFile(mBasePath, false, getter_AddRefs(webAppsStoreFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto webAppsStoreFileOrErr = QM_NewLocalFile(mBasePath);
if (NS_WARN_IF(webAppsStoreFileOrErr.isErr())) {
return webAppsStoreFileOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> webAppsStoreFile = webAppsStoreFileOrErr.unwrap();
rv = webAppsStoreFile->Append(NS_LITERAL_STRING(WEB_APPS_STORE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -5961,12 +5971,13 @@ nsresult QuotaManager::CreateLocalStorageArchiveConnectionFromWebAppsStore(
// <profile>/webappsstore.sqlite to
// <profile>/storage/ls-archive-tmp.sqlite
// We use a "-tmp" postfix since we are not done yet.
nsCOMPtr<nsIFile> storageDir;
rv = NS_NewLocalFile(mStoragePath, false, getter_AddRefs(storageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto storageDirOrErr = QM_NewLocalFile(mStoragePath);
if (NS_WARN_IF(storageDirOrErr.isErr())) {
return storageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> storageDir = storageDirOrErr.unwrap();
rv = webAppsStoreFile->CopyTo(storageDir,
NS_LITERAL_STRING(LS_ARCHIVE_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -6022,13 +6033,13 @@ nsresult QuotaManager::CreateLocalStorageArchiveConnectionFromWebAppsStore(
// If webappsstore database is not useable, just create an empty archive.
// Ensure the storage directory actually exists.
nsCOMPtr<nsIFile> storageDirectory;
rv = NS_NewLocalFile(GetStoragePath(), false,
getter_AddRefs(storageDirectory));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto storageDirectoryOrErr = QM_NewLocalFile(GetStoragePath());
if (NS_WARN_IF(storageDirectoryOrErr.isErr())) {
return storageDirectoryOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> storageDirectory = storageDirectoryOrErr.unwrap();
bool dummy;
rv = EnsureDirectory(storageDirectory, &dummy);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -6291,13 +6302,14 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
Initialization::Storage,
[& self = *this] { return static_cast<bool>(self.mStorageConnection); });
nsCOMPtr<nsIFile> storageFile;
nsresult rv = NS_NewLocalFile(mBasePath, false, getter_AddRefs(storageFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto storageFileOrErr = QM_NewLocalFile(mBasePath);
if (NS_WARN_IF(storageFileOrErr.isErr())) {
return storageFileOrErr.unwrapErr();
}
rv = storageFile->Append(NS_LITERAL_STRING(STORAGE_FILE_NAME));
nsCOMPtr<nsIFile> storageFile = storageFileOrErr.unwrap();
nsresult rv = storageFile->Append(NS_LITERAL_STRING(STORAGE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -6309,12 +6321,13 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
}
if (!exists) {
nsCOMPtr<nsIFile> indexedDBDir;
rv = NS_NewLocalFile(mIndexedDBPath, false, getter_AddRefs(indexedDBDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto indexedDBDirOrErr = QM_NewLocalFile(mIndexedDBPath);
if (NS_WARN_IF(indexedDBDirOrErr.isErr())) {
return indexedDBDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> indexedDBDir = indexedDBDirOrErr.unwrap();
bool indexedDBDirExists;
rv = indexedDBDir->Exists(&indexedDBDirExists);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -6331,13 +6344,13 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
}
}
nsCOMPtr<nsIFile> persistentStorageDir;
rv = NS_NewLocalFile(mStoragePath, false,
getter_AddRefs(persistentStorageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto persistentStorageDirOrErr = QM_NewLocalFile(mStoragePath);
if (NS_WARN_IF(persistentStorageDirOrErr.isErr())) {
return persistentStorageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> persistentStorageDir = persistentStorageDirOrErr.unwrap();
rv = persistentStorageDir->Append(
NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -6416,12 +6429,13 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
if (storageVersion < kStorageVersion) {
const bool newDatabase = !storageVersion;
nsCOMPtr<nsIFile> storageDir;
rv = NS_NewLocalFile(mStoragePath, false, getter_AddRefs(storageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto storageDirOrErr = QM_NewLocalFile(mStoragePath);
if (NS_WARN_IF(storageDirOrErr.isErr())) {
return storageDirOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> storageDir = storageDirOrErr.unwrap();
rv = storageDir->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -7826,7 +7840,7 @@ bool QuotaManager::IsSanitizedOriginValid(const nsACString& aSanitizedOrigin) {
}
int64_t QuotaManager::GenerateDirectoryLockId() {
const int64_t directroylockId = mNextDirectoryLockId;
const int64_t directorylockId = mNextDirectoryLockId;
CheckedInt64 result = CheckedInt64(mNextDirectoryLockId) + 1;
if (result.isValid()) {
@ -7843,7 +7857,7 @@ int64_t QuotaManager::GenerateDirectoryLockId() {
// TODO: Maybe add an assertion here to check that there is no existing
// directory lock with given id.
return directroylockId;
return directorylockId;
}
/*******************************************************************************
@ -9151,15 +9165,16 @@ nsresult TraverseRepositoryHelper::TraverseRepository(
AssertIsOnIOThread();
MOZ_ASSERT(aQuotaManager);
nsCOMPtr<nsIFile> directory;
nsresult rv = NS_NewLocalFile(aQuotaManager->GetStoragePath(aPersistenceType),
false, getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto directoryOrErr =
QM_NewLocalFile(aQuotaManager->GetStoragePath(aPersistenceType));
if (NS_WARN_IF(directoryOrErr.isErr())) {
return directoryOrErr.unwrapErr();
}
nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
bool exists;
rv = directory->Exists(&exists);
nsresult rv = directory->Exists(&exists);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -9670,13 +9685,13 @@ void ResetOrClearOp::DeleteFiles(QuotaManager* aQuotaManager) {
return;
}
nsCOMPtr<nsIFile> directory;
rv = NS_NewLocalFile(aQuotaManager->GetStoragePath(), false,
getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
auto directoryOrErr = QM_NewLocalFile(aQuotaManager->GetStoragePath());
if (NS_WARN_IF(directoryOrErr.isErr())) {
return;
}
nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
rv = directory->Remove(true);
if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
@ -9690,14 +9705,14 @@ void ResetOrClearOp::DeleteStorageFile(QuotaManager* aQuotaManager) {
AssertIsOnIOThread();
MOZ_ASSERT(aQuotaManager);
nsCOMPtr<nsIFile> storageFile;
nsresult rv = NS_NewLocalFile(aQuotaManager->GetBasePath(), false,
getter_AddRefs(storageFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
auto storageFileOrErr = QM_NewLocalFile(aQuotaManager->GetBasePath());
if (NS_WARN_IF(storageFileOrErr.isErr())) {
return;
}
rv = storageFile->Append(NS_LITERAL_STRING(STORAGE_FILE_NAME));
nsCOMPtr<nsIFile> storageFile = storageFileOrErr.unwrap();
nsresult rv = storageFile->Append(NS_LITERAL_STRING(STORAGE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
@ -9751,13 +9766,14 @@ void ClearRequestBase::DeleteFiles(QuotaManager* aQuotaManager,
return;
}
nsCOMPtr<nsIFile> directory;
rv = NS_NewLocalFile(aQuotaManager->GetStoragePath(aPersistenceType), false,
getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
auto directoryOrErr =
QM_NewLocalFile(aQuotaManager->GetStoragePath(aPersistenceType));
if (NS_WARN_IF(directoryOrErr.isErr())) {
return;
}
nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
nsCOMPtr<nsIDirectoryEnumerator> entries;
if (NS_WARN_IF(
NS_FAILED(directory->GetDirectoryEntries(getter_AddRefs(entries)))) ||
@ -11494,11 +11510,12 @@ nsresult CreateOrUpgradeDirectoryMetadataHelper::ProcessOriginDirectory(
const nsString& permanentStoragePath =
quotaManager->GetStoragePath(PERSISTENCE_TYPE_PERSISTENT);
rv = NS_NewLocalFile(permanentStoragePath, false,
getter_AddRefs(mPermanentStorageDir));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
auto permanentstorageDirOrErr = QM_NewLocalFile(permanentStoragePath);
if (NS_WARN_IF(permanentstorageDirOrErr.isErr())) {
return permanentstorageDirOrErr.unwrapErr();
}
mPermanentStorageDir = permanentstorageDirOrErr.unwrap();
}
nsString leafName;