Commit Graph

51 Commits

Author SHA1 Message Date
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
Jan Varga
3241d28ef0 Bug 1733107 - Avoid repository traversals during clearing of exact origins; r=dom-storage-reviewers,asuth
ClearRequestBase::DeleteFiles currently provides a way to clear origins for any
combination of persistence type, origin scope and client type. All origin
directories need to be traversed to find relevant matches. This can be slow if
there are many origin directories. Fortunately, the traversal can be completely
avoided when exact origin is being cleared.

Changes done in this patch:
- added a dedicated ClearRequestBase::DeleteFiles method for clearing of exact
  origins
- changed ClearOriginOp::DoDirectoryWork to use the new variant of
  ClearRequestBase::DeleteFiles

Differential Revision: https://phabricator.services.mozilla.com/D186781
2023-09-25 16:28:40 +00:00
Jan Varga
e425784e4a Bug 1733107 - Add QuotaManager::RemoveOriginDirectory; r=dom-storage-reviewers,asuth
The removing of an origin directory became a bit more complex because when the
app shutdown already started, origin directories shouldn't be fully removed
from disk. They need to be only moved to a special directory. All this
complexity should be covered by a dedicated QuotaManager method.

Changes done in this patch:
- added a new method QuotaManager::RemoveOriginDirectory
- added a prefilled string for the special to-be-removed directory
- adjusted ClearRequestBase::DeleteFiles to use the new
  QuotaManager::RemoveOriginDirectory method

Differential Revision: https://phabricator.services.mozilla.com/D186780
2023-09-25 16:28:39 +00:00
Jan Varga
74eb2aa223 Bug 1733107 - Change nsIQuotaManagerService::ClearStoragesForPrincipal to support clearing of exact origins only; r=dom-storage-reviewers,asuth
There are now no callers of nsIQuotaManagerService::ClearStoragesForPrincipal
which would request clearing of all storages for given prefix. The support for
that can be removed.

Changed done in this patch:
- removed the aClearAll argument from
  nsIQuotaManagerService::ClearStoragesForPrincipal
- removed the aClearAll argument from the async IPC message
- removed the aClearAll argument from QuotaManager::ClearStoragesForOrigin
- changed ClearOriginOp to support clearing of exact origins only

Differential Revision: https://phabricator.services.mozilla.com/D186779
2023-09-25 16:28:39 +00:00
Jan Varga
e698ab0991 Bug 1733107 - Add nsIQuotaManagerService::ClearStoragesForOriginPrefix; r=dom-storage-reviewers,asuth,jstutte
nsIQuotaManagerService::ClearStoragesForPrincipal currently supports both
clearing storages for a specific origin only and clearing storages for a group
of origins sharing the same prefix. It would be better to have separate methods
for this.

Changes done in this patch:
- added nsIQuotaManagerService::ClearStoragesForOriginPrefix
- added a new helper for testing clearOriginsByPrefix
- changed verifyStorage to accept an optional shared key name
- added thorough testing for the new method

Differential Revision: https://phabricator.services.mozilla.com/D186777
2023-09-25 16:28:38 +00:00
Jan Varga
49bb3fc77a Bug 1733107 - Rework remaining QuotaManagerService clearing methods to use asynchronous messages instead of creating sub actors; r=dom-storage-reviewers,jstutte
QuotaManagerService::ClearStoragesForOriginAttributesPattern and
QuotaManagerService::ClearStoragesForPrincipal still create sub actors which
makes it hard to add new clearing operations which would use async IPC messages
and which would inherit from the ClearRequestBase class as well.

Changes done in this patch:
- added QuotaManager::ClearStoragesForOrigin
- added QuotaManager::ClearStoragesForOriginAttributesPattern
- changed ClearRequestBase to inherit from ResolvableNormalOriginOp
- QuotaManagerService::ClearStoragesForOriginAttributesPattern reworked to use
  an asynchronous message instead of a sub actor
- QuotaManagerService::ClearStoragesForPrincipal reworked to use an
  asynchronous message instead of a sub actor
- added a new mactor QM_CUF_AND_IPC_FAIL similar to QM_IPC_FAIL

creating a sub actor

Differential Revision: https://phabricator.services.mozilla.com/D186628
2023-09-25 16:28:38 +00:00
Jan Varga
7b7073b84d Bug 1733107 - Move directory locking to derived classes of ClearRequestBase; r=dom-storage-reviewers,jstutte
ClearRequestBase currently provides generic directory locking based on generic
member variables. It's not totally clear what derived classes do in terms of
directory locking and work on the QuotaManager IO thread. It would be better if
ClearRequestBase only provided a generic DeleteFiles function instead.

Changed done in this patch:
- moved implementation of directory locking methods to derived classes of
  ClearRequestBase
- moved implementation of DoDirectoryWork to derived classes as well
- adjusted member variables

Differential Revision: https://phabricator.services.mozilla.com/D186627
2023-09-25 16:28:37 +00:00
Jan Varga
4ccab5cfcb Bug 1749504 - Convert origin operations which require storage initialization to use the new way to access the storage directory; r=dom-storage-reviewers,jstutte
Origin operations which require storage initialization currently create a
universal directory lock first and then when the universal directorylock is
acquired, they bounce to the QuotaManager I/O thread where they ensure that
storage is initialized. This can be now replaced by just calling
QuotaManager::OpenStorageDirectory.

Changes done in this patch:
- replaced QuotaManager::CreateDirectoryLockInternal call with
  QuotaManager::OpenStorageDirectory in corresponding OpenDirectory
  implementations
- removed QuotaManager::EnsureStorageIsInitializedInternal call from
  corresponding DoDirectoryWork implementations
- added QuotaManager::AssertStorageIsInitializedInternal to corresponding
  DoDirectoryWork implementations

Differential Revision: https://phabricator.services.mozilla.com/D186206
2023-09-20 10:37:44 +00:00
Jan Varga
25717c703a Bug 1749504 - Make sure storage is initialized before saving origin access time; r=dom-storage-reviewers,jstutte
SaveOriginAccessTimeOp::DoDirectoryWork currently doesn't call
QuotaManager::EnsureStorageIsInitializedInternal and just expects that
something else initialized storage previously. This seems to work, but it would
be cleaner to always make sure that storage is initialized. However, adding
QuotaManager::EnsureStorageIsInitializedInternal revealed another problem.
Storage shudown or storage clearing acquires an exlusive lock over entire
storage area which essentially forces that all existing directory locks are
released first. When the last directory lock for an origin is released, saving
of origin access time is scheduled. The problem is that it's scheduled after
the exclusive lock for storage shutdown or storage clearing, so storage would
be initialized again in the end or access time wouldn't be saved at all due
to quota manager shutdown being already in progress.

Changes done in this patch:
- added QuotaManager::EnsureStorageIsInitializedInternal call to
  SaveOriginAccessTimeOp::DoDirectoryWork
- changed QuotaManager::UnregisterDirectoryLock to work with already cleared
  directory lock tables
- added a new QuotaManager::ClearDirectoryLockTables method
- added QuotaManager::ClearDirectoryLockTables call to
  ShutdownStorageOp::OpenDirectory and ClearStorageOp::OpenDirectory
- made ClearStorageOp and ShutdownStorageOp friend classes of QuotaManager

Differential Revision: https://phabricator.services.mozilla.com/D187877
2023-09-20 10:37:44 +00:00
Jan Varga
c62de590af Bug 1749504 - Add directory locking to origin operations which require storage initialization; r=dom-storage-reviewers,jstutte
Some origin operations are currently not protected by directory locks because
they use cached data for generating responses. However these origin operations
ensure that storage is initializated on QuotaManager IO thread prior using the
cache data, so they should have directory directory locks as well.

Changed done in this patch:
- added directory locks to origin operations which require storage
  initialization
- changed corresponding OpenDirectory implementations
- added corresponding CloseDirectory implementations

Differential Revision: https://phabricator.services.mozilla.com/D186205
2023-09-18 03:50:01 +00:00
Jan Varga
78d2e22c50 Bug 1749504 - Make sure storage is initialized before clearing storage; r=dom-storage-reviewers,jstutte
LoadArchivedOrigins (called from QuotaClient::AboutToClearOrigins) currently
ensures that storage is initialized which eventually creates the archive from
webappsstore.sqlite. Conceptually, storage should be always initialized before
QuotaClient::AboutToClearOrigins is called.

Changes done in this patch:
- removed QuotaManager::EnsureStorageIsInitializedInternal call from
  LoadArchivedOrigins
- added QuotaManger::EnsureStorageIsInitializedInternal call to
  ClearStorageOp::DoDirectoryWork

Differential Revision: https://phabricator.services.mozilla.com/D186115
2023-09-14 04:04:29 +00:00
Jan Varga
c20121f65f Bug 1749504 - Fix a QuotaManager::OpenClientDirectory flaw; r=dom-storage-reviewers,jstutte
Now when origin operations have been refactored to do directory locking on
their own, it's possibly to pass an already acquired directory lock to the
InitOp object. This is required to fix a flaw in the implementation of
QuotaManager::OpenClientDirectory. Basically a directory lock for the InitOp
and a client directory lock both need to be acquired at the same time to
maintain correct ordering of operations.

Changes done in this patch:
- added a new overload for QuotaManager::InitializeStorage which takes a
  directory lock
- changed InitOp to work with an already acquired directory lock
- enabled a disabled test for QuotaManager::OpenClientDirectory
- added more tests for QuotaManager::OpenClientDirectory

Differential Revision: https://phabricator.services.mozilla.com/D186080
2023-09-13 16:41:59 +00:00
Jan Varga
d1fbaa17fb Bug 1749504 - Allow to do more complex directory opening in derived classes of NormalOriginOperationsBase; r=dom-storage-reviewers,jstutte
Some operations will need to do more complex directory opening involving for
example acquiring multiple directory locks. For this reason it's no longer
desired to hold a directory lock in the NormalOriginOperationBase class.

Changed done in this patch:
- changed NormalOriginOperationsBase::CreateDirectoryLock too return a
  MozPromise
- renamed NormalOriginOperationsBase::CreatedDirectoryLock to OpenDirectory
- added a new pure virtual method NormalOriginOperationBase::CloseDirectory
- removed mDirectoryLock member from NormalOriginOperationBase
- adjusted derived classes of NormalOriginOperationsBase

Differential Revision: https://phabricator.services.mozilla.com/D186079
2023-09-13 16:41:58 +00:00
Jan Varga
be082dd42c Bug 1749504 - Remove NormalOriginOperationBase members related to directory locking; r=dom-storage-reviewers,jstutte
Now when NormalOriginOperationBase lets the derived classes to create directory
locks, it is no longer needed to keep members related to directory locking in
the NormalOriginOperationBase class.

Changes done in this patch:
- optimized members of derived classes
- adjusted CreateDirectoryLock implementations
- removed members related to directory locking from NormalOriginOperationBase
- adjusted constructors of derived classes

Differential Revision: https://phabricator.services.mozilla.com/D185647
2023-09-13 16:41:58 +00:00
Jan Varga
9be3c623df Bug 1749504 - Change NormalOriginOperationBase::CreateDirectoryLock to be a pure virtual method; r=dom-storage-reviewers,jstutte
Directory locks are currently created either by NormalOriginOperationBase
based on the parameters passed to its constructor or derived classes override
the CreateDirectoryLock method. Some operations will need to acquire multiple
locks in future and eventually do some other stuff before they can start doing
IO work, so it would be better to remove the default implementation of
CreateDirectoryLock in advance and let the derived classes to always implement
the method.

Changes done in this patch:
- copied the default implementation of CreateDirectoryLock to each origin
operation
- changed NormalOriginOperationBase::CreateDirectoryLock to be a pure virtual
method
- removed the default implementation of CreateDirectoryLock
- added some missing AssertIsOnOwningThread calls

Differential Revision: https://phabricator.services.mozilla.com/D185646
2023-09-13 16:41:57 +00:00
Jan Varga
899a168066 Bug 1749504 - Add not null strong reference to QuotaManager from OriginOperatiosBase; r=dom-storage-reviewers,jstutte
OriginOperationBase and the derived classes currently must get QuotaManager by
calling QuotaManager::Get() and usually asserting that the returned value is
not null. Now when OriginOperationBase is created and destroyed only on the
PBackground thread, a new not null strong reference to QuotaManager can be
added to OriginOperationBase which will eliminate the need for calling
QuotaManager::Get. Calling QuotaManager::Get less is desired because such a
call can get more expensive in future.

Changes done in this patch:
- added not null strong reference to QuotaManager from OriginOperationBase
- adjusted constructors of derived classes
- adjusted factories for origin operations
- started using the new member in some places (instead of calling QuotaManager::Get)
- removed some now unnecessary QuotaManager::Get calls

Differential Revision: https://phabricator.services.mozilla.com/D185645
2023-09-13 16:41:57 +00:00
Jan Varga
28a813ff73 Bug 1749504 - Change OriginOperationBase to use a MozPromise chain; r=dom-storage-reviewers,jstutte
OriginOperationBase currently uses manual dispatching of runnables controlled
by a state machine which is not that easy to understand and requires many
helper methods. Additionally, OriginOperationBase can be destroyed off the
PBackground thread which makes it hard to hold PBackground only objects.

Changes done in this patch:
- changed OriginOperationBase to not inherit from Runnable
- changed OriginOperationBase to be created and destroyed on the PBackground thread only
- replaced the manual dispatching of runnables with a MozPromise chain
- removed OriginOperationBase::Dispatch
- changed pure virtual method OriginOperationBase::Open to return a MozPromise
- changed FinalizeOriginEvictionOp to be always created on the PBackground
  thread only (as a consequence of similar changes done to OriginOperationBase)

Differential Revision: https://phabricator.services.mozilla.com/D185641
2023-09-13 16:41:57 +00:00
Jan Varga
4d5ca1ffb5 Bug 1749504 - Add QuotaManager::InitializeStorage method; r=dom-storage-reviewers,jstutte
There's currently EnsureStorageIsInitializedInternal 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 storage
initialization is started.

Changes done in this patch:
- added QuotaManager::InitializeStorage method
- added QuotaManager::IsStorageInitialized method
- QuotaManagerService::Init reworked to use an asynchronous message instead of
  creating a sub actor
- added QuotaManagerDependencyFixture::IsStorageInitialized
- added QuotaManagerDependencyFixture::AssertStorageIsInitialized
- added QuotaManagerDependencyFixture::AssertStorageIsNotInitialized
- eliminated QuotaManager::IsStorageInitializedInternal calls in tests
- eliminated QuotaManager::EnsureStorageIsInitializedInternal calls in tests
- added a bunch of tests for the new QuotaManager::InitializeStorage method

Differential Revision: https://phabricator.services.mozilla.com/D185570
2023-09-13 16:41:56 +00:00
Jan Varga
6555388d94 Bug 1749504 - Rename EnsureStorageIsInitialized to EnsureStorageIsInitializedInternal; r=dom-storage-reviewers,jstutte
One of the goals of bug 1749504 is to call EnsureStorageIsInitialized only from
InitOp. 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.

Changes done in this patch:
- IsStorageInitialized renamed to IsStorageInitializedInternal
- AssertStorageIsInitialized renamed to AssertStorageIsInitializedInternal
- EnsureStorageIsInitialized renamed to EnsureStorageIsInitializedInternal

Differential Revision: https://phabricator.services.mozilla.com/D185547
2023-09-12 12:40:41 +00:00
Jan Varga
3e3372c1f4 Bug 1749504 - Add QuotaManager::ClearStorage method; r=dom-storage-reviewers,jstutte
There's currently no QuotaManager method for triggering storage clearing which
could be used by the ClearOp or directly in gtests. Asynchronous storage
initialization will introduce a flag which needs to be unset after storage
clearing or storage resetting. This can't be easilly done without a
QuotaManager method for storage clearing.

Changes done in this patch:
- added QuotaManager::ClearStorage method
- renamed ClearOp to ClearStorageOp
- QuotaManagerService::Clear reworked to use an asynchronous message instead of
  creating a sub actor

Differential Revision: https://phabricator.services.mozilla.com/D185546
2023-09-12 12:40:40 +00:00
Jan Varga
fac8a7fe9f Bug 1749504 - Separate the reset functionality out of ResetOrClearOp; r=dom-storage-reviewers,jstutte
The ResetOrClearOp currently supports both the resetting and clearing of
storage. However, there's already an operation for resetting storage called
ShutdownStorageOp which can be used separately.

Changes done in this patch:
- ResetOrClearOp renamed to ClearOp
- ClearOp converted to support only storage clearing
- QuotaManagerService::Reset reworked to use an asynchronous message instead of
creating a sub actor
- added generic helpers/callbacks for handling returned MozPromises

Differential Revision: https://phabricator.services.mozilla.com/D185545
2023-09-12 12:40:40 +00:00
Jan Varga
b9d97782b4 Bug 1842350 - Remove OriginOperationBase::mNeedsStorageInit; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D183072
2023-07-14 09:51:15 +00:00
Jan Varga
1a7036b4c8 Bug 1840772 - Merge ClearPrivateRepositoryOp and ClearPrivateBrowsingOp; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D182332
2023-07-14 09:51:15 +00:00
Jan Varga
4c954fad69 Bug 1840545 - Rename ResolvableOriginOp to ResolvableNormalOriginOp; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D182187
2023-07-13 09:57:18 +00:00