/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_MessagePortUtils_h #define mozilla_dom_MessagePortUtils_h #include "MessagePort.h" #include "mozilla/dom/File.h" #include "mozilla/dom/PMessagePort.h" class nsPIDOMWindow; namespace mozilla { namespace dom { namespace messageport { struct StructuredCloneClosure { nsTArray> mBlobImpls; nsTArray mMessagePortIdentifiers; }; struct StructuredCloneData { StructuredCloneData() : mData(nullptr), mDataLength(0) {} uint64_t* mData; size_t mDataLength; StructuredCloneClosure mClosure; }; bool ReadStructuredCloneWithTransfer(JSContext* aCx, nsTArray& aData, const StructuredCloneClosure& aClosure, JS::MutableHandle aClone, nsPIDOMWindow* aParentWindow, nsTArray>& aMessagePorts); bool WriteStructuredCloneWithTransfer(JSContext* aCx, JS::Handle aSource, JS::Handle aTransferable, nsTArray& aData, StructuredCloneClosure& aClosure); void FreeStructuredClone(nsTArray& aData, StructuredCloneClosure& aClosure); } // namespace messageport } // namespace dom } // namespace mozilla #endif // mozilla_dom_MessagePortUtils_h