Chromium Code Reviews| Index: content/child/v8_value_converter_impl.cc |
| diff --git a/content/child/v8_value_converter_impl.cc b/content/child/v8_value_converter_impl.cc |
| index 5dcf63608cd31a9360fda74eb54bed1c2f0cb166..67e4200027ce6b01cad6314949dbda61f4580eed 100644 |
| --- a/content/child/v8_value_converter_impl.cc |
| +++ b/content/child/v8_value_converter_impl.cc |
| @@ -17,9 +17,6 @@ |
| #include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/values.h" |
| -#include "third_party/WebKit/public/web/WebArrayBuffer.h" |
| -#include "third_party/WebKit/public/web/WebArrayBufferConverter.h" |
| -#include "third_party/WebKit/public/web/WebArrayBufferView.h" |
| #include "v8/include/v8.h" |
| namespace content { |
| @@ -339,11 +336,11 @@ v8::Local<v8::Value> V8ValueConverterImpl::ToArrayBuffer( |
| v8::Isolate* isolate, |
| v8::Local<v8::Object> creation_context, |
| const base::BinaryValue* value) const { |
| - blink::WebArrayBuffer buffer = |
| - blink::WebArrayBuffer::create(value->GetSize(), 1); |
| - memcpy(buffer.data(), value->GetBuffer(), value->GetSize()); |
| - return blink::WebArrayBufferConverter::toV8Value( |
| - &buffer, creation_context, isolate); |
| + DCHECK(creation_context == isolate->GetCurrentContext()); |
|
jbroman
2017/02/07 23:22:03
This matches the DCHECK that already exists in Web
|
| + v8::Local<v8::ArrayBuffer> buffer = |
| + v8::ArrayBuffer::New(isolate, value->GetSize()); |
| + memcpy(buffer->GetContents().Data(), value->GetBuffer(), value->GetSize()); |
| + return buffer; |
| } |
| std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8ValueImpl( |
| @@ -497,27 +494,20 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8ArrayBuffer( |
| return out; |
| } |
| - char* data = NULL; |
| - size_t length = 0; |
| - |
| - std::unique_ptr<blink::WebArrayBuffer> array_buffer( |
| - blink::WebArrayBufferConverter::createFromV8Value(val, isolate)); |
| - std::unique_ptr<blink::WebArrayBufferView> view; |
| - if (array_buffer) { |
| - data = reinterpret_cast<char*>(array_buffer->data()); |
| - length = array_buffer->byteLength(); |
| + if (val->IsArrayBuffer()) { |
| + auto contents = val.As<v8::ArrayBuffer>()->GetContents(); |
| + return base::BinaryValue::CreateWithCopiedBuffer( |
| + static_cast<const char*>(contents.Data()), contents.ByteLength()); |
| + } else if (val->IsArrayBufferView()) { |
| + v8::Local<v8::ArrayBufferView> view = val.As<v8::ArrayBufferView>(); |
| + size_t byte_length = view->ByteLength(); |
| + auto buffer = base::MakeUnique<char[]>(byte_length); |
| + view->CopyContents(buffer.get(), byte_length); |
| + return base::MakeUnique<base::BinaryValue>(std::move(buffer), byte_length); |
| } else { |
| - view.reset(blink::WebArrayBufferView::createFromV8Value(val)); |
| - if (view) { |
| - data = reinterpret_cast<char*>(view->baseAddress()) + view->byteOffset(); |
| - length = view->byteLength(); |
| - } |
| - } |
| - |
| - if (data) |
| - return base::BinaryValue::CreateWithCopiedBuffer(data, length); |
| - else |
| + NOTREACHED() << "Only ArrayBuffer and ArrayBufferView should get here."; |
| return nullptr; |
| + } |
| } |
| std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8Object( |