ActorsChild.h (2650B)
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/. */ 6 7 #ifndef mozilla_dom_quota_ActorsChild_h 8 #define mozilla_dom_quota_ActorsChild_h 9 10 #include "ErrorList.h" 11 #include "mozilla/RefPtr.h" 12 #include "mozilla/dom/quota/PQuotaChild.h" 13 #include "mozilla/dom/quota/PQuotaRequestChild.h" 14 #include "mozilla/ipc/ProtocolUtils.h" 15 #include "nsCOMPtr.h" 16 #include "nsStringFwd.h" 17 #include "nsTArray.h" 18 19 class nsIEventTarget; 20 21 namespace mozilla { 22 namespace ipc { 23 24 class BackgroundChildImpl; 25 26 } // namespace ipc 27 28 namespace dom::quota { 29 30 class QuotaManagerService; 31 class Request; 32 class UsageRequest; 33 34 class QuotaChild final : public PQuotaChild { 35 friend class mozilla::ipc::BackgroundChildImpl; 36 friend class QuotaManagerService; 37 38 QuotaManagerService* mService; 39 40 #ifdef DEBUG 41 nsCOMPtr<nsIEventTarget> mOwningThread; 42 #endif 43 44 public: 45 NS_INLINE_DECL_REFCOUNTING(QuotaChild, override) 46 47 void AssertIsOnOwningThread() const 48 #ifdef DEBUG 49 ; 50 #else 51 { 52 } 53 #endif 54 55 private: 56 // Only created by QuotaManagerService. 57 explicit QuotaChild(QuotaManagerService* aService); 58 59 ~QuotaChild(); 60 61 // IPDL methods are only called by IPDL. 62 virtual void ActorDestroy(ActorDestroyReason aWhy) override; 63 64 virtual PQuotaRequestChild* AllocPQuotaRequestChild( 65 const RequestParams& aParams) override; 66 67 virtual bool DeallocPQuotaRequestChild(PQuotaRequestChild* aActor) override; 68 }; 69 70 class QuotaRequestChild final : public PQuotaRequestChild { 71 friend class QuotaChild; 72 friend class QuotaManagerService; 73 74 RefPtr<Request> mRequest; 75 76 public: 77 void AssertIsOnOwningThread() const 78 #ifdef DEBUG 79 ; 80 #else 81 { 82 } 83 #endif 84 85 private: 86 // Only created by QuotaManagerService. 87 explicit QuotaRequestChild(Request* aRequest); 88 89 // Only destroyed by QuotaChild. 90 ~QuotaRequestChild(); 91 92 void HandleResponse(nsresult aResponse); 93 94 void HandleResponse(); 95 96 void HandleResponse(bool aResponse); 97 98 void HandleResponse(const nsAString& aResponse); 99 100 void HandleResponse(const EstimateResponse& aResponse); 101 102 void HandleResponse(const GetFullOriginMetadataResponse& aResponse); 103 104 // IPDL methods are only called by IPDL. 105 virtual void ActorDestroy(ActorDestroyReason aWhy) override; 106 107 virtual mozilla::ipc::IPCResult Recv__delete__( 108 const RequestResponse& aResponse) override; 109 }; 110 111 } // namespace dom::quota 112 } // namespace mozilla 113 114 #endif // mozilla_dom_quota_ActorsChild_h