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 mozilla_dom_quota_ActorsChild_h
8 #define mozilla_dom_quota_ActorsChild_h
11 #include "ErrorList.h"
12 #include "mozilla/RefPtr.h"
13 #include "mozilla/dom/quota/PQuotaChild.h"
14 #include "mozilla/dom/quota/PQuotaRequestChild.h"
15 #include "mozilla/dom/quota/PQuotaUsageRequestChild.h"
16 #include "mozilla/ipc/ProtocolUtils.h"
18 #include "nsStringFwd.h"
26 class BackgroundChildImpl
;
30 namespace dom::quota
{
32 class QuotaManagerService
;
36 class QuotaChild final
: public PQuotaChild
{
37 friend class mozilla::ipc::BackgroundChildImpl
;
38 friend class QuotaManagerService
;
40 QuotaManagerService
* mService
;
43 nsCOMPtr
<nsIEventTarget
> mOwningThread
;
47 void AssertIsOnOwningThread() const
56 // Only created by QuotaManagerService.
57 explicit QuotaChild(QuotaManagerService
* aService
);
59 // Only destroyed by mozilla::ipc::BackgroundChildImpl.
62 // IPDL methods are only called by IPDL.
63 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
65 virtual PQuotaUsageRequestChild
* AllocPQuotaUsageRequestChild(
66 const UsageRequestParams
& aParams
) override
;
68 virtual bool DeallocPQuotaUsageRequestChild(
69 PQuotaUsageRequestChild
* aActor
) override
;
71 virtual PQuotaRequestChild
* AllocPQuotaRequestChild(
72 const RequestParams
& aParams
) override
;
74 virtual bool DeallocPQuotaRequestChild(PQuotaRequestChild
* aActor
) override
;
77 class QuotaUsageRequestChild final
: public PQuotaUsageRequestChild
{
78 friend class QuotaChild
;
79 friend class QuotaManagerService
;
81 RefPtr
<UsageRequest
> mRequest
;
84 void AssertIsOnOwningThread() const
93 // Only created by QuotaManagerService.
94 explicit QuotaUsageRequestChild(UsageRequest
* aRequest
);
96 // Only destroyed by QuotaChild.
97 ~QuotaUsageRequestChild();
99 void HandleResponse(nsresult aResponse
);
101 void HandleResponse(const nsTArray
<OriginUsage
>& aResponse
);
103 void HandleResponse(const OriginUsageResponse
& aResponse
);
105 // IPDL methods are only called by IPDL.
106 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
108 virtual mozilla::ipc::IPCResult
Recv__delete__(
109 const UsageRequestResponse
& aResponse
) override
;
112 class QuotaRequestChild final
: public PQuotaRequestChild
{
113 friend class QuotaChild
;
114 friend class QuotaManagerService
;
116 RefPtr
<Request
> mRequest
;
119 void AssertIsOnOwningThread() const
128 // Only created by QuotaManagerService.
129 explicit QuotaRequestChild(Request
* aRequest
);
131 // Only destroyed by QuotaChild.
132 ~QuotaRequestChild();
134 void HandleResponse(nsresult aResponse
);
136 void HandleResponse();
138 void HandleResponse(bool aResponse
);
140 void HandleResponse(const nsAString
& aResponse
);
142 void HandleResponse(const EstimateResponse
& aResponse
);
144 void HandleResponse(const nsTArray
<nsCString
>& aResponse
);
146 void HandleResponse(const GetFullOriginMetadataResponse
& aResponse
);
148 // IPDL methods are only called by IPDL.
149 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
151 virtual mozilla::ipc::IPCResult
Recv__delete__(
152 const RequestResponse
& aResponse
) override
;
155 } // namespace dom::quota
156 } // namespace mozilla
158 #endif // mozilla_dom_quota_ActorsChild_h