Index: content/renderer/pepper/message_channel.cc |
diff --git a/content/renderer/pepper/message_channel.cc b/content/renderer/pepper/message_channel.cc |
index 527229dee71e315a339d6daf759a27290f022a7d..1a4e6383b524f9bd4a3b805b14aec4adf8b0d328 100644 |
--- a/content/renderer/pepper/message_channel.cc |
+++ b/content/renderer/pepper/message_channel.cc |
@@ -15,7 +15,6 @@ |
#include "content/renderer/pepper/pepper_try_catch.h" |
#include "content/renderer/pepper/plugin_module.h" |
#include "content/renderer/pepper/plugin_object.h" |
-#include "content/renderer/pepper/v8_var_converter.h" |
#include "gin/arguments.h" |
#include "gin/converter.h" |
#include "gin/function_template.h" |
@@ -122,8 +121,7 @@ void MessageChannel::PostMessageToJavaScript(PP_Var message_data) { |
v8::Context::Scope context_scope(context); |
v8::Handle<v8::Value> v8_val; |
- if (!V8VarConverter(instance_->pp_instance()) |
- .ToV8Value(message_data, context, &v8_val)) { |
+ if (!var_converter_.ToV8Value(message_data, context, &v8_val)) { |
PpapiGlobals::Get()->LogWithSource(instance_->pp_instance(), |
PP_LOGLEVEL_ERROR, |
std::string(), |
@@ -187,6 +185,8 @@ MessageChannel::MessageChannel(PepperPluginInstanceImpl* instance) |
js_message_queue_state_(WAITING_TO_START), |
blocking_message_depth_(0), |
plugin_message_queue_state_(WAITING_TO_START), |
+ var_converter_(instance->pp_instance(), |
+ V8VarConverter::kDisallowObjectVars), |
weak_ptr_factory_(this) { |
} |
@@ -214,8 +214,7 @@ v8::Local<v8::Value> MessageChannel::GetNamedProperty( |
if (!instance_) |
return v8::Local<v8::Value>(); |
- PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars, |
- isolate); |
+ PepperTryCatchV8 try_catch(instance_, &var_converter_, isolate); |
if (identifier == kPostMessage) { |
return gin::CreateFunctionTemplate(isolate, |
base::Bind(&MessageChannel::PostMessageToNative, |
@@ -246,8 +245,7 @@ bool MessageChannel::SetNamedProperty(v8::Isolate* isolate, |
v8::Local<v8::Value> value) { |
if (!instance_) |
return false; |
- PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars, |
- isolate); |
+ PepperTryCatchV8 try_catch(instance_, &var_converter_, isolate); |
if (identifier == kPostMessage || |
identifier == kPostMessageAndAwaitResponse) { |
try_catch.ThrowException("Cannot set properties with the name postMessage" |
@@ -296,8 +294,7 @@ void MessageChannel::PostMessageToNative(gin::Arguments* args) { |
void MessageChannel::PostBlockingMessageToNative(gin::Arguments* args) { |
if (!instance_) |
return; |
- PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars, |
- args->isolate()); |
+ PepperTryCatchV8 try_catch(instance_, &var_converter_, args->isolate()); |
if (args->Length() != 1) { |
try_catch.ThrowException( |
"postMessageAndAwaitResponse requires one argument"); |
@@ -391,14 +388,13 @@ PluginObject* MessageChannel::GetPluginObject(v8::Isolate* isolate) { |
void MessageChannel::EnqueuePluginMessage(v8::Handle<v8::Value> v8_value) { |
plugin_message_queue_.push_back(VarConversionResult()); |
- // Convert NPVariantType_Object in to an appropriate PP_Var like Dictionary, |
- // Array, etc. Note NPVariantToVar would convert to an "Object" PP_Var, |
- // which we don't support for Messaging. |
+ // Convert the v8 value in to an appropriate PP_Var like Dictionary, |
+ // Array, etc. (We explicitly don't want an "Object" PP_Var, which we don't |
+ // support for Messaging.) |
// TODO(raymes): Possibly change this to use TryCatch to do the conversion and |
// throw an exception if necessary. |
- V8VarConverter v8_var_converter(instance_->pp_instance()); |
V8VarConverter::VarResult conversion_result = |
- v8_var_converter.FromV8Value( |
+ var_converter_.FromV8Value( |
v8_value, |
v8::Isolate::GetCurrent()->GetCurrentContext(), |
base::Bind(&MessageChannel::FromV8ValueComplete, |