mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1749504 - Convert SimpleDB to use the new way to access a client directory; r=dom-storage-reviewers,jstutte
SimpleDB currently creates a client directory lock first and then when the client directorylock is acquired, it bounces to the QuotaManager I/O thread where it ensures that storage is initialized. This can be now replaced by just calling QuotaManager::OpenClientDirectory. Changes done in this patch: - replaced QuotaManager::CreateDirectoryLock call with QuotaManager::OpenClientDirectory - removed EnsureStorageIsInitializedInternal call from OpenOp::DatabaseWork - changed OpenOp to not inherit from OpenDirectoryListener Differential Revision: https://phabricator.services.mozilla.com/D186118
This commit is contained in:
parent
924f066162
commit
4a9479f3fc
@ -302,8 +302,7 @@ class ConnectionOperationBase : public Runnable,
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
};
|
||||
|
||||
class OpenOp final : public ConnectionOperationBase,
|
||||
public OpenDirectoryListener {
|
||||
class OpenOp final : public ConnectionOperationBase {
|
||||
enum class State {
|
||||
// Just created on the PBackground thread, dispatched to the main thread.
|
||||
// Next step is FinishOpen.
|
||||
@ -367,15 +366,12 @@ class OpenOp final : public ConnectionOperationBase,
|
||||
|
||||
void Cleanup() override;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD
|
||||
Run() override;
|
||||
|
||||
// OpenDirectoryListener overrides.
|
||||
void DirectoryLockAcquired(DirectoryLock* aLock) override;
|
||||
void DirectoryLockAcquired(DirectoryLock* aLock);
|
||||
|
||||
void DirectoryLockFailed() override;
|
||||
void DirectoryLockFailed();
|
||||
};
|
||||
|
||||
class SeekOp final : public ConnectionOperationBase {
|
||||
@ -1130,12 +1126,20 @@ nsresult OpenOp::FinishOpen() {
|
||||
|
||||
// Open the directory
|
||||
|
||||
RefPtr<DirectoryLock> directoryLock = quotaManager->CreateDirectoryLock(
|
||||
{mOriginMetadata, mozilla::dom::quota::Client::SDB},
|
||||
/* aExclusive */ false);
|
||||
|
||||
mState = State::DirectoryOpenPending;
|
||||
directoryLock->Acquire(this);
|
||||
|
||||
quotaManager
|
||||
->OpenClientDirectory({mOriginMetadata, mozilla::dom::quota::Client::SDB})
|
||||
->Then(
|
||||
GetCurrentSerialEventTarget(), __func__,
|
||||
[self = RefPtr(this)](
|
||||
const ClientDirectoryLockPromise::ResolveOrRejectValue& aValue) {
|
||||
if (aValue.IsResolve()) {
|
||||
self->DirectoryLockAcquired(aValue.ResolveValue());
|
||||
} else {
|
||||
self->DirectoryLockFailed();
|
||||
}
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1181,8 +1185,6 @@ nsresult OpenOp::DatabaseWork() {
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
QM_TRY(MOZ_TO_RESULT(quotaManager->EnsureStorageIsInitializedInternal()));
|
||||
|
||||
QM_TRY_INSPECT(
|
||||
const auto& dbDirectory,
|
||||
([persistenceType = GetConnection()->GetPersistenceType(), "aManager,
|
||||
@ -1341,8 +1343,6 @@ void OpenOp::Cleanup() {
|
||||
ConnectionOperationBase::Cleanup();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(OpenOp, ConnectionOperationBase)
|
||||
|
||||
NS_IMETHODIMP
|
||||
OpenOp::Run() {
|
||||
nsresult rv;
|
||||
|
Loading…
Reference in New Issue
Block a user