OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef V8_VALUE_SERIALIZER_H_ | 5 #ifndef V8_VALUE_SERIALIZER_H_ |
6 #define V8_VALUE_SERIALIZER_H_ | 6 #define V8_VALUE_SERIALIZER_H_ |
7 | 7 |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 /* | 78 /* |
79 * Publicly exposed wire format writing methods. | 79 * Publicly exposed wire format writing methods. |
80 * These are intended for use within the delegate's WriteHostObject method. | 80 * These are intended for use within the delegate's WriteHostObject method. |
81 */ | 81 */ |
82 void WriteUint32(uint32_t value); | 82 void WriteUint32(uint32_t value); |
83 void WriteUint64(uint64_t value); | 83 void WriteUint64(uint64_t value); |
84 void WriteRawBytes(const void* source, size_t length); | 84 void WriteRawBytes(const void* source, size_t length); |
85 void WriteDouble(double value); | 85 void WriteDouble(double value); |
86 | 86 |
| 87 /* |
| 88 * Indicate whether to treat ArrayBufferView objects as host objects, |
| 89 * i.e. pass them to Delegate::WriteHostObject. This should not be |
| 90 * called when no Delegate was passed. |
| 91 * |
| 92 * The default is not to treat ArrayBufferViews as host objects. |
| 93 */ |
| 94 void SetTreatArrayBufferViewsAsHostObjects(bool mode); |
| 95 |
87 private: | 96 private: |
88 // Managing allocations of the internal buffer. | 97 // Managing allocations of the internal buffer. |
89 Maybe<bool> ExpandBuffer(size_t required_capacity); | 98 Maybe<bool> ExpandBuffer(size_t required_capacity); |
90 | 99 |
91 // Writing the wire format. | 100 // Writing the wire format. |
92 void WriteTag(SerializationTag tag); | 101 void WriteTag(SerializationTag tag); |
93 template <typename T> | 102 template <typename T> |
94 void WriteVarint(T value); | 103 void WriteVarint(T value); |
95 template <typename T> | 104 template <typename T> |
96 void WriteZigZag(T value); | 105 void WriteZigZag(T value); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 * throwing an exception appropriate for the host. | 140 * throwing an exception appropriate for the host. |
132 */ | 141 */ |
133 void ThrowDataCloneError(MessageTemplate::Template template_index); | 142 void ThrowDataCloneError(MessageTemplate::Template template_index); |
134 V8_NOINLINE void ThrowDataCloneError(MessageTemplate::Template template_index, | 143 V8_NOINLINE void ThrowDataCloneError(MessageTemplate::Template template_index, |
135 Handle<Object> arg0); | 144 Handle<Object> arg0); |
136 | 145 |
137 Maybe<bool> ThrowIfOutOfMemory(); | 146 Maybe<bool> ThrowIfOutOfMemory(); |
138 | 147 |
139 Isolate* const isolate_; | 148 Isolate* const isolate_; |
140 v8::ValueSerializer::Delegate* const delegate_; | 149 v8::ValueSerializer::Delegate* const delegate_; |
| 150 bool treat_array_buffer_views_as_host_objects_ = false; |
141 uint8_t* buffer_ = nullptr; | 151 uint8_t* buffer_ = nullptr; |
142 size_t buffer_size_ = 0; | 152 size_t buffer_size_ = 0; |
143 size_t buffer_capacity_ = 0; | 153 size_t buffer_capacity_ = 0; |
144 bool out_of_memory_ = false; | 154 bool out_of_memory_ = false; |
145 Zone zone_; | 155 Zone zone_; |
146 | 156 |
147 // To avoid extra lookups in the identity map, ID+1 is actually stored in the | 157 // To avoid extra lookups in the identity map, ID+1 is actually stored in the |
148 // map (checking if the used identity is zero is the fast way of checking if | 158 // map (checking if the used identity is zero is the fast way of checking if |
149 // the entry is new). | 159 // the entry is new). |
150 IdentityMap<uint32_t> id_map_; | 160 IdentityMap<uint32_t> id_map_; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 Handle<FixedArray> id_map_; | 290 Handle<FixedArray> id_map_; |
281 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; | 291 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; |
282 | 292 |
283 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); | 293 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
284 }; | 294 }; |
285 | 295 |
286 } // namespace internal | 296 } // namespace internal |
287 } // namespace v8 | 297 } // namespace v8 |
288 | 298 |
289 #endif // V8_VALUE_SERIALIZER_H_ | 299 #endif // V8_VALUE_SERIALIZER_H_ |
OLD | NEW |