Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index fc63c2c3163c732bf90d9f24bb741c98eddc56dc..752a78dfd61fd263a9e335dbcc74d5b2e2bd6ed7 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -2847,6 +2847,14 @@ 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(Local<Object> object) { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(Isolate::GetCurrent()); |
|
Jakob Kummerow
2016/09/14 01:09:20
AFAIK Isolate::GetCurrent() is deprecated and new
jbroman
2016/09/14 14:58:43
OK, done. In practice the delegate will already ha
|
| + isolate->Throw(*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 +2899,29 @@ 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() { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(Isolate::GetCurrent()); |
|
Jakob Kummerow
2016/09/14 01:09:20
same here.
jbroman
2016/09/14 14:58:43
Done.
|
| + isolate->Throw(*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 +2929,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 +3022,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 { |