Converts OpenClientDirectory to return ClientDirectoryLockHandle instead of
RefPtr<ClientDirectoryLock>, and updates all its callers accordingly.
ClientDirectoryLockHandle is a move-only RAII wrapper that ensures the lock
is automatically dropped when the handle goes out of scope. This simplifies
ownership semantics and aligns with diagnostic assertions that verify proper
lock dropping.
This patch finalizes the transition for quota clients to use
ClientDirectoryLockHandle instead of client directory locks directly.
Differential Revision: https://phabricator.services.mozilla.com/D243665
Renames DebugOnlyMacro.h to ConditionalCompilation.h to better reflect its
purpose.
The header now contains both DEBUGONLY and DIAGNOSTICONLY macros, which are
used for conditional compilation based on build configuration. The new name
makes the file more general and scalable if future build-scoped macros are
added.
All includes of DebugOnlyMacro.h have been updated accordingly.
Differential Revision: https://phabricator.services.mozilla.com/D243652
`Nullable<ClientType>` currently allows specifying either a concrete client
type or all client types, but does not support more flexible scoping options.
`ClientStorageScope` is designed to address that limitation, with future
support planned for special purpose scopes, such as locking the metadata file
shared by client directories.
This patch updates existing code, particularly around directory locks, to use
`ClientStorageScope` in place of `Nullable<ClientType>`.
Support for additional scope types will be added in a follow-up patch. This
patch focuses on transitioning to the new abstraction.
Differential Revision: https://phabricator.services.mozilla.com/D243630
Captured structured bindings are a C++20 extension, and it's not
supported by Clang < 16, while we theoretically support Clang >= 8
Differential Revision: https://phabricator.services.mozilla.com/D237764
Restore IPC message size limit and introduce explicit structured clone size
limit in IndexedDB
This patch addresses an issue where large arrays of structured clones or keys
(< 64KB each) can accumulate in the IPC message, easily reaching the hard 256
MB IPC limit.
Key Changes:
- Aligned the IPC and IDB-specific IPC message size limits to prevent exceeding
the hard IPC limit.
- Adjusted the IPC message size calculation in IndexedDB to properly account
for shared memory fallback for large structured clones, ensuring that only
necessary data is included in the IPC message.
Note, the way some preferences are handled in IndexedDatabaseManager would
deserve refactoring/cleanup.
Differential Revision: https://phabricator.services.mozilla.com/D235643
QuotaManager::OpenStorageDirectory already makes sure that persistent storage
is initialized so this call is now redundant.
Differential Revision: https://phabricator.services.mozilla.com/D195665
QuotaManager::OpenStorageDirectory can now detect the requested persistence
scope and initialize persistent storage if it's needed.
Differential Revision: https://phabricator.services.mozilla.com/D195661
QuotaManager::OpenClientDirectory already makes sure that corresponding origin
is initialized so all places where a client directory lock is obtained in such
way can start using QuotaManager::GetOriginDirectory instead of
QuotaManager::EnsurePersistentOriginIsInitializedInternal and
QuotaManager::GetOrCreateTemporaryOriginDirectory instead of
QuotaManager::EnsureTemporaryOriginIsInitializedInternal.
Differential Revision: https://phabricator.services.mozilla.com/D195589
LSNG already uses some QuotaManager APIs to achieve that origin directories are
not created if they don't exist during datastore preparation, but the feature
is not easy to use and it's also not generalized enough for use in other quota
clients. Besides that, the way how it's currently done in LSNG complicates
removal of QuotaManager::EnsureTemporaryOriginIsInitializedInternal calls from
LSNG. This patch is about generalizing of the feature, making it available to
all quota clients.
Differential Revision: https://phabricator.services.mozilla.com/D195551
LSNG already uses some QuotaManager APIs to achieve that origin directories are
not created if they don't exist during datastore preparation, but the feature
is not easy to use and it's also not generalized enough for use in other quota
clients. Besides that, the way how it's currently done in LSNG complicates
removal of QuotaManager::EnsureTemporaryOriginIsInitializedInternal calls from
LSNG. This patch is about generalizing of the feature, making it available to
all quota clients.
Differential Revision: https://phabricator.services.mozilla.com/D195551
QuotaManager::OpenStorageDirectory already makes sure that temporary storage
is initialized so all these calls are now redundant.
Differential Revision: https://phabricator.services.mozilla.com/D195395
QuotaManager::OpenStorageDirectory can now detect the requested persistence
scope and initialize temporary storage if it's needed.
Differential Revision: https://phabricator.services.mozilla.com/D195393
QuotaManager::OpenClientDirectory already makes sure that temporary storage
is initialized so all these calls are now redundant.
Differential Revision: https://phabricator.services.mozilla.com/D195391
Nullable<PersistenceType> only allows to specify a concrete persistence type or
all persistence types while PersistenceScope is intended to allow specification
of multiple persistence types as well. Support for that will be added in a
separate patch. This patch is about using the new type especially in directory
locks.
Differential Revision: https://phabricator.services.mozilla.com/D195373
One of the goals of the asynchronous temporary storage initialization is to
call Ensure(Persistent|Temporary)OriginIsInitialized only from
Initialize(Persistent|Temporary)OriginOp. Calling from other places including
quota clients will be disallowed by changing the method to a private method.
The private nature of the method should be emphasized by adding the Internal
suffix.
Differential Revision: https://phabricator.services.mozilla.com/D192150
Maintenance::Abort and DatabaseMaintenance::Abort should not drop any directory
locks. Only Maintenance::Finish and DatabaseMaintenance::RunOnOwningThread are
responsible for cleanup activities like this.
The directory lock for initial collection of databases held by Maintenanace is
normally dropped by BeginDatabaseMaintenance, but if something fails (in any
method), Maintenance::Finish will do the cleanup.
Differential Revision: https://phabricator.services.mozilla.com/D215088
It can happen that DirectoryOpen call in Maintenance::DirectoryLockAcquired
fails or Maintenance::DirectoryWork method fails or
Maintenance::BeginDatabaseMaintenance method fails which results in
Maintenance::Finish being called with not null mDirectoryLock and that
the directory lock hasn't been dropped in Maintenance::BeginDatabaseMaintenance.
Maintenance::Finish should always check and eventually drop the directory lock
instead of relying on Maintenance::BeginDatabaseMaintenance to drop it.
We still want to drop it as soon as possible in
Maintenance::BeginDatabaseMaintenance so other storage operations are not
blocked by the directory lock covering all idb folders for all repositories.
Differential Revision: https://phabricator.services.mozilla.com/D214388
Until now, directory locks were dropped when the last strong reference was
removed or after calling Drop explicitly. The dependency on ref-counting makes
it less obvious when directory locks are dropped for real and it's also
difficult to release them asynchronously eventually. This patch removes the
directory lock unregistration from the destructor, so from now on, directory
locks must be always dropped explicitly.
Differential Revision: https://phabricator.services.mozilla.com/D197294