gecko-dev/dom/quota/QuotaParent.h
Jan Varga 1ae113cb02 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

80 lines
2.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef DOM_QUOTA_QUOTAPARENT_H_
#define DOM_QUOTA_QUOTAPARENT_H_
#include "mozilla/dom/quota/PQuotaParent.h"
#include "nsISupportsImpl.h"
namespace mozilla::dom::quota {
class Quota final : public PQuotaParent {
#ifdef DEBUG
bool mActorDestroyed;
#endif
public:
Quota();
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::dom::quota::Quota)
private:
~Quota();
bool VerifyRequestParams(const UsageRequestParams& aParams) const;
bool VerifyRequestParams(const RequestParams& aParams) const;
// IPDL methods.
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual PQuotaUsageRequestParent* AllocPQuotaUsageRequestParent(
const UsageRequestParams& aParams) override;
virtual mozilla::ipc::IPCResult RecvPQuotaUsageRequestConstructor(
PQuotaUsageRequestParent* aActor,
const UsageRequestParams& aParams) override;
virtual bool DeallocPQuotaUsageRequestParent(
PQuotaUsageRequestParent* aActor) override;
virtual PQuotaRequestParent* AllocPQuotaRequestParent(
const RequestParams& aParams) override;
virtual mozilla::ipc::IPCResult RecvPQuotaRequestConstructor(
PQuotaRequestParent* aActor, const RequestParams& aParams) override;
virtual bool DeallocPQuotaRequestParent(PQuotaRequestParent* aActor) override;
virtual mozilla::ipc::IPCResult RecvInitializeStorage(
InitializeStorageResolver&& aResolver) override;
virtual mozilla::ipc::IPCResult RecvClearStoragesForPrivateBrowsing(
ClearStoragesForPrivateBrowsingResolver&& aResolver) override;
virtual mozilla::ipc::IPCResult RecvClearStorage(
ClearStorageResolver&& aResolver) override;
virtual mozilla::ipc::IPCResult RecvShutdownStorage(
ShutdownStorageResolver&& aResolver) override;
virtual mozilla::ipc::IPCResult RecvStartIdleMaintenance() override;
virtual mozilla::ipc::IPCResult RecvStopIdleMaintenance() override;
virtual mozilla::ipc::IPCResult RecvAbortOperationsForProcess(
const ContentParentId& aContentParentId) override;
};
PQuotaParent* AllocPQuotaParent();
bool DeallocPQuotaParent(PQuotaParent* aActor);
} // namespace mozilla::dom::quota
#endif // DOM_QUOTA_QUOTAPARENT_H_