Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: set ts=8 sw=2 et tw=80: |
michael@0 | 3 | * |
michael@0 | 4 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "nsISupports.idl" |
michael@0 | 9 | |
michael@0 | 10 | interface nsIVariant; |
michael@0 | 11 | interface nsIDocument; |
michael@0 | 12 | |
michael@0 | 13 | %{C++ |
michael@0 | 14 | #include "js/TypeDecls.h" |
michael@0 | 15 | %} |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * This interface acts as a container for an object serialized using the |
michael@0 | 19 | * structured clone algorithm. |
michael@0 | 20 | * |
michael@0 | 21 | * You can copy an object into an nsIStructuredCloneContainer using |
michael@0 | 22 | * initFromVariant or initFromBase64. It's an error to initialize an |
michael@0 | 23 | * nsIStructuredCloneContainer more than once. |
michael@0 | 24 | * |
michael@0 | 25 | * Once you've initialized the container, you can get a copy of the object it |
michael@0 | 26 | * stores by calling deserializeToVariant. You can also get a base-64-encoded |
michael@0 | 27 | * string containing a copy of the container's serialized data, using |
michael@0 | 28 | * getDataAsBase64. |
michael@0 | 29 | */ |
michael@0 | 30 | [scriptable, uuid(c8852f01-4c05-47c3-acca-253a958f39f6)] |
michael@0 | 31 | interface nsIStructuredCloneContainer : nsISupports |
michael@0 | 32 | { |
michael@0 | 33 | /** |
michael@0 | 34 | * Initialize this structured clone container so it contains a clone of the |
michael@0 | 35 | * given jsval. |
michael@0 | 36 | */ |
michael@0 | 37 | [noscript, implicit_jscontext] |
michael@0 | 38 | void initFromJSVal(in jsval aData); |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * Initialize this structured clone container from a base-64-encoded byte |
michael@0 | 42 | * stream, stored in aData. aFormatVersion should be the version of the |
michael@0 | 43 | * structured clone algorithm which was used to generate aData. |
michael@0 | 44 | */ |
michael@0 | 45 | [implicit_jscontext] |
michael@0 | 46 | void initFromBase64(in AString aData,in unsigned long aFormatVersion); |
michael@0 | 47 | |
michael@0 | 48 | /** |
michael@0 | 49 | * Deserialize the object this conatiner holds, returning it wrapped as |
michael@0 | 50 | * an nsIVariant. |
michael@0 | 51 | */ |
michael@0 | 52 | [implicit_jscontext] |
michael@0 | 53 | nsIVariant deserializeToVariant(); |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * Get this structured clone container's data as a base-64-encoded string. |
michael@0 | 57 | */ |
michael@0 | 58 | AString getDataAsBase64(); |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Get the size in bytes of this container's serialized data. |
michael@0 | 62 | */ |
michael@0 | 63 | readonly attribute unsigned long long serializedNBytes; |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Get the version of the structured clone algorithm which was used to |
michael@0 | 67 | * generate this container's serialized buffer. |
michael@0 | 68 | */ |
michael@0 | 69 | readonly attribute unsigned long formatVersion; |
michael@0 | 70 | }; |