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

Unified Diff: content/renderer/v8_value_converter_impl.cc

Issue 301883002: Should provide creation context and isolate for WebArrayConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed bad coding style Created 6 years, 6 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/renderer/v8_value_converter_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/v8_value_converter_impl.cc
diff --git a/content/renderer/v8_value_converter_impl.cc b/content/renderer/v8_value_converter_impl.cc
index d12b26bdf07eb2383b0f5d92bcc0217d713f7f1b..2c222bd772a9e5e965ae4e8b38e3c32b385334db 100644
--- a/content/renderer/v8_value_converter_impl.cc
+++ b/content/renderer/v8_value_converter_impl.cc
@@ -153,7 +153,8 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value(
const base::Value* value, v8::Handle<v8::Context> context) const {
v8::Context::Scope context_scope(context);
v8::EscapableHandleScope handle_scope(context->GetIsolate());
- return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value));
+ return handle_scope.Escape(
+ ToV8ValueImpl(context->GetIsolate(), context->Global(), value));
}
base::Value* V8ValueConverterImpl::FromV8Value(
@@ -167,6 +168,7 @@ base::Value* V8ValueConverterImpl::FromV8Value(
v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
v8::Isolate* isolate,
+ v8::Handle<v8::Object> creation_context,
const base::Value* value) const {
CHECK(value);
switch (value->GetType()) {
@@ -199,14 +201,19 @@ v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
}
case base::Value::TYPE_LIST:
- return ToV8Array(isolate, static_cast<const base::ListValue*>(value));
+ return ToV8Array(isolate,
+ creation_context,
+ static_cast<const base::ListValue*>(value));
case base::Value::TYPE_DICTIONARY:
return ToV8Object(isolate,
+ creation_context,
static_cast<const base::DictionaryValue*>(value));
case base::Value::TYPE_BINARY:
- return ToArrayBuffer(static_cast<const base::BinaryValue*>(value));
+ return ToArrayBuffer(isolate,
+ creation_context,
+ static_cast<const base::BinaryValue*>(value));
default:
LOG(ERROR) << "Unexpected value type: " << value->GetType();
@@ -216,6 +223,7 @@ v8::Local<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
v8::Isolate* isolate,
+ v8::Handle<v8::Object> creation_context,
const base::ListValue* val) const {
v8::Handle<v8::Array> result(v8::Array::New(isolate, val->GetSize()));
@@ -223,7 +231,8 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
const base::Value* child = NULL;
CHECK(val->Get(i, &child));
- v8::Handle<v8::Value> child_v8 = ToV8ValueImpl(isolate, child);
+ v8::Handle<v8::Value> child_v8 =
+ ToV8ValueImpl(isolate, creation_context, child);
CHECK(!child_v8.IsEmpty());
v8::TryCatch try_catch;
@@ -237,13 +246,15 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object(
v8::Isolate* isolate,
+ v8::Handle<v8::Object> creation_context,
const base::DictionaryValue* val) const {
v8::Handle<v8::Object> result(v8::Object::New(isolate));
for (base::DictionaryValue::Iterator iter(*val);
!iter.IsAtEnd(); iter.Advance()) {
const std::string& key = iter.key();
- v8::Handle<v8::Value> child_v8 = ToV8ValueImpl(isolate, &iter.value());
+ v8::Handle<v8::Value> child_v8 =
+ ToV8ValueImpl(isolate, creation_context, &iter.value());
CHECK(!child_v8.IsEmpty());
v8::TryCatch try_catch;
@@ -261,11 +272,14 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object(
}
v8::Handle<v8::Value> V8ValueConverterImpl::ToArrayBuffer(
+ v8::Isolate* isolate,
+ v8::Handle<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);
+ return blink::WebArrayBufferConverter::toV8Value(
+ &buffer, creation_context, isolate);
}
base::Value* V8ValueConverterImpl::FromV8ValueImpl(
@@ -418,7 +432,7 @@ base::Value* V8ValueConverterImpl::FromV8ArrayBuffer(
size_t length = 0;
scoped_ptr<blink::WebArrayBuffer> array_buffer(
- blink::WebArrayBufferConverter::createFromV8Value(val));
+ blink::WebArrayBufferConverter::createFromV8Value(val, isolate));
scoped_ptr<blink::WebArrayBufferView> view;
if (array_buffer) {
data = reinterpret_cast<char*>(array_buffer->data());
« no previous file with comments | « content/renderer/v8_value_converter_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698