diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/quota/DirectoryLock.h | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/quota/DirectoryLock.h')
-rw-r--r-- | dom/quota/DirectoryLock.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/dom/quota/DirectoryLock.h b/dom/quota/DirectoryLock.h new file mode 100644 index 0000000000..af89901cb6 --- /dev/null +++ b/dom/quota/DirectoryLock.h @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DOM_QUOTA_DIRECTORYLOCK_H_ +#define DOM_QUOTA_DIRECTORYLOCK_H_ + +#include "nsTArrayForwardDeclare.h" +#include "mozilla/dom/Nullable.h" +#include "mozilla/dom/quota/Client.h" +#include "mozilla/dom/quota/PersistenceType.h" + +template <class T> +class RefPtr; + +namespace mozilla::dom::quota { + +class ClientDirectoryLock; +enum class DirectoryLockCategory : uint8_t; +struct OriginMetadata; + +// Basic directory lock interface shared by all other directory lock classes. +// The class must contain pure virtual functions only to avoid problems with +// multiple inheritance. +class NS_NO_VTABLE DirectoryLock { + public: + NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING + + virtual int64_t Id() const = 0; + + virtual DirectoryLockCategory Category() const = 0; + + virtual bool Acquired() const = 0; + + virtual bool MustWait() const = 0; + + virtual nsTArray<RefPtr<DirectoryLock>> LocksMustWaitFor() const = 0; + + virtual bool Dropped() const = 0; + + virtual RefPtr<BoolPromise> Acquire() = 0; + + virtual void AcquireImmediately() = 0; + + virtual void AssertIsAcquiredExclusively() = 0; + + virtual void Drop() = 0; + + virtual void OnInvalidate(std::function<void()>&& aCallback) = 0; + + virtual void Log() const = 0; +}; + +// A directory lock specialized for a given origin directory. +class NS_NO_VTABLE OriginDirectoryLock : public DirectoryLock { + public: + // 'Get' prefix is to avoid name collisions with the enum + virtual PersistenceType GetPersistenceType() const = 0; + + virtual quota::OriginMetadata OriginMetadata() const = 0; + + virtual const nsACString& Origin() const = 0; +}; + +// A directory lock specialized for a given client directory (inside an origin +// directory). +class NS_NO_VTABLE ClientDirectoryLock : public OriginDirectoryLock { + public: + virtual Client::Type ClientType() const = 0; +}; + +// A directory lock for universal use. A universal lock can handle any possible +// combination of nullable persistence type, origin scope and nullable client +// type. +// +// For example, if the persistence type is set to null, origin scope is null +// and the client type is set to Client::IDB, then the lock will cover +// <profile>/storage/*/*/idb +// +// If no property is set, then the lock will cover the entire storage directory +// and its subdirectories. +class UniversalDirectoryLock : public DirectoryLock { + public: + // XXX Rename to NullablePersistenceTypeRef. + virtual const Nullable<PersistenceType>& NullablePersistenceType() const = 0; + + // XXX Rename to OriginScopeRef. + virtual const OriginScope& GetOriginScope() const = 0; + + // 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; +}; + +} // namespace mozilla::dom::quota + +#endif // DOM_QUOTA_DIRECTORYLOCK_H_ |