dom/ipc/StructuredCloneUtils.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d293c2ac3499
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set sw=4 ts=8 et 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_StructuredCloneUtils_h
8 #define mozilla_dom_StructuredCloneUtils_h
9
10 #include "nsCOMPtr.h"
11 #include "nsTArray.h"
12 #include "nsIDOMFile.h"
13
14 #include "js/StructuredClone.h"
15
16 namespace mozilla {
17
18 struct SerializedStructuredCloneBuffer;
19
20 namespace dom {
21
22 struct
23 StructuredCloneClosure
24 {
25 nsTArray<nsCOMPtr<nsIDOMBlob> > mBlobs;
26 };
27
28 struct
29 StructuredCloneData
30 {
31 StructuredCloneData() : mData(nullptr), mDataLength(0) {}
32 uint64_t* mData;
33 size_t mDataLength;
34 StructuredCloneClosure mClosure;
35 };
36
37 bool
38 ReadStructuredClone(JSContext* aCx, uint64_t* aData, size_t aDataLength,
39 const StructuredCloneClosure& aClosure,
40 JS::MutableHandle<JS::Value> aClone);
41
42 inline bool
43 ReadStructuredClone(JSContext* aCx, const StructuredCloneData& aData,
44 JS::MutableHandle<JS::Value> aClone)
45 {
46 return ReadStructuredClone(aCx, aData.mData, aData.mDataLength,
47 aData.mClosure, aClone);
48 }
49
50 bool
51 WriteStructuredClone(JSContext* aCx, JS::Handle<JS::Value> aSource,
52 JSAutoStructuredCloneBuffer& aBuffer,
53 StructuredCloneClosure& aClosure);
54
55 } // namespace dom
56 } // namespace mozilla
57
58 #endif // mozilla_dom_StructuredCloneUtils_h

mercurial