Commit Graph

74 Commits

Author SHA1 Message Date
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
Jan Varga
a0adce1a7d Bug 1920456 - QM: Use helpers for dropping directory locks; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D223108
2024-10-04 16:57:02 +00:00
Jan Varga
79f4bd0fbf Bug 1866217 - Scope temporary storage initialization to temporary and default repository only; r=dom-storage-reviewers,jari
Temporary storage initialization currently uses a directory lock over all
repositories which blocks any exclusive directory locks for the persistent
repository for no reason.

Differential Revision: https://phabricator.services.mozilla.com/D195389
2024-08-15 05:23:44 +00:00
Jan Varga
6c1c77590e Bug 1866217 - Add support for persistence type sets to PersistenceScope; r=dom-storage-reviewers,jari
Temporary storage initialization can finally lock only specific repositories
instead of locking all repositories (actual temporary storage initialization
locking chagnes will be done in a separate patch).

Differential Revision: https://phabricator.services.mozilla.com/D195374
2024-08-14 20:17:31 +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
86c2984718 Bug 1866217 - Change nsIQuotaManagerService::GetUsageForPrincipal to support getting origin usage only by inspecting disk; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D195365
2024-08-13 10:40:08 +00:00
Jan Varga
9c64c62ec8 Bug 1866217 - Add a dedicated method for getting cached origin usage; r=dom-storage-reviewers,jari
Cached origin usage can be currently obtained by passing fromMemory=true to
nsIQuotaManagerService::GetUsageForPrincipal. However, supporting both ways of
getting origin on one operation is not ideal for sevaral reasons. The return
value is a plain integer in the case of cached origin usage and getting cached
origin usage in theory doesn't have to go the QM IO thread. So it would be
better to have a dedicated method for that called
nsIQuotaManagerService::GetCachedUsageForPrincipal.

Differential Revision: https://phabricator.services.mozilla.com/D195360
2024-08-12 16:36:38 +00:00
Jan Varga
aacad88741 Bug 1912272 - Gettting cached origin usage shouldn't trigger temporary storage initialization; r=hsingh
Currently, getting cached origin usage may trigger temporary storage
initialization which is a problem in tests when we want just compare real and
cached usage without affecting the state of initialization.

This patch changes the behavior to return Nothing if temporary storage is not
initialized.

Consumers may either explicitly make sure that temporary storage is initialized
before getting cached origin usage or they can use the other mode when real
usage is colleced from disk.

Differential Revision: https://phabricator.services.mozilla.com/D194504
2024-08-09 14:39:04 +00:00
Jan Varga
de73e243ed Bug 1910848 - Rework QuotaManagerService methods for getting usage to use async messages with async responses; r=dom-storage-reviewers,jari
Sub actors are still created, but their only purpose is to allow cancellation
of alreaady created requests. Actual results are now returned as asynchronous
responses to the asynchronous messages.

Differential Revision: https://phabricator.services.mozilla.com/D194097
2024-08-07 07:53:16 +00:00
Jan Varga
74fab2a848 Bug 1910848 - Replace custom OriginUsage with a common OriginUsageMetadata struct; r=dom-storage-reviewers,jari
This is a prerequisite to make GetUsageOp independent from the actor.

Differential Revision: https://phabricator.services.mozilla.com/D194053
2024-08-07 07:53:13 +00:00
Jan Varga
10e3dee746 Bug 1910848 - Make PQuotaUsageRequest protocol refcounted; r=dom-storage-reviewers,jari
The class which implements the protocol is already refcounted, but the
interaction with IPC still uses manual deallocation.

Differential Revision: https://phabricator.services.mozilla.com/D194042
2024-08-07 07:53:12 +00:00
Jan Varga
870961a2fd Bug 1910848 - Pull out OriginOperationBase::mActorDestroyed to actor classes; r=dom-storage-reviewers,jari
OriginOperationBase is finally fully abstract.

Differential Revision: https://phabricator.services.mozilla.com/D194037
2024-08-07 07:53:12 +00:00
Jan Varga
7d17aea57f Bug 1910848 - Encapsulate NormalOriginOperationBase::mCanceled; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D194036
2024-08-07 07:53:11 +00:00
Jan Varga
6f8551406b Bug 1910848 - Pull out GetUsageForOrigin and GetUsageForOriginEntries methods from QuotaUsageRequestBase into a new base class; r=dom-storage-reviewers,jari
This is one of the things which are needed for making GetUsageOp and
GetOriginUsageOp independent from the actor. In practise, for changing the main
base class of the operations from QuotaUsageRequestBase to
ResolvableNormalOriginOp.

Differential Revision: https://phabricator.services.mozilla.com/D194011
2024-08-07 07:53:10 +00:00
Jan Varga
3a9b32ed6c Bug 1910848 - Pull out TraverseRepositoryHelper::GetIsCanceledFlag method into a new base class; r=dom-storage-reviewers,jari
Multiple helper classes will need to call this method.

Differential Revision: https://phabricator.services.mozilla.com/D194010
2024-08-07 07:53:10 +00:00
Jan Varga
c712045cf2 Bug 1906041 - Add QuotaManager::Initialize(Persistent|Temporary)Origin methods; r=dom-storage-reviewers,jari
There are currently EnsurePersistentOriginIsInitializedInternal and
EnsureTemporaryOriginIsInitializedInternal methods which can only be
called on the QuotaManager IO thread. These methods shouldn't be exposed to
quota clients and origin operations. There should be public methods callable
from the PBackground thread returning a MozPromise instead. Such methods will
guarantee that proper directory locking is acquired before persistent origin
initialization or temporary origin initialization is started.

Differential Revision: https://phabricator.services.mozilla.com/D194005
2024-08-01 09:33:05 +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
07bd74474f Bug 1905011 - Replace counting of pending clear/shutdown storage operations with evaluation of existing directory locks; r=dom-storage-reviewers,jari
Counting of clear/shutdown storage operations was only a temporary solution.
We are now approaching a point when we will be able to initialize origins
asynchronously and that can't efficiently work with counting of clear origin
operations because initialization and clearing of origins is parameterized by
persistence type and actual origin. So there can be a clear origin operation
which doesn't block other init origin operation. Couting of clear operations
would be problematic in that case.
Evaluation of existing directory locks should work both for storage and origin
initialization.

Differential Revision: https://phabricator.services.mozilla.com/D193191
2024-07-02 21:40:24 +00:00
Jan Varga
b4890162d2 Bug 1903985 - Add some information about pending ClearRequestBase operations to quota manager shutdown crash annotation; r=dom-storage-reviewers,jstutte
For now, we only report how many directory iterations have been done.

Differential Revision: https://phabricator.services.mozilla.com/D214521
2024-06-21 11:48:01 +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
Jan Varga
a6bbde2554 Bug 1808294 - Add QuotaManager::InitializeTemporaryStorage method; r=dom-storage-reviewers,jari
There's currently EnsureTemporaryStorageIsInitializedInternal which can only be
called on the QuotaManager IO thread. That method shouldn't be exposed to quota
clients and origin operations. There should be a public method callable from
the PBackground thread returning a MozPromise instead. Such method will
guarantee that proper directory locking is acquired before temporary storage
initialization is started.

Differential Revision: https://phabricator.services.mozilla.com/D192135
2023-12-08 05:55:05 +00:00
Jan Varga
c3f18dd105 Bug 1808294 - Rename EnsureTemporaryStorageIsInitialized to EnsureTemporaryStorageIsInitializedInternal; r=dom-storage-reviewers,asuth
One of the goals of the asynchronous temporary storage initialization is to
call EnsureTemporaryStorageIsInitialized only from InitTemporaryStorageOp.
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/D188332
2023-12-08 05:55:04 +00:00
Jan Varga
94ed43025b Bug 1808294 - Rework QuotaManagerService::StorageInitialized and QuotaManager::TemporaryStorageInitialized to use asynchronous messages instead of creating sub actors; r=dom-storage-reviewers,jari
This patch also adds QuotaManager::StorageInitialized and
QuotaManager::TemporaryStorageInitialized which can be then used by the
QuotaManagerDependencyFixture.

Differential Revision: https://phabricator.services.mozilla.com/D191930
2023-12-08 05:55:03 +00:00
Sylvestre Ledru
b0fe72dee5 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan
7388749830 Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru
4a97019e39 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Jan Varga
ac13c04d02 Bug 1808294 - Add a common way to create quota client directories; r=dom-storage-reviewers,jari
Depends on D166173

Differential Revision: https://phabricator.services.mozilla.com/D166174
2023-10-12 14:55:59 +00:00
Jan Varga
8fda754884 Bug 1858067 - Skip saving of origin access time during shutdown; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D190541
2023-10-10 08:49:53 +00:00
Jens Stutte
a2f32fc6b1 Bug 1857858 - Add a shutdown annotation to ShutdownStorageOp::DoDirectoryWork. r=dom-storage-reviewers,janv
Operations are shown as "pending" in the QM shutdown hang annotations until they are fully executed. Given that executing them often requires acquiring a directory lock first and also involves some thread hopping, we want to understand better, where we hang.

In particular many crashes show `ShutdownStorageOp` as pending but there is no sign in the stack trace that `DoDirectoryWork` ever started. In addition, most if not all of those crashes show either an open IDB connection or an unclosed  Cache manager, which might interfere with directory locking here.

The annotation should help to confirm that `ShutdownStorageOp` is endlessly waiting to acquire the directory lock in those cases.

Differential Revision: https://phabricator.services.mozilla.com/D190425
2023-10-09 09:34:31 +00:00
Jan Varga
1cbc966086 Bug 1808294 - Extend nsIQuotaOriginUsageResult to match UsageInfo; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D166173
2023-10-06 13:33:13 +00:00