ClientHandleParent.h (2029B)
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 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #ifndef _mozilla_dom_ClientHandleParent_h 7 #define _mozilla_dom_ClientHandleParent_h 8 9 #include "mozilla/dom/PClientHandleParent.h" 10 11 namespace mozilla::dom { 12 13 class ClientManagerService; 14 class ClientSourceParent; 15 16 using SourcePromise = 17 MozPromise<bool, CopyableErrorResult, /* IsExclusive = */ false>; 18 19 class ClientHandleParent final : public PClientHandleParent { 20 RefPtr<ClientManagerService> mService; 21 22 // mSource and mSourcePromiseHolder are mutually exclusive. 23 ClientSourceParent* mSource; 24 25 // Operations will wait on this promise while mSource is null. 26 MozPromiseHolder<SourcePromise> mSourcePromiseHolder; 27 28 MozPromiseRequestHolder<SourcePromise> mSourcePromiseRequestHolder; 29 30 nsID mClientId; 31 mozilla::ipc::PrincipalInfo mPrincipalInfo; 32 33 ~ClientHandleParent(); 34 35 // PClientHandleParent interface 36 mozilla::ipc::IPCResult RecvTeardown() override; 37 38 void ActorDestroy(ActorDestroyReason aReason) override; 39 40 PClientHandleOpParent* AllocPClientHandleOpParent( 41 const ClientOpConstructorArgs& aArgs) override; 42 43 bool DeallocPClientHandleOpParent(PClientHandleOpParent* aActor) override; 44 45 mozilla::ipc::IPCResult RecvPClientHandleOpConstructor( 46 PClientHandleOpParent* aActor, 47 const ClientOpConstructorArgs& aArgs) override; 48 49 public: 50 NS_INLINE_DECL_REFCOUNTING(ClientHandleParent, override) 51 52 ClientHandleParent(); 53 54 void Init(const IPCClientInfo& aClientInfo); 55 56 void FoundSource(ClientSourceParent* aSource); 57 58 // Should be called only once EnsureSource() has resolved. May return nullptr. 59 ClientSourceParent* GetSource() const; 60 61 RefPtr<SourcePromise> EnsureSource(); 62 }; 63 64 } // namespace mozilla::dom 65 66 #endif // _mozilla_dom_ClientHandleParent_h