Bug 1860712 [wpt PR 42705] - Port popover test to WPT and adjust for close requests...
[gecko.git] / dom / messagechannel / MessagePortParent.h
blob13c92a1ef6a9f8da793c52402587dba3d3cd2c70
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_MessagePortParent_h
8 #define mozilla_dom_MessagePortParent_h
10 #include "mozilla/WeakPtr.h"
11 #include "mozilla/dom/PMessagePortParent.h"
12 #include "mozilla/dom/quota/CheckedUnsafePtr.h"
14 namespace mozilla::dom {
16 class MessagePortService;
18 class MessagePortParent final
19 : public PMessagePortParent,
20 public SupportsWeakPtr,
21 public SupportsCheckedUnsafePtr<CheckIf<DiagnosticAssertEnabled>> {
22 friend class PMessagePortParent;
24 public:
25 explicit MessagePortParent(const nsID& aUUID);
26 ~MessagePortParent();
28 bool Entangle(const nsID& aDestinationUUID, const uint32_t& aSequenceID);
30 bool Entangled(nsTArray<MessageData>&& aMessages);
32 void Close();
33 void CloseAndDelete();
35 bool CanSendData() const { return mCanSendData; }
37 const nsID& ID() const { return mUUID; }
39 static bool ForceClose(const nsID& aUUID, const nsID& aDestinationUUID,
40 const uint32_t& aSequenceID);
42 private:
43 mozilla::ipc::IPCResult RecvPostMessages(nsTArray<MessageData>&& aMessages);
45 mozilla::ipc::IPCResult RecvDisentangle(nsTArray<MessageData>&& aMessages);
47 mozilla::ipc::IPCResult RecvStopSendingData();
49 mozilla::ipc::IPCResult RecvClose();
51 virtual void ActorDestroy(ActorDestroyReason aWhy) override;
53 RefPtr<MessagePortService> mService;
54 const nsID mUUID;
55 bool mEntangled;
56 bool mCanSendData;
59 } // namespace mozilla::dom
61 #endif // mozilla_dom_MessagePortParent_h