forked from mirrors/gecko-dev
Bug 1841726 - Clean up OPFS datamodel files. r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D182755
This commit is contained in:
parent
611fed8ace
commit
f0a515b51b
4 changed files with 22 additions and 14 deletions
|
|
@ -167,8 +167,8 @@ FileSystemDataManager::FileSystemDataManager(
|
||||||
mIOTarget(std::move(aIOTarget)),
|
mIOTarget(std::move(aIOTarget)),
|
||||||
mIOTaskQueue(std::move(aIOTaskQueue)),
|
mIOTaskQueue(std::move(aIOTaskQueue)),
|
||||||
mRegCount(0),
|
mRegCount(0),
|
||||||
mState(State::Initial),
|
mVersion(0),
|
||||||
mVersion(0) {}
|
mState(State::Initial) {}
|
||||||
|
|
||||||
FileSystemDataManager::~FileSystemDataManager() {
|
FileSystemDataManager::~FileSystemDataManager() {
|
||||||
NS_ASSERT_OWNINGTHREAD(FileSystemDataManager);
|
NS_ASSERT_OWNINGTHREAD(FileSystemDataManager);
|
||||||
|
|
@ -403,14 +403,14 @@ Result<bool, QMResult> FileSystemDataManager::IsLocked(
|
||||||
|
|
||||||
Result<FileId, QMResult> FileSystemDataManager::LockExclusive(
|
Result<FileId, QMResult> FileSystemDataManager::LockExclusive(
|
||||||
const EntryId& aEntryId) {
|
const EntryId& aEntryId) {
|
||||||
QM_TRY_INSPECT(const FileId& fileId,
|
|
||||||
mDatabaseManager->EnsureFileId(aEntryId));
|
|
||||||
|
|
||||||
QM_TRY_UNWRAP(const bool isLocked, IsLocked(aEntryId));
|
QM_TRY_UNWRAP(const bool isLocked, IsLocked(aEntryId));
|
||||||
if (isLocked) {
|
if (isLocked) {
|
||||||
return Err(QMResult(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR));
|
return Err(QMResult(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QM_TRY_INSPECT(const FileId& fileId,
|
||||||
|
mDatabaseManager->EnsureFileId(aEntryId));
|
||||||
|
|
||||||
// If the file has been removed, we should get a file not found error.
|
// If the file has been removed, we should get a file not found error.
|
||||||
// Otherwise, if usage tracking cannot be started because file size is not
|
// Otherwise, if usage tracking cannot be started because file size is not
|
||||||
// known and attempts to read it are failing, lock is denied to freeze the
|
// known and attempts to read it are failing, lock is denied to freeze the
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,8 @@ class FileSystemDataManager
|
||||||
MozPromiseHolder<BoolPromise> mOpenPromiseHolder;
|
MozPromiseHolder<BoolPromise> mOpenPromiseHolder;
|
||||||
MozPromiseHolder<BoolPromise> mClosePromiseHolder;
|
MozPromiseHolder<BoolPromise> mClosePromiseHolder;
|
||||||
uint32_t mRegCount;
|
uint32_t mRegCount;
|
||||||
State mState;
|
|
||||||
DatabaseVersion mVersion;
|
DatabaseVersion mVersion;
|
||||||
|
State mState;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace fs::data
|
} // namespace fs::data
|
||||||
|
|
|
||||||
|
|
@ -587,14 +587,22 @@ Result<FileId, QMResult> FileSystemDatabaseManagerVersion002::EnsureFileId(
|
||||||
return Err(QMResult(NS_ERROR_DOM_NOT_FOUND_ERR));
|
return Err(QMResult(NS_ERROR_DOM_NOT_FOUND_ERR));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mainFileRes = GetFileId(aEntryId);
|
QM_TRY_UNWRAP(Maybe<FileId> maybeMainFileId,
|
||||||
if (mainFileRes.isOk()) {
|
QM_OR_ELSE_LOG_VERBOSE_IF(
|
||||||
return mainFileRes.unwrap();
|
// Expression.
|
||||||
}
|
GetFileId(aEntryId).map([](auto mainFileId) {
|
||||||
|
return Some(std::move(mainFileId));
|
||||||
|
}),
|
||||||
|
// Predicate.
|
||||||
|
IsSpecificError<NS_ERROR_DOM_NOT_FOUND_ERR>,
|
||||||
|
// Fallback.
|
||||||
|
([](const auto&) -> Result<Maybe<FileId>, QMResult> {
|
||||||
|
return Maybe<FileId>{};
|
||||||
|
})));
|
||||||
|
|
||||||
QM_TRY(
|
if (maybeMainFileId) {
|
||||||
OkIf(ToNSResult(mainFileRes.inspectErr()) == NS_ERROR_DOM_NOT_FOUND_ERR),
|
return *maybeMainFileId;
|
||||||
Err(mainFileRes.unwrapErr()));
|
}
|
||||||
|
|
||||||
QM_TRY_UNWRAP(auto transaction, StartedTransaction::Create(mConnection));
|
QM_TRY_UNWRAP(auto transaction, StartedTransaction::Create(mConnection));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "nsIFileProtocolHandler.h"
|
#include "nsIFileProtocolHandler.h"
|
||||||
#include "nsIFileURL.h"
|
#include "nsIFileURL.h"
|
||||||
#include "nsILocalFileWin.h"
|
|
||||||
#include "nsIURIMutator.h"
|
#include "nsIURIMutator.h"
|
||||||
#include "nsTHashMap.h"
|
#include "nsTHashMap.h"
|
||||||
#include "nsXPCOM.h"
|
#include "nsXPCOM.h"
|
||||||
|
|
@ -285,6 +284,7 @@ Result<nsCOMPtr<nsIFile>, QMResult> FileSystemFileManager::CreateFileFrom(
|
||||||
const FileId& aDestinationFileId, const FileId& aSourceFileId) {
|
const FileId& aDestinationFileId, const FileId& aSourceFileId) {
|
||||||
MOZ_ASSERT(!aDestinationFileId.IsEmpty());
|
MOZ_ASSERT(!aDestinationFileId.IsEmpty());
|
||||||
MOZ_ASSERT(!aSourceFileId.IsEmpty());
|
MOZ_ASSERT(!aSourceFileId.IsEmpty());
|
||||||
|
|
||||||
QM_TRY_UNWRAP(nsCOMPtr<nsIFile> original, GetFile(aSourceFileId));
|
QM_TRY_UNWRAP(nsCOMPtr<nsIFile> original, GetFile(aSourceFileId));
|
||||||
|
|
||||||
QM_TRY_UNWRAP(nsCOMPtr<nsIFile> destination,
|
QM_TRY_UNWRAP(nsCOMPtr<nsIFile> destination,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue