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
;
33 class QuotaManagerService
;
37 class QuotaChild final
: public PQuotaChild
{
38 friend class mozilla::ipc::BackgroundChildImpl
;
39 friend class QuotaManagerService
;
41 QuotaManagerService
* mService
;
44 nsCOMPtr
<nsIEventTarget
> mOwningThread
;
48 void AssertIsOnOwningThread() const
57 // Only created by QuotaManagerService.
58 explicit QuotaChild(QuotaManagerService
* aService
);
60 // Only destroyed by mozilla::ipc::BackgroundChildImpl.
63 // IPDL methods are only called by IPDL.
64 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
66 virtual PQuotaUsageRequestChild
* AllocPQuotaUsageRequestChild(
67 const UsageRequestParams
& aParams
) override
;
69 virtual bool DeallocPQuotaUsageRequestChild(
70 PQuotaUsageRequestChild
* aActor
) override
;
72 virtual PQuotaRequestChild
* AllocPQuotaRequestChild(
73 const RequestParams
& aParams
) override
;
75 virtual bool DeallocPQuotaRequestChild(PQuotaRequestChild
* aActor
) override
;
78 class QuotaUsageRequestChild final
: public PQuotaUsageRequestChild
{
79 friend class QuotaChild
;
80 friend class QuotaManagerService
;
82 RefPtr
<UsageRequest
> mRequest
;
85 void AssertIsOnOwningThread() const
94 // Only created by QuotaManagerService.
95 explicit QuotaUsageRequestChild(UsageRequest
* aRequest
);
97 // Only destroyed by QuotaChild.
98 ~QuotaUsageRequestChild();
100 void HandleResponse(nsresult aResponse
);
102 void HandleResponse(const nsTArray
<OriginUsage
>& aResponse
);
104 void HandleResponse(const OriginUsageResponse
& aResponse
);
106 // IPDL methods are only called by IPDL.
107 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
109 virtual mozilla::ipc::IPCResult
Recv__delete__(
110 const UsageRequestResponse
& aResponse
) override
;
113 class QuotaRequestChild final
: public PQuotaRequestChild
{
114 friend class QuotaChild
;
115 friend class QuotaManagerService
;
117 RefPtr
<Request
> mRequest
;
120 void AssertIsOnOwningThread() const
129 // Only created by QuotaManagerService.
130 explicit QuotaRequestChild(Request
* aRequest
);
132 // Only destroyed by QuotaChild.
133 ~QuotaRequestChild();
135 void HandleResponse(nsresult aResponse
);
137 void HandleResponse();
139 void HandleResponse(bool aResponse
);
141 void HandleResponse(const nsAString
& aResponse
);
143 void HandleResponse(const EstimateResponse
& aResponse
);
145 void HandleResponse(const nsTArray
<nsCString
>& aResponse
);
147 // IPDL methods are only called by IPDL.
148 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
150 virtual mozilla::ipc::IPCResult
Recv__delete__(
151 const RequestResponse
& aResponse
) override
;
156 } // namespace mozilla
158 #endif // mozilla_dom_quota_ActorsChild_h