Merge pull request #3070 from deepak1556/v8_value_converter_patch
nativemate: handle binary types in v8 value conversion
This commit is contained in:
commit
34d49441b1
2 changed files with 14 additions and 0 deletions
|
@ -152,6 +152,10 @@ v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
|
|||
return ToV8Object(isolate,
|
||||
static_cast<const base::DictionaryValue*>(value));
|
||||
|
||||
case base::Value::TYPE_BINARY:
|
||||
return ToArrayBuffer(isolate,
|
||||
static_cast<const base::BinaryValue*>(value));
|
||||
|
||||
default:
|
||||
LOG(ERROR) << "Unexpected value type: " << value->GetType();
|
||||
return v8::Null(isolate);
|
||||
|
@ -200,6 +204,13 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Object(
|
|||
return result.GetHandle();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> V8ValueConverter::ToArrayBuffer(
|
||||
v8::Isolate* isolate, const base::BinaryValue* value) const {
|
||||
return node::Buffer::Copy(isolate,
|
||||
value->GetBuffer(),
|
||||
value->GetSize()).ToLocalChecked();
|
||||
}
|
||||
|
||||
base::Value* V8ValueConverter::FromV8ValueImpl(
|
||||
FromV8ValueState* state,
|
||||
v8::Local<v8::Value> val,
|
||||
|
|
|
@ -41,6 +41,9 @@ class V8ValueConverter {
|
|||
v8::Local<v8::Value> ToV8Object(
|
||||
v8::Isolate* isolate,
|
||||
const base::DictionaryValue* dictionary) const;
|
||||
v8::Local<v8::Value> ToArrayBuffer(
|
||||
v8::Isolate* isolate,
|
||||
const base::BinaryValue* value) const;
|
||||
|
||||
base::Value* FromV8ValueImpl(FromV8ValueState* state,
|
||||
v8::Local<v8::Value> value,
|
||||
|
|
Loading…
Reference in a new issue