Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / quota / QuotaUsageRequestBase.h
blob524c80193ba613eab7550e7afb3bc039fcc5ff80
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_QUOTA_QUOTAUSAGEREQUESTBASE_H_
8 #define DOM_QUOTA_QUOTAUSAGEREQUESTBASE_H_
10 #include "NormalOriginOperationBase.h"
11 #include "mozilla/dom/quota/PersistenceType.h"
12 #include "mozilla/dom/quota/PQuotaUsageRequestParent.h"
14 class nsIFile;
16 namespace mozilla {
18 template <typename V, typename E>
19 class Result;
21 namespace dom::quota {
23 struct OriginMetadata;
24 class UsageInfo;
25 class UsageRequestResponse;
27 class QuotaUsageRequestBase : public NormalOriginOperationBase,
28 public PQuotaUsageRequestParent {
29 protected:
30 QuotaUsageRequestBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
31 const char* aName)
32 : NormalOriginOperationBase(std::move(aQuotaManager), aName) {}
34 mozilla::Result<UsageInfo, nsresult> GetUsageForOrigin(
35 QuotaManager& aQuotaManager, PersistenceType aPersistenceType,
36 const OriginMetadata& aOriginMetadata);
38 // Subclasses use this override to set the IPDL response value.
39 virtual void GetResponse(UsageRequestResponse& aResponse) = 0;
41 private:
42 mozilla::Result<UsageInfo, nsresult> GetUsageForOriginEntries(
43 QuotaManager& aQuotaManager, PersistenceType aPersistenceType,
44 const OriginMetadata& aOriginMetadata, nsIFile& aDirectory,
45 bool aInitialized);
47 void SendResults() override;
49 // IPDL methods.
50 void ActorDestroy(ActorDestroyReason aWhy) override;
52 mozilla::ipc::IPCResult RecvCancel() final;
55 } // namespace dom::quota
56 } // namespace mozilla
58 #endif // DOM_QUOTA_QUOTAUSAGEREQUESTBASE_H_