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

Side by Side Diff: include/v8.h

Issue 2327653002: Support delegating serialization of host objects. (Closed)
Patch Set: Isolate* argument to delegate 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') | no next file with comments »
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 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 class V8_EXPORT Delegate { 1674 class V8_EXPORT Delegate {
1675 public: 1675 public:
1676 virtual ~Delegate() {} 1676 virtual ~Delegate() {}
1677 1677
1678 /* 1678 /*
1679 * Handles the case where a DataCloneError would be thrown in the structured 1679 * Handles the case where a DataCloneError would be thrown in the structured
1680 * clone spec. Other V8 embedders may throw some other appropriate exception 1680 * clone spec. Other V8 embedders may throw some other appropriate exception
1681 * type. 1681 * type.
1682 */ 1682 */
1683 virtual void ThrowDataCloneError(Local<String> message) = 0; 1683 virtual void ThrowDataCloneError(Local<String> message) = 0;
1684
1685 /*
1686 * The embedder overrides this method to write some kind of host object, if
1687 * possible. If not, a suitable exception should be thrown and
1688 * Nothing<bool>() returned.
1689 */
1690 virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
jochen (gone - plz use gerrit) 2016/09/14 15:44:31 should this be pure virtual?
jbroman 2016/09/14 16:35:23 Ideally, yes. How does V8 usually manage rollout o
1684 }; 1691 };
1685 1692
1686 explicit ValueSerializer(Isolate* isolate); 1693 explicit ValueSerializer(Isolate* isolate);
1687 ValueSerializer(Isolate* isolate, Delegate* delegate); 1694 ValueSerializer(Isolate* isolate, Delegate* delegate);
1688 ~ValueSerializer(); 1695 ~ValueSerializer();
1689 1696
1690 /* 1697 /*
1691 * Writes out a header, which includes the format version. 1698 * Writes out a header, which includes the format version.
1692 */ 1699 */
1693 void WriteHeader(); 1700 void WriteHeader();
(...skipping 17 matching lines...) Expand all
1711 */ 1718 */
1712 void TransferArrayBuffer(uint32_t transfer_id, 1719 void TransferArrayBuffer(uint32_t transfer_id,
1713 Local<ArrayBuffer> array_buffer); 1720 Local<ArrayBuffer> array_buffer);
1714 1721
1715 /* 1722 /*
1716 * Similar to TransferArrayBuffer, but for SharedArrayBuffer. 1723 * Similar to TransferArrayBuffer, but for SharedArrayBuffer.
1717 */ 1724 */
1718 void TransferSharedArrayBuffer(uint32_t transfer_id, 1725 void TransferSharedArrayBuffer(uint32_t transfer_id,
1719 Local<SharedArrayBuffer> shared_array_buffer); 1726 Local<SharedArrayBuffer> shared_array_buffer);
1720 1727
1728 /*
1729 * Write raw data in various common formats to the buffer.
1730 * Note that integer types are written in base-128 varint format, not with a
1731 * binary copy. For use during an override of Delegate::WriteHostObject.
1732 */
1733 void WriteUint32(uint32_t value);
1734 void WriteUint64(uint64_t value);
1735 void WriteRawBytes(const void* source, size_t length);
1736
1721 private: 1737 private:
1722 ValueSerializer(const ValueSerializer&) = delete; 1738 ValueSerializer(const ValueSerializer&) = delete;
1723 void operator=(const ValueSerializer&) = delete; 1739 void operator=(const ValueSerializer&) = delete;
1724 1740
1725 struct PrivateData; 1741 struct PrivateData;
1726 PrivateData* private_; 1742 PrivateData* private_;
1727 }; 1743 };
1728 1744
1729 /** 1745 /**
1730 * Deserializes values from data written with ValueSerializer, or a compatible 1746 * Deserializes values from data written with ValueSerializer, or a compatible
1731 * implementation. 1747 * implementation.
1732 * 1748 *
1733 * WARNING: This API is under development, and changes (including incompatible 1749 * WARNING: This API is under development, and changes (including incompatible
1734 * changes to the API or wire format) may occur without notice until this 1750 * changes to the API or wire format) may occur without notice until this
1735 * warning is removed. 1751 * warning is removed.
1736 */ 1752 */
1737 class V8_EXPORT ValueDeserializer { 1753 class V8_EXPORT ValueDeserializer {
1738 public: 1754 public:
1755 class V8_EXPORT Delegate {
1756 public:
1757 virtual ~Delegate() {}
1758
1759 /*
1760 * The embedder overrides this method to read some kind of host object, if
1761 * possible. If not, a suitable exception should be thrown and
1762 * MaybeLocal<Object>() returned.
1763 */
1764 virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
jochen (gone - plz use gerrit) 2016/09/14 15:44:31 same here?
1765 };
1766
1739 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); 1767 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size);
1768 ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size,
1769 Delegate* delegate);
1740 ~ValueDeserializer(); 1770 ~ValueDeserializer();
1741 1771
1742 /* 1772 /*
1743 * Reads and validates a header (including the format version). 1773 * Reads and validates a header (including the format version).
1744 * May, for example, reject an invalid or unsupported wire format. 1774 * May, for example, reject an invalid or unsupported wire format.
1745 */ 1775 */
1746 V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context); 1776 V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context);
1747 V8_DEPRECATE_SOON("Use Local<Context> version", Maybe<bool> ReadHeader()); 1777 V8_DEPRECATE_SOON("Use Local<Context> version", Maybe<bool> ReadHeader());
1748 1778
1749 /* 1779 /*
(...skipping 24 matching lines...) Expand all
1774 */ 1804 */
1775 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); 1805 void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format);
1776 1806
1777 /* 1807 /*
1778 * Reads the underlying wire format version. Likely mostly to be useful to 1808 * Reads the underlying wire format version. Likely mostly to be useful to
1779 * legacy code reading old wire format versions. Must be called after 1809 * legacy code reading old wire format versions. Must be called after
1780 * ReadHeader. 1810 * ReadHeader.
1781 */ 1811 */
1782 uint32_t GetWireFormatVersion() const; 1812 uint32_t GetWireFormatVersion() const;
1783 1813
1814 /*
1815 * Reads raw data in various common formats to the buffer.
1816 * Note that integer types are read in base-128 varint format, not with a
1817 * binary copy. For use during an override of Delegate::ReadHostObject.
1818 */
1819 V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value);
1820 V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value);
1821 V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);
1822
1784 private: 1823 private:
1785 ValueDeserializer(const ValueDeserializer&) = delete; 1824 ValueDeserializer(const ValueDeserializer&) = delete;
1786 void operator=(const ValueDeserializer&) = delete; 1825 void operator=(const ValueDeserializer&) = delete;
1787 1826
1788 struct PrivateData; 1827 struct PrivateData;
1789 PrivateData* private_; 1828 PrivateData* private_;
1790 }; 1829 };
1791 1830
1792 /** 1831 /**
1793 * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap 1832 * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap
(...skipping 7699 matching lines...) Expand 10 before | Expand all | Expand 10 after
9493 */ 9532 */
9494 9533
9495 9534
9496 } // namespace v8 9535 } // namespace v8
9497 9536
9498 9537
9499 #undef TYPE_CHECK 9538 #undef TYPE_CHECK
9500 9539
9501 9540
9502 #endif // INCLUDE_V8_H_ 9541 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698