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/. */
7 #ifndef mozilla_dom_StructuredCloneTester_h
8 #define mozilla_dom_StructuredCloneTester_h
10 #include "mozilla/AlreadyAddRefed.h"
12 #include "nsISupports.h"
13 #include "nsWrapperCache.h"
15 struct JSStructuredCloneReader
;
16 struct JSStructuredCloneWriter
;
17 class nsIGlobalObject
;
27 class StructuredCloneTester final
: public nsISupports
, public nsWrapperCache
{
29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
30 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(StructuredCloneTester
)
32 static already_AddRefed
<StructuredCloneTester
> Constructor(
33 const GlobalObject
& aGlobal
, const bool aSerializable
,
34 const bool aDeserializable
);
36 bool Serializable() const;
38 bool Deserializable() const;
40 static already_AddRefed
<StructuredCloneTester
> ReadStructuredClone(
41 JSContext
* aCx
, nsIGlobalObject
* aGlobal
,
42 JSStructuredCloneReader
* aReader
);
44 bool WriteStructuredClone(JSContext
* aCx
,
45 JSStructuredCloneWriter
* aWriter
) const;
47 nsISupports
* GetParentObject() const;
49 // nsWrapperCache interface
50 JSObject
* WrapObject(JSContext
* aCx
,
51 JS::Handle
<JSObject
*> aGivenProto
) override
;
54 StructuredCloneTester(nsISupports
* aParent
, const bool aSerializable
,
55 const bool aDeserializable
);
56 ~StructuredCloneTester() = default;
58 nsCOMPtr
<nsISupports
> mParent
;
64 } // namespace mozilla
66 #endif // mozilla_dom_StructuredCloneTester_h