ClientSourceParent.h (2778B)
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_ClientSourceParent_h 7 #define _mozilla_dom_ClientSourceParent_h 8 9 #include "ClientInfo.h" 10 #include "ClientOpPromise.h" 11 #include "mozilla/MozPromise.h" 12 #include "mozilla/dom/PClientSourceParent.h" 13 #include "mozilla/dom/ServiceWorkerDescriptor.h" 14 #include "mozilla/dom/ipc/IdType.h" 15 16 namespace mozilla::dom { 17 18 class ClientHandleParent; 19 class ClientManagerService; 20 21 class ClientSourceParent final : public PClientSourceParent { 22 ClientInfo mClientInfo; 23 Maybe<ServiceWorkerDescriptor> mController; 24 const Maybe<ContentParentId> mContentParentId; 25 RefPtr<ClientManagerService> mService; 26 nsTArray<ClientHandleParent*> mHandleList; 27 MozPromiseHolder<GenericNonExclusivePromise> mExecutionReadyPromise; 28 bool mExecutionReady; 29 bool mFrozen; 30 31 ~ClientSourceParent(); 32 33 // PClientSourceParent 34 mozilla::ipc::IPCResult RecvWorkerSyncPing() override; 35 36 mozilla::ipc::IPCResult RecvTeardown() override; 37 38 mozilla::ipc::IPCResult RecvExecutionReady( 39 const ClientSourceExecutionReadyArgs& aArgs) override; 40 41 mozilla::ipc::IPCResult RecvFreeze() override; 42 43 mozilla::ipc::IPCResult RecvThaw() override; 44 45 mozilla::ipc::IPCResult RecvInheritController( 46 const ClientControlledArgs& aArgs) override; 47 48 mozilla::ipc::IPCResult RecvNoteDOMContentLoaded() override; 49 50 void ActorDestroy(ActorDestroyReason aReason) override; 51 52 PClientSourceOpParent* AllocPClientSourceOpParent( 53 const ClientOpConstructorArgs& aArgs) override; 54 55 bool DeallocPClientSourceOpParent(PClientSourceOpParent* aActor) override; 56 57 public: 58 NS_INLINE_DECL_REFCOUNTING(ClientSourceParent, override) 59 60 explicit ClientSourceParent(const ClientSourceConstructorArgs& aArgs, 61 const Maybe<ContentParentId>& aContentParentId); 62 63 mozilla::ipc::IPCResult Init(); 64 65 const ClientInfo& Info() const; 66 67 bool IsFrozen() const; 68 69 bool ExecutionReady() const; 70 71 RefPtr<GenericNonExclusivePromise> ExecutionReadyPromise(); 72 73 const Maybe<ServiceWorkerDescriptor>& GetController() const; 74 75 void ClearController(); 76 77 bool IsOwnedByProcess(ContentParentId aContentParentId) const { 78 return mContentParentId && mContentParentId.value() == aContentParentId; 79 } 80 81 void AttachHandle(ClientHandleParent* aClientSource); 82 83 void DetachHandle(ClientHandleParent* aClientSource); 84 85 RefPtr<ClientOpPromise> StartOp(ClientOpConstructorArgs&& aArgs); 86 }; 87 88 } // namespace mozilla::dom 89 90 #endif // _mozilla_dom_ClientSourceParent_h