| Index: include/v8.h
|
| diff --git a/include/v8.h b/include/v8.h
|
| index d7e39adbaee34955ce14737573d2ca6fb1fb5458..968df4b7ce77062f52ca799f55f02f8a5dc34dc4 100644
|
| --- a/include/v8.h
|
| +++ b/include/v8.h
|
| @@ -1664,6 +1664,91 @@ class V8_EXPORT JSON {
|
| Local<String> gap = Local<String>());
|
| };
|
|
|
| +/**
|
| + * Value serialization compatible with the HTML structured clone algorithm.
|
| + * The format is backward-compatible (i.e. safe to store to disk).
|
| + *
|
| + * WARNING: This API is under development, and changes (including incompatible
|
| + * changes to the API or wire format) may occur without notice until this
|
| + * warning is removed.
|
| + */
|
| +class V8_EXPORT ValueSerializer {
|
| + public:
|
| + explicit ValueSerializer(Isolate* isolate);
|
| + ~ValueSerializer();
|
| +
|
| + /*
|
| + * Writes out a header, which includes the format version.
|
| + */
|
| + void WriteHeader();
|
| +
|
| + /*
|
| + * Serializes a JavaScript value into the buffer.
|
| + */
|
| + V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context,
|
| + Local<Value> value);
|
| +
|
| + /*
|
| + * Returns the stored data. This serializer should not be used once the buffer
|
| + * is released. The contents are undefined if a previous write has failed.
|
| + */
|
| + std::vector<uint8_t> ReleaseBuffer();
|
| +
|
| + private:
|
| + ValueSerializer(const ValueSerializer&) = delete;
|
| + void operator=(const ValueSerializer&) = delete;
|
| +
|
| + struct PrivateData;
|
| + PrivateData* private_;
|
| +};
|
| +
|
| +/**
|
| + * Deserializes values from data written with ValueSerializer, or a compatible
|
| + * implementation.
|
| + *
|
| + * WARNING: This API is under development, and changes (including incompatible
|
| + * changes to the API or wire format) may occur without notice until this
|
| + * warning is removed.
|
| + */
|
| +class V8_EXPORT ValueDeserializer {
|
| + public:
|
| + ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
|
| + ~ValueDeserializer();
|
| +
|
| + /*
|
| + * Reads and validates a header (including the format version).
|
| + * May, for example, reject an invalid or unsupported wire format.
|
| + */
|
| + V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader();
|
| +
|
| + /*
|
| + * Deserializes a JavaScript value from the buffer.
|
| + */
|
| + V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context);
|
| +
|
| + /*
|
| + * Must be called before ReadHeader to enable support for reading the legacy
|
| + * wire format (i.e., which predates this being shipped).
|
| + *
|
| + * Don't use this unless you need to read data written by previous versions of
|
| + * blink::ScriptValueSerializer.
|
| + */
|
| + void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
|
| +
|
| + /*
|
| + * Reads the underlying wire format version. Likely mostly to be useful to
|
| + * legacy code reading old wire format versions. Must be called after
|
| + * ReadHeader.
|
| + */
|
| + uint32_t GetWireFormatVersion() const;
|
| +
|
| + private:
|
| + ValueDeserializer(const ValueDeserializer&) = delete;
|
| + void operator=(const ValueDeserializer&) = delete;
|
| +
|
| + struct PrivateData;
|
| + PrivateData* private_;
|
| +};
|
|
|
| /**
|
| * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap
|
|
|