Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: content/child/v8_value_converter_impl.cc

Issue 2689673002: Inline base::BinaryValue into base::Value (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/v8_value_converter_impl.h ('k') | content/common/android/gin_java_bridge_value.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dd3678809a2f520193b172c53d17f54cb72a0e01..86554c33915beb1850a49f10781c027f097594e8 100644
--- a/content/child/v8_value_converter_impl.cc
+++ b/content/child/v8_value_converter_impl.cc
@@ -11,6 +11,7 @@
#include <memory>
#include <string>
#include <utility>
+#include <vector>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -268,9 +269,7 @@ v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
static_cast<const base::DictionaryValue*>(value));
case base::Value::Type::BINARY:
- return ToArrayBuffer(isolate,
- creation_context,
- static_cast<const base::BinaryValue*>(value));
+ return ToArrayBuffer(isolate, creation_context, value);
default:
LOG(ERROR) << "Unexpected value type: " << value->GetType();
@@ -501,9 +500,9 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8ArrayBuffer(
} 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);
+ std::vector<char> buffer(byte_length);
+ view->CopyContents(buffer.data(), buffer.size());
+ return base::MakeUnique<base::BinaryValue>(std::move(buffer));
} else {
NOTREACHED() << "Only ArrayBuffer and ArrayBufferView should get here.";
return nullptr;
« no previous file with comments | « content/child/v8_value_converter_impl.h ('k') | content/common/android/gin_java_bridge_value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698