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_StructuredCloneTester_h 8 #define mozilla_dom_StructuredCloneTester_h 9 10 #include "mozilla/AlreadyAddRefed.h" 11 #include "nsCOMPtr.h" 12 #include "nsISupports.h" 13 #include "nsWrapperCache.h" 14 15 struct JSStructuredCloneReader; 16 struct JSStructuredCloneWriter; 17 class nsIGlobalObject; 18 19 namespace mozilla { 20 21 class ErrorResult; 22 23 namespace dom { 24 25 class GlobalObject; 26 27 class StructuredCloneTester final : public nsISupports, public nsWrapperCache { 28 public: 29 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 30 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StructuredCloneTester) 31 32 static already_AddRefed<StructuredCloneTester> Constructor( 33 const GlobalObject& aGlobal, const bool aSerializable, 34 const bool aDeserializable); 35 36 bool Serializable() const; 37 38 bool Deserializable() const; 39 40 static already_AddRefed<StructuredCloneTester> ReadStructuredClone( 41 JSContext* aCx, nsIGlobalObject* aGlobal, 42 JSStructuredCloneReader* aReader); 43 44 bool WriteStructuredClone(JSContext* aCx, 45 JSStructuredCloneWriter* aWriter) const; 46 47 nsISupports* GetParentObject() const; 48 49 // nsWrapperCache interface 50 JSObject* WrapObject(JSContext* aCx, 51 JS::Handle<JSObject*> aGivenProto) override; 52 53 private: 54 StructuredCloneTester(nsISupports* aParent, const bool aSerializable, 55 const bool aDeserializable); 56 ~StructuredCloneTester() = default; 57 58 nsCOMPtr<nsISupports> mParent; 59 bool mSerializable; 60 bool mDeserializable; 61 }; 62 63 } // namespace dom 64 } // namespace mozilla 65 66 #endif // mozilla_dom_StructuredCloneTester_h 67