Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index fc63c2c3163c732bf90d9f24bb741c98eddc56dc..a22846e20a6ac0719c246f078729addd779d61da 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2847,6 +2847,15 @@ MaybeLocal<String> JSON::Stringify(Local<Context> context, |
// --- V a l u e S e r i a l i z a t i o n --- |
+Maybe<bool> ValueSerializer::Delegate::WriteHostObject(Isolate* v8_isolate, |
+ Local<Object> object) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ isolate->ScheduleThrow(*isolate->factory()->NewError( |
+ isolate->error_function(), i::MessageTemplate::kDataCloneError, |
+ Utils::OpenHandle(*object))); |
+ return Nothing<bool>(); |
+} |
+ |
struct ValueSerializer::PrivateData { |
explicit PrivateData(i::Isolate* i, ValueSerializer::Delegate* delegate) |
: isolate(i), serializer(i, delegate) {} |
@@ -2891,9 +2900,30 @@ void ValueSerializer::TransferSharedArrayBuffer( |
transfer_id, Utils::OpenHandle(*shared_array_buffer)); |
} |
+void ValueSerializer::WriteUint32(uint32_t value) { |
+ private_->serializer.WriteUint32(value); |
+} |
+ |
+void ValueSerializer::WriteUint64(uint64_t value) { |
+ private_->serializer.WriteUint64(value); |
+} |
+ |
+void ValueSerializer::WriteRawBytes(const void* source, size_t length) { |
+ private_->serializer.WriteRawBytes(source, length); |
+} |
+ |
+MaybeLocal<Object> ValueDeserializer::Delegate::ReadHostObject( |
+ Isolate* v8_isolate) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ isolate->ScheduleThrow(*isolate->factory()->NewError( |
+ isolate->error_function(), |
+ i::MessageTemplate::kDataCloneDeserializationError)); |
+ return MaybeLocal<Object>(); |
+} |
+ |
struct ValueDeserializer::PrivateData { |
- PrivateData(i::Isolate* i, i::Vector<const uint8_t> data) |
- : isolate(i), deserializer(i, data) {} |
+ PrivateData(i::Isolate* i, i::Vector<const uint8_t> data, Delegate* delegate) |
+ : isolate(i), deserializer(i, data, delegate) {} |
i::Isolate* isolate; |
i::ValueDeserializer deserializer; |
bool has_aborted = false; |
@@ -2901,14 +2931,18 @@ struct ValueDeserializer::PrivateData { |
}; |
ValueDeserializer::ValueDeserializer(Isolate* isolate, const uint8_t* data, |
- size_t size) { |
+ size_t size) |
+ : ValueDeserializer(isolate, data, size, nullptr) {} |
+ |
+ValueDeserializer::ValueDeserializer(Isolate* isolate, const uint8_t* data, |
+ size_t size, Delegate* delegate) { |
if (base::IsValueInRangeForNumericType<int>(size)) { |
- private_ = |
- new PrivateData(reinterpret_cast<i::Isolate*>(isolate), |
- i::Vector<const uint8_t>(data, static_cast<int>(size))); |
+ private_ = new PrivateData( |
+ reinterpret_cast<i::Isolate*>(isolate), |
+ i::Vector<const uint8_t>(data, static_cast<int>(size)), delegate); |
} else { |
private_ = new PrivateData(reinterpret_cast<i::Isolate*>(isolate), |
- i::Vector<const uint8_t>(nullptr, 0)); |
+ i::Vector<const uint8_t>(nullptr, 0), nullptr); |
private_->has_aborted = true; |
} |
} |
@@ -2990,6 +3024,18 @@ void ValueDeserializer::TransferSharedArrayBuffer( |
transfer_id, Utils::OpenHandle(*shared_array_buffer)); |
} |
+bool ValueDeserializer::ReadUint32(uint32_t* value) { |
+ return private_->deserializer.ReadUint32(value); |
+} |
+ |
+bool ValueDeserializer::ReadUint64(uint64_t* value) { |
+ return private_->deserializer.ReadUint64(value); |
+} |
+ |
+bool ValueDeserializer::ReadRawBytes(size_t length, const void** data) { |
+ return private_->deserializer.ReadRawBytes(length, data); |
+} |
+ |
// --- D a t a --- |
bool Value::FullIsUndefined() const { |