1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/interfaces/base/nsIStructuredCloneContainer.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: set ts=8 sw=2 et tw=80: 1.6 + * 1.7 + * This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#include "nsISupports.idl" 1.12 + 1.13 +interface nsIVariant; 1.14 +interface nsIDocument; 1.15 + 1.16 +%{C++ 1.17 +#include "js/TypeDecls.h" 1.18 +%} 1.19 + 1.20 +/** 1.21 + * This interface acts as a container for an object serialized using the 1.22 + * structured clone algorithm. 1.23 + * 1.24 + * You can copy an object into an nsIStructuredCloneContainer using 1.25 + * initFromVariant or initFromBase64. It's an error to initialize an 1.26 + * nsIStructuredCloneContainer more than once. 1.27 + * 1.28 + * Once you've initialized the container, you can get a copy of the object it 1.29 + * stores by calling deserializeToVariant. You can also get a base-64-encoded 1.30 + * string containing a copy of the container's serialized data, using 1.31 + * getDataAsBase64. 1.32 + */ 1.33 +[scriptable, uuid(c8852f01-4c05-47c3-acca-253a958f39f6)] 1.34 +interface nsIStructuredCloneContainer : nsISupports 1.35 +{ 1.36 + /** 1.37 + * Initialize this structured clone container so it contains a clone of the 1.38 + * given jsval. 1.39 + */ 1.40 + [noscript, implicit_jscontext] 1.41 + void initFromJSVal(in jsval aData); 1.42 + 1.43 + /** 1.44 + * Initialize this structured clone container from a base-64-encoded byte 1.45 + * stream, stored in aData. aFormatVersion should be the version of the 1.46 + * structured clone algorithm which was used to generate aData. 1.47 + */ 1.48 + [implicit_jscontext] 1.49 + void initFromBase64(in AString aData,in unsigned long aFormatVersion); 1.50 + 1.51 + /** 1.52 + * Deserialize the object this conatiner holds, returning it wrapped as 1.53 + * an nsIVariant. 1.54 + */ 1.55 + [implicit_jscontext] 1.56 + nsIVariant deserializeToVariant(); 1.57 + 1.58 + /** 1.59 + * Get this structured clone container's data as a base-64-encoded string. 1.60 + */ 1.61 + AString getDataAsBase64(); 1.62 + 1.63 + /** 1.64 + * Get the size in bytes of this container's serialized data. 1.65 + */ 1.66 + readonly attribute unsigned long long serializedNBytes; 1.67 + 1.68 + /** 1.69 + * Get the version of the structured clone algorithm which was used to 1.70 + * generate this container's serialized buffer. 1.71 + */ 1.72 + readonly attribute unsigned long formatVersion; 1.73 +};