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_StructuredCloneBlob_h
7 : #define mozilla_dom_StructuredCloneBlob_h
8 :
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/StructuredCloneHolder.h"
11 : #include "mozilla/dom/StructuredCloneHolderBinding.h"
12 : #include "mozilla/RefCounted.h"
13 :
14 : #include "jsapi.h"
15 :
16 : #include "nsISupports.h"
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : class StructuredCloneBlob : public StructuredCloneHolder
22 : , public RefCounted<StructuredCloneBlob>
23 : {
24 : public:
25 0 : MOZ_DECLARE_REFCOUNTED_TYPENAME(StructuredCloneBlob)
26 :
27 : explicit StructuredCloneBlob();
28 :
29 : static JSObject* ReadStructuredClone(JSContext* aCx, JSStructuredCloneReader* aReader,
30 : StructuredCloneHolder* aHolder);
31 : bool WriteStructuredClone(JSContext* aCx, JSStructuredCloneWriter* aWriter,
32 : StructuredCloneHolder* aHolder);
33 :
34 : static already_AddRefed<StructuredCloneBlob>
35 : Constructor(GlobalObject& aGlobal, JS::HandleValue aValue, JS::HandleObject aTargetGlobal, ErrorResult& aRv);
36 :
37 : void Deserialize(JSContext* aCx, JS::HandleObject aTargetScope,
38 : JS::MutableHandleValue aResult, ErrorResult& aRv);
39 :
40 0 : nsISupports* GetParentObject() const { return nullptr; }
41 : JSObject* GetWrapper() const { return nullptr; }
42 :
43 : bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandleObject aResult);
44 :
45 : protected:
46 : template <typename T, detail::RefCountAtomicity>
47 : friend class detail::RefCounted;
48 :
49 0 : ~StructuredCloneBlob() = default;
50 :
51 : private:
52 : bool ReadStructuredCloneInternal(JSContext* aCx, JSStructuredCloneReader* aReader,
53 : StructuredCloneHolder* aHolder);
54 : };
55 :
56 : } // namespace dom
57 : } // namespace mozilla
58 :
59 : #endif // mozilla_dom_StructuredCloneBlob_h
60 :
|