/src/mozilla-central/dom/messagechannel/SharedMessagePortMessage.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
7 | | #ifndef mozilla_dom_SharedMessagePortMessage_h |
8 | | #define mozilla_dom_SharedMessagePortMessage_h |
9 | | |
10 | | #include "mozilla/dom/ipc/StructuredCloneData.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace dom { |
14 | | |
15 | | class MessagePortChild; |
16 | | class MessagePortMessage; |
17 | | class MessagePortParent; |
18 | | |
19 | | class SharedMessagePortMessage final : public ipc::StructuredCloneData |
20 | | { |
21 | | public: |
22 | | NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage) |
23 | | |
24 | | SharedMessagePortMessage() |
25 | | : ipc::StructuredCloneData() |
26 | 0 | {} |
27 | | |
28 | | // Note that the populated ClonedMessageData borrows the underlying |
29 | | // JSStructuredCloneData from the SharedMessagePortMessage, so the caller is |
30 | | // required to ensure that the ClonedMessageData instances are destroyed prior |
31 | | // to the SharedMessagePortMessage instances. |
32 | | static void |
33 | | FromSharedToMessagesChild( |
34 | | MessagePortChild* aActor, |
35 | | const nsTArray<RefPtr<SharedMessagePortMessage>>& aData, |
36 | | nsTArray<ClonedMessageData>& aArray); |
37 | | |
38 | | static bool |
39 | | FromMessagesToSharedChild( |
40 | | nsTArray<ClonedMessageData>& aArray, |
41 | | FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData); |
42 | | |
43 | | // Note that the populated ClonedMessageData borrows the underlying |
44 | | // JSStructuredCloneData from the SharedMessagePortMessage, so the caller is |
45 | | // required to ensure that the ClonedMessageData instances are destroyed prior |
46 | | // to the SharedMessagePortMessage instances. |
47 | | static bool |
48 | | FromSharedToMessagesParent( |
49 | | MessagePortParent* aActor, |
50 | | const nsTArray<RefPtr<SharedMessagePortMessage>>& aData, |
51 | | FallibleTArray<ClonedMessageData>& aArray); |
52 | | |
53 | | static bool |
54 | | FromMessagesToSharedParent( |
55 | | nsTArray<ClonedMessageData>& aArray, |
56 | | FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData); |
57 | | |
58 | | private: |
59 | 0 | ~SharedMessagePortMessage() {} |
60 | | }; |
61 | | |
62 | | } // namespace dom |
63 | | } // namespace mozilla |
64 | | |
65 | | #endif // mozilla_dom_SharedMessagePortMessage_h |