Open Bug 1866402 Opened 8 months ago Updated 6 months ago

Cover origin initialization in OpenStorageDirectory and OpenClientDirectory

Categories

(Core :: Storage: Quota Manager, task, P1)

task

Tracking

()

ASSIGNED

People

(Reporter: janv, Assigned: janv)

References

(Depends on 1 open bug, Blocks 2 open bugs)

Details

Attachments

(26 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Quota clients and origin operations currently still have to call EnsurePersistentOriginIsInitializedInternal or EnsureTemporaryOriginIsInitializedInternal method on the QM IO thread. This should be covered by OpenStorageDirectory and OpenClientDirectory instead.

Blocks: 1867997

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.

Depends on D195400

There's now a dedicated nsIQuotaManagerService::ClearStoragesForClient method
for clearing storages by client type. All callers of
nsIQuotaManagerService::ClearStoragesForPrincipal which want to clear storages
for a specific client only can be now converted to call the new method.

Depends on D195403

A sub actor is no longer created. Actual result is now returned as
an asynchronous response to an asynchronous message.

Depends on D195505

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.

Depends on D195507

There's now a dedicated nsIQuotaManagerService::ResetStoragesForClient method
for resetting storages by client type. All callers of
nsIQuotaManagerService::ResetStoragesForPrincipal which want to reset storages
for a specific client only can be now converted to call the new method.

Depends on D195508

This is a preparation for unsetting some flags when origins are either cleared
or reset.

Depends on D195510

This additional testing infrastructure is needed for verifying origin
initialization status.

Depends on D195522

This removes some code duplication, but the primary motivation is to use it for
a member variable declaration in QuotaManager.h

Depends on D195526

Origin initialization tracking on the owning thread is needed for covering
origin initialization in QuotaManager::OpenClientDirectory.

Depends on D195532

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.

Depends on D195535

It's now possible to check if an origin is already initialized on the owning
thread and it's also possible to evaluate existing directory locks if there are
any uninit origin operations pending. So we can add optimizations to origin
initialization methods to resolve promises immediately if origins are already
initialized and there are no pending uninit storage or uninit origin operations.

Depends on D195543

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.

Depends on D195548

QuotaManager::OpenClientDirectory can now get initialization status of
corresponding origin and initialize the origin if it's needed.

Depends on D195570

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::GetOrCreateOriginDirectory instead of
QuotaManager::Ensure(Persistent|Temporary)OriginIsInitializedInternal.

Depends on D195582

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.

Depends on D195589

QuotaManager::OpenStorageDirectory can now detect the requested persistence
scope and initialize persistent storage if it's needed.

Depends on D195653

QuotaManager::OpenStorageDirectory already makes sure that persistent storage
is initialized so this call is now redundant.

Depends on D195661

QuotaManager::Ensure(Persistent|Temporary)OriginIsInitializedInternal are now
called only from Initialize(Persistent|Temporary)OriginOp. It's now easy to
change the methods to be private methods.

Depends on D195665

The getter IsExtensionOrigin doesn't require the lock to be held, so the member
must be const.

Depends on D195548

Attachment #9367143 - Attachment description: Bug 1866402 - Replace most of QuotaManager::Ensure(Persistent|Temporary)OriginIsInitializedInternal calls with QuotaManager::GetOrCreateOriginDirectory; r=#dom-storage → Bug 1866402 - Replace most of QuotaManager::EnsurePersistentOriginIsInitializedInternal and QuotaManager::EnsureTemporaryOriginIsInitializedInternal calls; r=#dom-storage

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).

Depends on D196657

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.

Depends on D198664

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.

Depends on D198668

You need to log in before you can comment on or make changes to this bug.