mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1690025 - Move and rename DirectoryLock::Specialize to UniversalDirectoryLock::SpecializeForClient; r=dom-storage-reviewers,asuth
This patch also changes the only consumer to not depend on the lock passed to OpenDirectoryListener::DirectoryLockAcquired because it uses the base type ( unsafe static_cast would have to be used). Differential Revision: https://phabricator.services.mozilla.com/D104804
This commit is contained in:
parent
083983b7f0
commit
2372314fa1
@ -5169,7 +5169,8 @@ class Maintenance final : public Runnable, public OpenDirectoryListener {
|
||||
|
||||
RefPtr<QuotaClient> mQuotaClient;
|
||||
PRTime mStartTime;
|
||||
RefPtr<DirectoryLock> mDirectoryLock;
|
||||
RefPtr<UniversalDirectoryLock> mPendingDirectoryLock;
|
||||
RefPtr<UniversalDirectoryLock> mDirectoryLock;
|
||||
nsTArray<DirectoryInfo> mDirectoryInfos;
|
||||
nsTHashMap<nsStringHashKey, DatabaseMaintenance*> mDatabaseMaintenances;
|
||||
nsresult mResultCode;
|
||||
@ -13432,14 +13433,19 @@ nsresult Maintenance::OpenDirectory() {
|
||||
|
||||
// Get a shared lock for <profile>/storage/*/*/idb
|
||||
|
||||
RefPtr<DirectoryLock> directoryLock =
|
||||
QuotaManager::Get()->CreateDirectoryLockInternal(
|
||||
Nullable<PersistenceType>(), OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(Client::IDB),
|
||||
/* aExclusive */ false);
|
||||
mPendingDirectoryLock = QuotaManager::Get()->CreateDirectoryLockInternal(
|
||||
Nullable<PersistenceType>(), OriginScope::FromNull(),
|
||||
Nullable<Client::Type>(Client::IDB),
|
||||
/* aExclusive */ false);
|
||||
|
||||
mState = State::DirectoryOpenPending;
|
||||
directoryLock->Acquire(this);
|
||||
|
||||
{
|
||||
// Pin the directory lock, because Acquire might clear mPendingDirectoryLock
|
||||
// during the Acquire call.
|
||||
RefPtr pinnedDirectoryLock = mPendingDirectoryLock;
|
||||
pinnedDirectoryLock->Acquire(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -13765,7 +13771,7 @@ nsresult Maintenance::BeginDatabaseMaintenance() {
|
||||
for (const nsString& databasePath : *directoryInfo.mDatabasePaths) {
|
||||
if (Helper::IsSafeToRunMaintenance(databasePath)) {
|
||||
if (!directoryLock) {
|
||||
directoryLock = mDirectoryLock->Specialize(
|
||||
directoryLock = mDirectoryLock->SpecializeForClient(
|
||||
directoryInfo.mPersistenceType,
|
||||
*directoryInfo.mFullOriginMetadata, Client::IDB);
|
||||
MOZ_ASSERT(directoryLock);
|
||||
@ -13888,7 +13894,7 @@ void Maintenance::DirectoryLockAcquired(DirectoryLock* aLock) {
|
||||
MOZ_ASSERT(mState == State::DirectoryOpenPending);
|
||||
MOZ_ASSERT(!mDirectoryLock);
|
||||
|
||||
mDirectoryLock = aLock;
|
||||
mDirectoryLock = std::exchange(mPendingDirectoryLock, nullptr);
|
||||
|
||||
nsresult rv = DirectoryOpen();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -13908,6 +13914,8 @@ void Maintenance::DirectoryLockFailed() {
|
||||
MOZ_ASSERT(mState == State::DirectoryOpenPending);
|
||||
MOZ_ASSERT(!mDirectoryLock);
|
||||
|
||||
mPendingDirectoryLock = nullptr;
|
||||
|
||||
if (NS_SUCCEEDED(mResultCode)) {
|
||||
mResultCode = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -30,11 +30,6 @@ class NS_NO_VTABLE DirectoryLock {
|
||||
|
||||
virtual void AcquireImmediately() = 0;
|
||||
|
||||
// XXX Move to the UniversalDirectoryLock class.
|
||||
virtual RefPtr<ClientDirectoryLock> Specialize(
|
||||
PersistenceType aPersistenceType, const OriginMetadata& aOriginMetadata,
|
||||
Client::Type aClientType) const = 0;
|
||||
|
||||
virtual void Log() const = 0;
|
||||
};
|
||||
|
||||
@ -76,6 +71,10 @@ class UniversalDirectoryLock : public DirectoryLock {
|
||||
|
||||
// XXX Rename to NullableClientTypeRef.
|
||||
virtual const Nullable<Client::Type>& NullableClientType() const = 0;
|
||||
|
||||
virtual RefPtr<ClientDirectoryLock> SpecializeForClient(
|
||||
PersistenceType aPersistenceType, const OriginMetadata& aOriginMetadata,
|
||||
Client::Type aClientType) const = 0;
|
||||
};
|
||||
|
||||
class NS_NO_VTABLE OpenDirectoryListener {
|
||||
|
@ -201,7 +201,7 @@ void DirectoryLockImpl::AcquireImmediately() {
|
||||
mQuotaManager->RegisterDirectoryLock(*this);
|
||||
}
|
||||
|
||||
RefPtr<ClientDirectoryLock> DirectoryLockImpl::Specialize(
|
||||
RefPtr<ClientDirectoryLock> DirectoryLockImpl::SpecializeForClient(
|
||||
PersistenceType aPersistenceType,
|
||||
const quota::OriginMetadata& aOriginMetadata,
|
||||
Client::Type aClientType) const {
|
||||
|
@ -173,11 +173,6 @@ class DirectoryLockImpl final : public ClientDirectoryLock,
|
||||
|
||||
void AcquireImmediately() override;
|
||||
|
||||
RefPtr<ClientDirectoryLock> Specialize(
|
||||
PersistenceType aPersistenceType,
|
||||
const quota::OriginMetadata& aOriginMetadata,
|
||||
Client::Type aClientType) const override;
|
||||
|
||||
void Log() const override;
|
||||
|
||||
// OriginDirectoryLock interface
|
||||
@ -223,6 +218,11 @@ class DirectoryLockImpl final : public ClientDirectoryLock,
|
||||
return mClientType;
|
||||
}
|
||||
|
||||
RefPtr<ClientDirectoryLock> SpecializeForClient(
|
||||
PersistenceType aPersistenceType,
|
||||
const quota::OriginMetadata& aOriginMetadata,
|
||||
Client::Type aClientType) const override;
|
||||
|
||||
private:
|
||||
~DirectoryLockImpl();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user