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 public: NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage)21 NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage) 22 23 SharedMessagePortMessage() : ipc::StructuredCloneData() {} 24 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); 33 34 static bool FromMessagesToSharedChild( 35 nsTArray<ClonedMessageData>& aArray, 36 FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData); 37 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); 46 47 static bool FromMessagesToSharedParent( 48 nsTArray<ClonedMessageData>& aArray, 49 FallibleTArray<RefPtr<SharedMessagePortMessage>>& aData); 50 51 private: ~SharedMessagePortMessage()52 ~SharedMessagePortMessage() {} 53 }; 54 55 } // namespace dom 56 } // namespace mozilla 57 58 #endif // mozilla_dom_SharedMessagePortMessage_h 59