Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: include/v8.h

Issue 2274693002: Add an experimental public API for value serialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: explicitly manage the pointer rather than using std::unique_ptr, to deal with C4521 (Windows) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 * it as string if successful. 1657 * it as string if successful.
1658 * 1658 *
1659 * \param json_object The JSON-serializable object to stringify. 1659 * \param json_object The JSON-serializable object to stringify.
1660 * \return The corresponding string if successfully stringified. 1660 * \return The corresponding string if successfully stringified.
1661 */ 1661 */
1662 static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify( 1662 static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify(
1663 Local<Context> context, Local<Object> json_object, 1663 Local<Context> context, Local<Object> json_object,
1664 Local<String> gap = Local<String>()); 1664 Local<String> gap = Local<String>());
1665 }; 1665 };
1666 1666
1667 /**
1668 * Value serialization compatible with the HTML structured clone algorithm.
1669 * The format is backward-compatible (i.e. safe to store to disk).
1670 *
1671 * WARNING: This API is under development, and changes (including incompatible
1672 * changes to the API or wire format) may occur without notice until this
1673 * warning is removed.
1674 */
1675 class V8_EXPORT ValueSerializer {
1676 public:
1677 explicit ValueSerializer(Isolate* isolate);
1678 ~ValueSerializer();
1679
1680 /*
1681 * Writes out a header, which includes the format version.
1682 */
1683 void WriteHeader();
1684
1685 /*
1686 * Serializes a JavaScript value into the buffer.
1687 */
1688 V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context,
1689 Local<Value> value);
1690
1691 /*
1692 * Returns the stored data. This serializer should not be used once the buffer
1693 * is released. The contents are undefined if a previous write has failed.
1694 */
1695 std::vector<uint8_t> ReleaseBuffer();
1696
1697 private:
1698 ValueSerializer(const ValueSerializer&) = delete;
1699 void operator=(const ValueSerializer&) = delete;
1700
1701 struct PrivateData;
1702 PrivateData* private_;
1703 };
1704
1705 /**
1706 * Deserializes values from data written with ValueSerializer, or a compatible
1707 * implementation.
1708 *
1709 * WARNING: This API is under development, and changes (including incompatible
1710 * changes to the API or wire format) may occur without notice until this
1711 * warning is removed.
1712 */
1713 class V8_EXPORT ValueDeserializer {
1714 public:
1715 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
1716 ~ValueDeserializer();
1717
1718 /*
1719 * Reads and validates a header (including the format version).
1720 * May, for example, reject an invalid or unsupported wire format.
1721 */
1722 V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader();
1723
1724 /*
1725 * Deserializes a JavaScript value from the buffer.
1726 */
1727 V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context);
1728
1729 /*
1730 * Must be called to enable support for reading the legacy wire format (i.e.,
1731 * which predates this being shipped). Don't use this unless you need to read
1732 * data written by previous versions of blink::ScriptValueSerializer.
1733 */
1734 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
1735
1736 /*
1737 * Reads the underlying wire format version. Likely mostly to be useful to
1738 * legacy code reading old wire format versions. Must be called after
1739 * ReadHeader.
1740 */
1741 uint32_t GetWireFormatVersion() const;
1742
1743 private:
1744 ValueDeserializer(const ValueDeserializer&) = delete;
1745 void operator=(const ValueDeserializer&) = delete;
1746
1747 struct PrivateData;
1748 PrivateData* private_;
1749 };
1667 1750
1668 /** 1751 /**
1669 * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap 1752 * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap
1670 * but can be created without entering a v8::Context and hence shouldn't 1753 * but can be created without entering a v8::Context and hence shouldn't
1671 * escape to JavaScript. 1754 * escape to JavaScript.
1672 */ 1755 */
1673 class V8_EXPORT NativeWeakMap : public Data { 1756 class V8_EXPORT NativeWeakMap : public Data {
1674 public: 1757 public:
1675 static Local<NativeWeakMap> New(Isolate* isolate); 1758 static Local<NativeWeakMap> New(Isolate* isolate);
1676 void Set(Local<Value> key, Local<Value> value); 1759 void Set(Local<Value> key, Local<Value> value);
(...skipping 7329 matching lines...) Expand 10 before | Expand all | Expand 10 after
9006 */ 9089 */
9007 9090
9008 9091
9009 } // namespace v8 9092 } // namespace v8
9010 9093
9011 9094
9012 #undef TYPE_CHECK 9095 #undef TYPE_CHECK
9013 9096
9014 9097
9015 #endif // INCLUDE_V8_H_ 9098 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698