Commit Graph

104 Commits

Author SHA1 Message Date
Jan Varga
386cb25a51 Bug 1962126 - QM: Avoid QM_TRY warnings caused by LSNG preloading fallback; r=dom-storage-reviewers,jstutte
Suppresses QM_TRY warning output in expected LSNG preloading scenarios by
introducing a new error code (NS_ERROR_DOM_QM_CLIENT_INIT_ORIGIN_UNINITIALIZED)
and ensuring it is processed without logging. This prevents terminal/system
console noise during normal fallback behavior when an origin directory has not
been initialized yet.

This patch also introduces a dedicated error module for QuotaManager, which has
been planned for some time and now provides a clean way to define and isolate
QuotaManager specific error codes.

These changes finalize the preparation for adding client initialization to
QuotaManager::OpenClientDirectory, while preserving LSNG’s delayed origin
initialization strategy.

Differential Revision: https://phabricator.services.mozilla.com/D246567
2025-05-16 11:24:46 +00:00
Jan Varga
c878226a2b Bug 1962126 - QM: Align client initialization signatures with origin initialization; r=dom-storage-reviewers,jstutte
Aligns the signatures of client initialization methods with those used for
origin initialization, primarily by adding the aCreateIfNonExistent parameter.

This change prepares the way for supporting delayed creation of client
directories in QuotaManager::OpenClientDirectory, as required by the LSNG quota
client. LSNG delays creation of origin and client directories for performance
reasons, and this refactoring ensures that behavior can be preserved when
client initialization is added to OpenClientDirectory.

Differential Revision: https://phabricator.services.mozilla.com/D246563
2025-05-16 07:00:39 +00:00
Jan Varga
3957b02801 Bug 1962126 - QM: Change client initialization methods to use ClientMetadata and pre-acquired locks; r=dom-storage-reviewers,jstutte
Refactors client initialization methods to take ClientMetadata instead of
PrincipalInfo and other individual arguments, and updates relevant client
initialization operations to use pre-acquired directory locks. These are both
necessary steps for integrating client initialization into
QuotaManager::OpenClientDirectory.

Behavior remains unchanged for now.

Differential Revision: https://phabricator.services.mozilla.com/D246559
2025-05-14 21:22:33 +00:00
Jan Varga
9fa68a2225 Bug 1959622 - QM: Add support for tracking SaveOriginAccessTime metadata updates; r=dom-storage-reviewers,asuth
Introduce methods SaveOriginAccessTimeCount/SaveOriginAccessTimeCountInternal
and IncreaseSaveOriginAccessTimeCount/IncreaseSaveOriginAccessTimeCountInternal
to track SaveOriginAccessTime metadata updates.

This is mainly preparation for more complex testing related to the planned
transition from directory lock based to handle based access time tracking,
which will be handled by QuotaManager::OpenClientDirectory.

Currently, access time updates may be skipped in some edge cases. The
transition and follow-up patches will address those cases, and these new
counters will help test that updates are applied consistently.

Differential Revision: https://phabricator.services.mozilla.com/D244776
2025-05-09 09:16:30 +00:00
Jan Varga
a1578cd9ca Bug 1957334 - QM: Scope saving of origin access time to metadata only; r=dom-storage-reviewers,jstutte
Saving of origin access time currently uses a directory lock over the entire
origin directory, which unnecessarily blocks exclusive directory locks for
individual clients.

This patch scopes SaveOriginAccessTime to metadata only by using a dedicated
ClientStorageScope, so that it no longer conflicts with client level exclusive
locks. This improves concurrency and prevents unrelated client operations from
being blocked by metadata access.

A previously disabled gtest has been enabled to verify that
SaveOriginAccessTime resolves correctly even when an exclusive client lock is
held.

Differential Revision: https://phabricator.services.mozilla.com/D243646
2025-04-11 06:11:11 +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
Jan Varga
e37b690cd1 Bug 1956260 - QM: Expose saving of origin access time; r=dom-storage-reviewers,jstutte
This patch introduces a `SaveOriginAccessTime` method in `QuotaManager`,
enabling code to directly trigger origin access time updates.

While this functionality is currently needed only for writing new gtests to
verify directory locking behavior, it is also a preparatory step toward
integrating access time saving into the `QuotaManager::OpenClientDirectory`
promise chain in the future.

The method is not yet exposed to xpcshell tests. Doing so would require
extending `nsIQuotaManagerService` and implementing the necessary IPC plumbing,
which may be done in a future patch if needed.

Differential Revision: https://phabricator.services.mozilla.com/D243074
2025-04-07 11:57:59 +00:00
Jan Varga
76fafd29fc Bug 1933053 - QM: Optimize thumbnail private identity pattern clearing in ClearDataOp::DoDirectoryWork; r=dom-storage-reviewers,asuth
This patch improves the performance of ClearDataOp::DoDirectoryWork by
introducing a conditional optimization for thumbnail private identity patterns.

If the thumbnail private identity id is known, and the pattern matches the
thumbnail private identity pattern, and temporary storage is initialized, and
there are no thumbnail private identity temporary origins, the operation skips
iterating over all temporary storage repositories (only persistent repository
is traversed).

This optimization is especially important during shutdown, where reducing
unnecessary operations can help minimize delays and improve performance.

Differential Revision: https://phabricator.services.mozilla.com/D230183
2024-12-18 13:25:23 +00:00
Jan Varga
8f6f907c24 Bug 1933053 - QM: Rework QuotaManagerService::ListOrigins to use an async message with an async response; r=dom-storage-reviewers,asuth
A sub actor is no longer created. Actual result is now returned as an
asynchronous response to an asynchronous message.

Although this modernizes the code, the primary motivation is to enable calling
QuotaManager::ListOrigins in gtests.

Differential Revision: https://phabricator.services.mozilla.com/D230137
2024-12-14 21:48:18 +00:00
Jan Varga
5aa9f83272 Bug 1933053 - QM: Add partial support for tracking total directory iterations; r=dom-storage-reviewers,asuth
Introduce mTotalDirectoryIterations and methods TotalDirectoryIterations and
IncreaseTotalDirectoryIterations to track directory traversal count. Currently,
only clearing operations increase this counter, with full support to be added
later.

Differential Revision: https://phabricator.services.mozilla.com/D230094
2024-12-14 17:26:39 +00:00
Jan Varga
2368724e35 Bug 1931513 - QM: Change also TemporaryGroupInitialized to take PrincipalMetadata instead of PrincipalInfo; r=dom-storage-reviewers,jari
This is not strictly required to get rid of PrincipalMetadataToPrincipalInfo,
but it's better for consistency and readability.

Differential Revision: https://phabricator.services.mozilla.com/D229646
2024-12-07 06:59:18 +00:00
Jan Varga
bbe6b61b43 Bug 1931513 - QM: Change group initialization related methods to take PrincipalMetadata instead of PrincipalInfo; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D229645
2024-12-07 06:59:18 +00:00
Jan Varga
bcd1ef4277 Bug 1931513 - QM: Change temporary origin initialization related methods to take OriginMetadata instead of PersistenceType and PrincipalMetadata; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D229644
2024-12-07 06:59:17 +00:00
Jan Varga
8cc4be68d2 Bug 1931513 - QM: Change persistent origin initialization related methods to take OriginMetadata instead of PrincipalMetadata; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D229643
2024-12-07 06:59:16 +00:00
Jan Varga
0713ce3f7e Bug 1931513 - QM: Change also PersistentOriginInitialized and TemporaryOriginInitialize to take PrincipalMetadata instead of PrincipalInfo; r=dom-storage-reviewers,jari
This is not strictly required to get rid of PrincipalMetadataToPrincipalInfo,
but it's better for consistency and readability.

Differential Revision: https://phabricator.services.mozilla.com/D229596
2024-12-07 06:59:15 +00:00
Jan Varga
86fa7e0dff Bug 1931513 - QM: Change origin initialization related methods to take PrincipalMetadata instead of PrincipalInfo; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D229593
2024-12-07 06:59:14 +00:00
Jan Varga
c2a0dd3d3c Bug 1928092 - QM: Add temporary origin to cached origins even if directory metadata creation fails; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D228082
2024-11-10 11:17:22 +00:00
Jan Varga
643c83124a Bug 1927723 - QM: Add support for listing cached origins; r=dom-storage-reviewers,jari
This patch also extends ResolvableNormalOriginOp to enable debug-only checks in
UnwrapResolveValue overrides, ensuring that the method is called no more than
once.

Differential Revision: https://phabricator.services.mozilla.com/D227198
2024-11-08 11:15:49 +00:00
Jan Varga
5ef4edde18 Bug 1911030 - Rename ResolvableNormalOriginOp::GetResolveValue to ResolvableNormalOriginOp::UnwrapResolveValue; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D226738
2024-10-28 15:32:12 +00:00
Jan Varga
1437944aee Bug 1904562 - Move OriginDirectoryLock to separate files and make it inherit from DirectoryLockImpl; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D214848
2024-10-21 09:31:22 +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
13760d78ec Bug 1867997 - Add support for continuous background initialization of all temporary origins collected during temporary storage initialization; r=dom-storage-reviewers,jari
This is finally the patch which fundamentally changes the way how temporary
origins are initialized. Currently, when temporary storage is accessed for the
first time, all temporary origins need to be synchronously initialized. This
causes two major problems. First, large temporary storage can block first page
load for long time. Second, one broken origin breaks entire temporary storage.
These two problems can be mitigated in a big way by making the initialization
asynchronous. A lot of stuff had to be refactored, new infrastructure had to be
added and the support for conditional lazy initialization of origins had to be
implemented. This patch adds support for continuous background initialization
of all temporary origins collected during temporary storage initialization. So
if a page needs to access temporary storage, only origins for given group are
initialized. Origins for other groups are initialized in the background.

The background origin initialization is still considered to be experimental,
not recommended for normal use (disabled by default).

Differential Revision: https://phabricator.services.mozilla.com/D199082
2024-10-20 10:50:40 +00:00
Jan Varga
1020110797 Bug 1867997 - Maintain a list of all available temporary origins; r=dom-storage-reviewers,jari
The list will be initially only used for starting asynchronous initialization
of origins in the background, but it can be later also used for optimizing more
complex clearing operations to avoid traversing all origin directories on disk.

Differential Revision: https://phabricator.services.mozilla.com/D198990
2024-10-18 13:14:04 +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
32d7ab8d6f Bug 1867997 - Add support for initializing temporary groups; r=dom-storage-reviewers,jari
The planned asynchronous temporary origin initialization in the background
will initialize temporary origins in groups to prevent situations when an
already initialized temporary origin would cause that group usage exceeds the
group limit (this could happen because the final/precise group usage would not
be known until all temporary origins for the group are initialized). So this
patch adds initial support for initializing temporary groups.

Differential Revision: https://phabricator.services.mozilla.com/D196826
2024-10-18 01:32:38 +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
03c4470197 Bug 1867997 - Fix EstimateOp to lock entire origin group; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D196048
2024-10-17 10:14:47 +00:00
Jan Varga
76abbac890 Bug 1867997 - Change OriginScope::FromOrigin and OriginScope::FromPrefix signatures to take PrincipalMetadata; r=dom-storage-reviewers,jari
The planned group (eTLD+1 domain) support in OriginScope will require access to
the group of a particular origin. PrincipalMetadata will not only allow easy
access to the group, but it will also allow further DirectoryLockImpl cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D196034
2024-10-16 07:32:39 +00:00
Jan Varga
0c1566f749 Bug 1866402 - Implement initialization of entire persistent storage; r=dom-storage-reviewers,jari
IndexedDB still calls QuotaManager::EnsurePersistentOriginIsInitializedInternal
from its idle database maintenance. However, we want to get rid of that so the
method can be made private. The idle database maintenance should only rely on
QuotaManager::OpenStorageDirectory method to do all necessary initialization.
Before we can do that, we need a method dedicated for initialization of entire
persistent storage.

Differential Revision: https://phabricator.services.mozilla.com/D195653
2024-10-14 10:06:14 +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
Jan Varga
f60983e284 Bug 1866402 - Update the cached value in PersistOp::DoDirectoryWork only after successful creation of the metadata file; r=dom-storage-reviewers,jari
Currently, the cached value is updated before creation of the metadata file
which can lead to a mismatch between the metadata file and the cached value if
creation of the metadata file fails. It will be safer to update the cached
value only after successful creation of the metadata file.

Differential Revision: https://phabricator.services.mozilla.com/D198670
2024-10-12 10:00:14 +00:00
Jan Varga
a227650eeb Bug 1866402 - Update the cached value in PersistOp::DoDirectoryWork only when the value changed in the metadata file; r=dom-storage-reviewers,jari
Currently, we call QuotaManager::PersistOrigin even when the origin was already
persisted. QuotaManager::PersistOrigin won't try to update the value again,
but it will have to do a hash lookup. We can easilly avoid this by calling
QuotaManager::PersistOrigin only when the value changed in the metadata file.

Differential Revision: https://phabricator.services.mozilla.com/D198668
2024-10-12 10:00:14 +00:00
Jan Varga
68747ea413 Bug 1866402 - Use the cached value if it's available in PersistOp::DoDirectoryWork; r=dom-storage-reviewers,jari
If temporary storage is already initialized, we can use the cached value and
avoid reading it from the metadata file (which was used for loading the cached
value).

Differential Revision: https://phabricator.services.mozilla.com/D198664
2024-10-12 10:00:14 +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
52e0ac7b76 Bug 1866402 - Update the cached value in PersistOp::DoDirectoryWork only after successful creation of the metadata file; r=dom-storage-reviewers,jari
Currently, the cached value is updated before creation of the metadata file
which can lead to a mismatch between the metadata file and the cached value if
creation of the metadata file fails. It will be safer to update the cached
value only after successful creation of the metadata file.

Differential Revision: https://phabricator.services.mozilla.com/D198670
2024-10-10 12:22:54 +00:00
Jan Varga
22902c6ba5 Bug 1866402 - Update the cached value in PersistOp::DoDirectoryWork only when the value changed in the metadata file; r=dom-storage-reviewers,jari
Currently, we call QuotaManager::PersistOrigin even when the origin was already
persisted. QuotaManager::PersistOrigin won't try to update the value again,
but it will have to do a hash lookup. We can easilly avoid this by calling
QuotaManager::PersistOrigin only when the value changed in the metadata file.

Differential Revision: https://phabricator.services.mozilla.com/D198668
2024-10-10 12:22:54 +00:00
Jan Varga
3856184613 Bug 1866402 - Use the cached value if it's available in PersistOp::DoDirectoryWork; r=dom-storage-reviewers,jari
If temporary storage is already initialized, we can use the cached value and
avoid reading it from the metadata file (which was used for loading the cached
value).

Differential Revision: https://phabricator.services.mozilla.com/D198664
2024-10-10 12:22:53 +00:00
Jan Varga
1b8289e189 Bug 1866402 - Add UninitOrigins directory lock category and use it for directory locks which uninitialize origins; r=dom-storage-reviewers,jari
The new category is needed for implementing an optimization in
QuotaManager::InitializePersistentOrigin,
QuotaManager::InitializeTemporaryOrigin and
QuotaManager::OpenClientDirectory to avoid creating a new origin initialization
operations when a given origin is already initialized.

Differential Revision: https://phabricator.services.mozilla.com/D195543
2024-10-09 22:16:52 +00:00
Jan Varga
1ac5d967d3 Bug 1866402 - Implement origin initialization status tracking on the owning thread; r=dom-storage-reviewers,jari
Origin initialization tracking on the owning thread is needed for covering
origin initialization in QuotaManager::OpenClientDirectory.

Differential Revision: https://phabricator.services.mozilla.com/D195535
2024-10-09 22:16:52 +00:00
Jan Varga
bf79d79484 Bug 1866402 - Add nsIQuotaManagerService::PersistentOriginInitialized and nsIQuotaManagerService::TemporaryOriginInitialized methods; r=dom-storage-reviewers,jari
This additional testing infrastructure is needed for verifying origin
initialization status.

Differential Revision: https://phabricator.services.mozilla.com/D195526
2024-10-09 22:16:50 +00:00
Jan Varga
3d7a29952a Bug 1866402 - Change all origin operations which uninit origins to return an array of origin metadata; r=dom-storage-reviewers,jari
This is a preparation for unsetting some flags when origins are either cleared
or reset.

Differential Revision: https://phabricator.services.mozilla.com/D195522
2024-10-09 22:16:50 +00:00
Jan Varga
169df9071e Bug 1866402 - Change nsIQuotaManagerService::ResetStoragesForPrincipal to support resetting of entire origins only; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D195510
2024-10-09 11:59:35 +00:00
Jan Varga
6e58d18911 Bug 1866402 - Add a dedicated method for resetting storages of a specific client; r=dom-storage-reviewers,jari
Client storages can be currently reset by using the optional argument of
nsIQuotaManagerService::ResetStoragesForPrincipal. However, supporting
resetting storages for both a principal and a client is not ideal for several
reasons. Resetting of origins will have to unset some flags which is
problematic when a client type is specified and resetting of clients will
eventually need to unset some other flags as well.

Differential Revision: https://phabricator.services.mozilla.com/D195508
2024-10-09 11:59:34 +00:00
Jan Varga
0ef753e75b Bug 1866402 - Rework QuotaManagerService::ResetStoragesForPrincipal to use an async message with an async response; r=dom-storage-reviewers,jari
A sub actor is no longer created. Actual result is now returned as
an asynchronous response to an asynchronous message.

Differential Revision: https://phabricator.services.mozilla.com/D195507
2024-10-09 11:59:34 +00:00
Jan Varga
2162985d40 Bug 1866402 - Change nsIQuotaManagerService::ClearStoragesForPrincipal to support clearing of entire origins only; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D195505
2024-10-09 05:34:37 +00:00
Jan Varga
41bde09445 Bug 1866402 - Add a dedicated method for clearing storages of a specific client; r=dom-storage-reviewers,jari
Client storages can be currently cleared by using the optional argument of
nsIQuotaManagerService::ClearStoragesForPrincipal. However, supporting clearing
storages for both a principal and a client is not ideal for several reasons.
Clearing of origins will have to unset some flags which is problematic when
a client type is specified and clearing of clients will eventually need to
unset some other flags as well.

Differential Revision: https://phabricator.services.mozilla.com/D195403
2024-10-09 05:34:36 +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