Commit Graph

1406 Commits

Author SHA1 Message Date
Jan Varga
d5cca7bb2d Bug 1957367 - QM: Convert OpenClientDirectory and its callers to use ClientDirectoryLockHandle; r=dom-storage-reviewers,jstutte
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
2025-04-15 12:25:49 +00:00
Jan Varga
7b7f9da8c7 Bug 1957367 - QM: Rename DebugOnlyMacro.h to ConditionalCompilation.h; r=dom-storage-reviewers,jstutte
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
2025-04-12 05:34:25 +00:00
Jan Varga
74c99915a3 Bug 1957334 - QM: Replace uses of Nullable<Client::Type> with ClientStorageScope; r=dom-storage-reviewers,jstutte
`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
2025-04-10 05:06:55 +00:00
serge-sans-paille
78f8234f3f Bug 1943756 - Remove C++ construct that relies on C++20 extension r=dom-storage-reviewers,jari
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
2025-02-11 18:32:18 +00:00
Jan Varga
bdb79a5323 Bug 1943951 - Restore previous IPC message size limit and introduce a new explicit structured clone size limit to fix a crash; r=nika,smaug
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
2025-02-03 16:36:52 +00:00
serge-sans-paille
262f78c07f Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 08:21:19 +00:00
Alexandru Marc
a5eb905bf4 Backed out changeset d92f391b3b0c (bug 1922838) for backing out bug 1915351 2024-10-25 16:42:33 +03:00
serge-sans-paille
07101ac24d Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-24 09:06:01 +00:00
Jan Varga
f0640d46f6 Bug 1903816 - GetDatabasesOp::SendResults doesn't check if operation failed; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D226739
2024-10-24 08:56:31 +00:00
Alexandru Marc
004e704b22 Backed out changeset 448597bce69d (bug 1922838) for causing build bustages. CLOSED TREE 2024-10-24 11:37:49 +03:00
serge-sans-paille
2c916d4973 Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-24 07:38:30 +00:00
Jan Varga
95554c8edd Bug 1926565 - IDB: Ensure that a closed connection is not used when asserting that the current thread is the connection thread; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D226649
2024-10-23 20:17:07 +00:00
Jan Varga
b1bb047866 Bug 1926565 - IDB: Remove a meaningless assertion; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D226638
2024-10-23 20:17:07 +00:00
Jan Varga
48a999da72 Bug 1904562 - Change DirectoryLockImpl to be topmost class; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D214857
2024-10-21 09:31:27 +00:00
Jan Varga
36ded0ff50 Bug 1904562 - Convert IndexedDB to use concrete directory lock type; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D214855
2024-10-21 09:31:26 +00:00
Jan Varga
e3dea7bd08 Bug 1904562 - Move ClientDirectoryLock to separate files and make it inherit from DirectoryLockImpl; r=dom-storage-reviewers,aiunusov
Differential Revision: https://phabricator.services.mozilla.com/D214849
2024-10-21 09:31:23 +00:00
Jan Varga
bb854e20b6 Bug 1904562 - Move UniversalDirectoryLock to separate files and make it inherit from DirectoryLockImpl; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D214818
2024-10-21 09:31:22 +00:00
Jan Varga
dcedb93285 Bug 1867997 - Simplify signature of QuotaManager::OnOriginClearCompleted; r=dom-storage-reviewers,jari
OnOriginClearCompleted currently takes two separate arguments which can be
expressed as just one argument.

Differential Revision: https://phabricator.services.mozilla.com/D198494
2024-10-18 13:14:03 +00:00
Jan Varga
8cdc63b5d9 Bug 1867997 - Move nsIPrincipal/PrincipalInfo helpers to separate files; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D223992
2024-10-18 01:32:36 +00:00
Jan Varga
dbc9573884 Bug 1867997 - Change QuotaManager::GetInfoFromValidatedPrincipalInfo to be a stacic method; r=dom-storage-reviewers,jari
This is a preparation for moving all nsIPrincipal and PrincipalInfo helpers to separate source files.

Differential Revision: https://phabricator.services.mozilla.com/D223950
2024-10-18 01:32:35 +00:00
Jan Varga
4e199dfdbe Bug 1866402 - Remove QuotaManager::EnsurePersistentOriginIsInitializedInternal calls from IndexedDB maintenance; r=dom-storage-reviewers,aiunusov,jari
QuotaManager::OpenStorageDirectory already makes sure that persistent storage
is initialized so this call is now redundant.

Differential Revision: https://phabricator.services.mozilla.com/D195665
2024-10-15 12:33:30 +00:00
Jan Varga
cd2d5f13f3 Bug 1866402 - Add support for initializing persistent storage to QuotaManager::OpenStorageDirectory; r=dom-storage-reviewers,jari
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
2024-10-15 05:12:36 +00:00
Jan Varga
beb966a005 Bug 1866402 - Replace most of QuotaManager::EnsurePersistentOriginIsInitializedInternal and QuotaManager::EnsureTemporaryOriginIsInitializedInternal calls; r=dom-storage-reviewers,jari
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
2024-10-13 23:05:25 +00:00
Jan Varga
7783acd7c8 Bug 1866402 - Make it possible to initialize temporary origins without ensuring origin directories; r=dom-storage-reviewers,jari
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
2024-10-12 20:58:36 +00:00
Sebastian Hengst
1a2fdf5653 Backed out 7 changesets (bug 1866402) for causing crashes (bug 1762908). a=backout
Backed out changeset 6180f2e753bd (bug 1866402)
Backed out changeset f25dfc157ef7 (bug 1866402)
Backed out changeset d63dac1ee4d4 (bug 1866402)
Backed out changeset 2ab08c49f2b1 (bug 1866402)
Backed out changeset 48781c71d287 (bug 1866402)
Backed out changeset a649d075c9b3 (bug 1866402)
Backed out changeset cc03e4975743 (bug 1866402)
2024-10-11 12:47:35 +02:00
Jan Varga
a426b86e42 Bug 1866402 - Make it possible to initialize temporary origins without ensuring origin directories; r=dom-storage-reviewers,jari
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
2024-10-10 12:22:55 +00:00
Jan Varga
493b80e184 Bug 1914599 - Fix a potential race between OpenDatabaseOp and GetDatabasesOp; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D224463
2024-10-09 18:19:22 +00:00
Jan Varga
f504456106 Bug 1913561 - Remove QuotaManager::EnsureTemporaryStorageIsInitializedInternal calls from places where a directory lock is obtained via QuotaManager::OpenStorageDirectory; r=dom-storage-reviewers,jari
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
2024-10-07 10:25:01 +00:00
Jan Varga
3cddbe3e4d Bug 1913561 - Add support for initializing temporary storage to QuotaManager::OpenStorageDirectory; r=dom-storage-reviewers,jari
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
2024-10-06 22:04:46 +00:00
Jan Varga
fc0786849f Bug 1913561 - Remove QuotaManager::EnsureTemporaryStorageIsInitializedInternal calls from places where a directory lock is obtained via QuotaManager::OpenClientDirectory; r=dom-storage-reviewers,jari
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
2024-10-06 02:01:00 +00:00
Jan Varga
9b404423d6 Bug 1920487 - QM: Rename helpers for resolving nsresult type; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D223131
2024-10-04 16:57:02 +00:00
Jan Varga
8a7191b5fa Bug 1919493 - IDB: Propagate database invalidation when the actor becomes alive; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220674
2024-10-01 17:35:59 +00:00
Jan Varga
3b893df97f Bug 1919493 - IDB: Add handling for directory locks invalidated during database initialization; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220248
2024-10-01 17:35:57 +00:00
Jan Varga
5fe4f03d52 Bug 1919493 - IDB: Add support for pausing QM IO thread after finishing database initialization; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220246
2024-10-01 17:35:57 +00:00
Jan Varga
b885ef1405 Bug 1919493 - IDB: Add a new testing only notification for database work starting; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D220245
2024-10-01 17:35:56 +00:00
Harveer Singh
043fae3200 Bug 1914982: Fixing the race condition in FileInfoManager.h.r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D222469
2024-09-23 21:40:52 +00:00
Jan Varga
0a14929610 Bug 1917462 - IDB: Add handling for invalidated directory locks; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D219631
2024-09-16 22:17:06 +00:00
Jan Varga
9ccefe3399 Bug 1917462 - Convert anonymous lambda to a named lambda in FactoryOp::DirectoryLockAcquired; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D219630
2024-09-16 22:17:06 +00:00
Jan Varga
d0a8f8f6a6 Bug 1866217 - Replace uses of Nullable<PersistenceType> type with PersistenceScope; r=dom-storage-reviewers,jari
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
2024-08-14 12:46:14 +00:00
Jan Varga
0d373bc154 Bug 1906041 - Rename Ensure(Persistent|Temporary)OriginIsInitialized to Ensure(Persistent|Temporary)OriginIsInitializedInternal; r=dom-storage-reviewers,jari
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
2024-07-16 10:43:40 +00:00
Jan Varga
0de36a844f Bug 1906041 - Simplify signature of QuotaManager::EnsureTemporaryOriginIsInitialized; r=dom-storage-reviewers,jari
EnsureTemporaryOriginIsInitialized currently takes two separate arguments which
can be expressed as just one argument.

Differential Revision: https://phabricator.services.mozilla.com/D192149
2024-07-16 10:43:39 +00:00
Jan Varga
ebd2245035 Bug 1889563 - Bring back debug only slowing down of connection pool threads; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D206589
2024-07-11 06:36:09 +00:00
Jan Varga
c9d406bb7a Bug 1903806 - Clean up directory lock dropping in Maintenance and DatabaseMaintenance; r=dom-storage-reviewers,aiunusov
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
2024-06-28 14:13:45 +00:00
Jan Varga
7850cdbb8f Bug 1903387 - Always check and eventually drop directory lock in Maintenance::Finish; r=dom-storage-reviewers,jstutte
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
2024-06-20 23:37:52 +00:00
Jan Varga
381e78c9df Bug 1888878 - Add nsIIndexedDatabaseManager::DoMaintenance; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D206256
2024-06-20 17:27:10 +00:00
Jan Varga
47f5cd1d79 Bug 1888878 - Add QuotaClient::DoMaintenance; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D206223
2024-06-20 07:28:39 +00:00
Jan Varga
530773f7eb Bug 1888878 - Add Maintenance::OnResults; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D206222
2024-06-20 07:28:38 +00:00
Jan Varga
990995f746 Bug 1883045 - Handle IDBTransaction durability hints; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D204868
2024-06-19 13:46:35 +00:00
Jan Varga
d23f2205b4 Bug 1903169 - Drop directory lock only when GetDatabasesOp owns one; r=dom-storage-reviewers,aiunusov
Differential Revision: https://phabricator.services.mozilla.com/D214070
2024-06-18 13:01:45 +00:00
Jan Varga
e87e849e0f Bug 1883353 - Require to always drop directory locks explicitly; r=dom-storage-reviewers,jari
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
2024-06-14 07:21:24 +00:00