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
;
25 explicit MessagePortParent(const nsID
& aUUID
);
28 bool Entangle(const nsID
& aDestinationUUID
, const uint32_t& aSequenceID
);
30 bool Entangled(nsTArray
<MessageData
>&& aMessages
);
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
);
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
;
59 } // namespace mozilla::dom
61 #endif // mozilla_dom_MessagePortParent_h