Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_dom_SharedMessagePortMessage_h
7 : #define mozilla_dom_SharedMessagePortMessage_h
8 :
9 : #include "mozilla/dom/ipc/StructuredCloneData.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 : class MessagePortChild;
15 : class MessagePortMessage;
16 : class MessagePortParent;
17 :
18 : class SharedMessagePortMessage final : public ipc::StructuredCloneData
19 : {
20 : public:
21 0 : NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage)
22 :
23 0 : SharedMessagePortMessage()
24 0 : : ipc::StructuredCloneData()
25 0 : {}
26 :
27 : // Note that the populated ClonedMessageData borrows the underlying
28 : // JSStructuredCloneData from the SharedMessagePortMessage, so the caller is
29 : // required to ensure that the ClonedMessageData instances are destroyed prior
30 : // to the SharedMessagePortMessage instances.
31 : static void
32 : FromSharedToMessagesChild(
33 : MessagePortChild* aActor,
34 : const nsTArray<RefPtr<SharedMessagePortMessage>>& aData,
35 : nsTArray<ClonedMessageData>& aArray);
36 :
37 : static bool
38 : FromMessagesToSharedChild(
39 : nsTArray<ClonedMessageData>& aArray,
40 : FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData);
41 :
42 : // Note that the populated ClonedMessageData borrows the underlying
43 : // JSStructuredCloneData from the SharedMessagePortMessage, so the caller is
44 : // required to ensure that the ClonedMessageData instances are destroyed prior
45 : // to the SharedMessagePortMessage instances.
46 : static bool
47 : FromSharedToMessagesParent(
48 : MessagePortParent* aActor,
49 : const nsTArray<RefPtr<SharedMessagePortMessage>>& aData,
50 : FallibleTArray<ClonedMessageData>& aArray);
51 :
52 : static bool
53 : FromMessagesToSharedParent(
54 : nsTArray<ClonedMessageData>& aArray,
55 : FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData);
56 :
57 : private:
58 0 : ~SharedMessagePortMessage() {}
59 : };
60 :
61 : } // namespace dom
62 : } // namespace mozilla
63 :
64 : #endif // mozilla_dom_SharedMessagePortMessage_h
|