Bug 1922525 fixed the main issue related to shutdown requested during
CreateFileSystemManagerParent, so we don't crash anymore. However, correctness
and extra safety (that the manager doesn't start closing during
CreateFileSystemManagerParent), it would be better to capture a handle for all
async steps which need to access the manager.
Differential Revision: https://phabricator.services.mozilla.com/D225019
This requires a small change to the filesystem code, as the
FileSystemManager::BeginRequest signature explicitly uses the type
outside of IPC code.
We never need to copy the request object, so using std::function applies
unnecessary restrictions.
Differential Revision: https://phabricator.services.mozilla.com/D228098
MOZ_RUNINIT => initialized at runtime
MOZ_CONSTINIT => initialized at compile time
MOZ_GLOBINIT => initialized either at runtime or compile time, depending on template parameter, macro parameter etc
This annotation is only understood by our clang-tidy plugin. It has no
effect on regular compilation.
Differential Revision: https://phabricator.services.mozilla.com/D223341
The warnings are:
no edition set: defaulting to the 2015 edition while the latest is 2021
unused manifest key: lib.plugin
Differential Revision: https://phabricator.services.mozilla.com/D226855
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
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
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
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
This removes some code duplication, but the primary motivation is to use it for
a member variable declaration in QuotaManager.h
Differential Revision: https://phabricator.services.mozilla.com/D195532
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
getDirectory currently fails with unknown error because the actor refuses to
send the GetRootHandle message. For accuracy, it would be better to explicitly
error out FileSystemBackgroundRequestHandler::CreateFileSystemManagerChild if
the actor already received the CloseAll message.
Differential Revision: https://phabricator.services.mozilla.com/D221711
It can happen that FileSystemDataManager::AbortOperationsForLocks is called
during asynchronous CreateFileSystemManagerParent operation when the actor is
not yet registered. FileSystemDataManager::RequestAllowToClose is not able
to propagate the notification to the actor in that case. This patch fixes the
problem by checking directory lock and propagating the notification right after
a new actor has been registered.
Differential Revision: https://phabricator.services.mozilla.com/D220928
FileSystemManagerChild::CloseAllWritables is sometimes called from
FileSystemManager::Shutdown which can be called late in application shutdown
when GetCurrentSerialEventTarget returns null. At that point there are no
writable file streams and the problem with GetCurrentSerialEventTarget
returning null can be solved by calling the callback directly without
dispatching a new runnable.
Differential Revision: https://phabricator.services.mozilla.com/D221614
mBackgroundRequestHandler->FileSystemManagerChildStrongRef() is currently
expected to return a non-null value when FileSystemManager::BeginRequest gets a
success for mBackgroundRequestHandler->CreateFileSystemManagerChild. It turns
out that's not always true because the child actor can get destroyed in the
mean time (FileSystemBackgroundRequestHandler::ClearActor is called). It would
be safer if FileSystemBackgroundRequestHandler::CreateFileSystemManagerChild
returned a strong reference to the created object.
Differential Revision: https://phabricator.services.mozilla.com/D220992
There's now a dedicated nsIQuotaManagerService::GetCachedUsageForPrincipal
method for getting cached origin usage. All callers of
nsIQuotaManagerService::GetUsageForPrincipal which want to get cached origin
usage for given principal can be now converted to call the new method.
Differential Revision: https://phabricator.services.mozilla.com/D195363
InitOrigin is supposed to be called when temporary storage is not initialized
or is being initialized. On the other hand, GetUsageForOrigin is supposed to be
called only when temporary storage is already initialized.
Differential Revision: https://phabricator.services.mozilla.com/D194542
The TestFileSystemQuotaClient test suite has been replacted with
TestFileSystemUsageTracking and TestFileSystemOriginInitialization test suites.
Differential Revision: https://phabricator.services.mozilla.com/D194540
The new test suite is intended for integration tests which verify origin
initialization. The suite is partially based on the existing
TestFileSystemQuotaClient suite.
TestFileSystemQuotaClient.cpp will get removed in a separate patch.
Differential Revision: https://phabricator.services.mozilla.com/D166175
FileSystemQuotaClient::InitOrigin shouldn't be called when temporary storage is
already initialized. It shouldn't be called when there's already active storage
connection for the OPFS database either.
Differential Revision: https://phabricator.services.mozilla.com/D194467
The new test suite is intended for integration tests which verify usage
tracking without any restart in between. The suite is based on the existing
TestFileSystemQuotaClient suite except the test which in theory request a
restart in between: TrackedFilesOnInitOriginShouldCauseRescan.
TestFileSystemQuotaClient.cpp will get removed after some additional
refactoring.
Differential Revision: https://phabricator.services.mozilla.com/D194465