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/. */
7 #ifndef mozilla_dom_SharedMessagePortMessage_h
8 #define mozilla_dom_SharedMessagePortMessage_h
10 #include "mozilla/dom/ipc/StructuredCloneData.h"
15 class MessagePortChild
;
16 class MessagePortMessage
;
17 class MessagePortParent
;
19 class SharedMessagePortMessage final
: public ipc::StructuredCloneData
{
21 NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage
)
23 SharedMessagePortMessage() : ipc::StructuredCloneData() {}
25 // Note that the populated ClonedMessageData borrows the underlying
26 // JSStructuredCloneData from the SharedMessagePortMessage, so the caller is
27 // required to ensure that the ClonedMessageData instances are destroyed prior
28 // to the SharedMessagePortMessage instances.
29 static void FromSharedToMessagesChild(
30 MessagePortChild
* aActor
,
31 const nsTArray
<RefPtr
<SharedMessagePortMessage
>>& aData
,
32 nsTArray
<ClonedMessageData
>& aArray
);
34 static bool FromMessagesToSharedChild(
35 nsTArray
<ClonedMessageData
>& aArray
,
36 FallibleTArray
<RefPtr
<SharedMessagePortMessage
>>& aData
);
38 // Note that the populated ClonedMessageData borrows the underlying
39 // JSStructuredCloneData from the SharedMessagePortMessage, so the caller is
40 // required to ensure that the ClonedMessageData instances are destroyed prior
41 // to the SharedMessagePortMessage instances.
42 static bool FromSharedToMessagesParent(
43 MessagePortParent
* aActor
,
44 const nsTArray
<RefPtr
<SharedMessagePortMessage
>>& aData
,
45 FallibleTArray
<ClonedMessageData
>& aArray
);
47 static bool FromMessagesToSharedParent(
48 nsTArray
<ClonedMessageData
>& aArray
,
49 FallibleTArray
<RefPtr
<SharedMessagePortMessage
>>& aData
);
52 ~SharedMessagePortMessage() {}
56 } // namespace mozilla
58 #endif // mozilla_dom_SharedMessagePortMessage_h