2021-02-09 13:42:22 +03:00
|
|
|
/* -*- 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_
|
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2021-02-09 13:42:22 +03:00
|
|
|
#include "mozilla/dom/quota/Client.h"
|
|
|
|
#include "mozilla/dom/quota/PersistenceType.h"
|
|
|
|
|
|
|
|
namespace mozilla::dom::quota {
|
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
class ClientDirectoryLock;
|
2021-02-09 13:42:22 +03:00
|
|
|
struct GroupAndOrigin;
|
|
|
|
class OpenDirectoryListener;
|
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
// 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 {
|
2021-02-09 13:42:22 +03:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
virtual int64_t Id() const = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
virtual void Acquire(RefPtr<OpenDirectoryListener> aOpenListener) = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
virtual void AcquireImmediately() = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
// XXX Move to the UniversalDirectoryLock class.
|
|
|
|
virtual RefPtr<ClientDirectoryLock> Specialize(
|
|
|
|
PersistenceType aPersistenceType, const GroupAndOrigin& aGroupAndOrigin,
|
|
|
|
Client::Type aClientType) const = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
virtual void Log() const = 0;
|
|
|
|
};
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
// 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;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
virtual quota::GroupAndOrigin GroupAndOrigin() const = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
virtual const nsACString& Origin() const = 0;
|
|
|
|
};
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
// 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;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
// XXX Rename to OriginScopeRef.
|
|
|
|
virtual const OriginScope& GetOriginScope() const = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
// XXX Rename to NullableClientTypeRef.
|
|
|
|
virtual const Nullable<Client::Type>& NullableClientType() const = 0;
|
2021-02-09 13:42:22 +03:00
|
|
|
};
|
|
|
|
|
2021-02-09 18:01:54 +03:00
|
|
|
class NS_NO_VTABLE OpenDirectoryListener {
|
2021-02-09 13:42:22 +03:00
|
|
|
public:
|
2021-02-09 18:01:54 +03:00
|
|
|
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
|
|
|
|
2021-02-09 13:42:22 +03:00
|
|
|
virtual void DirectoryLockAcquired(DirectoryLock* aLock) = 0;
|
|
|
|
|
|
|
|
virtual void DirectoryLockFailed() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~OpenDirectoryListener() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla::dom::quota
|
|
|
|
|
|
|
|
#endif // DOM_QUOTA_DIRECTORYLOCK_H_
|