| Index: webkit/plugins/ppapi/message_channel.cc
|
| diff --git a/webkit/plugins/ppapi/message_channel.cc b/webkit/plugins/ppapi/message_channel.cc
|
| index 646b822201ca6e640262c3cd96ee892d2f8a82c3..44e6467a9f6eea8a9ccbfcf374359903f448c85b 100644
|
| --- a/webkit/plugins/ppapi/message_channel.cc
|
| +++ b/webkit/plugins/ppapi/message_channel.cc
|
| @@ -24,6 +24,7 @@
|
| #include "v8/include/v8.h"
|
| #include "webkit/plugins/ppapi/host_array_buffer_var.h"
|
| #include "webkit/plugins/ppapi/npapi_glue.h"
|
| +#include "webkit/plugins/ppapi/plugin_module.h"
|
| #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
|
|
|
| using ppapi::ArrayBufferVar;
|
| @@ -358,11 +359,17 @@ void MessageChannel::PostMessageToJavaScript(PP_Var message_data) {
|
| WebSerializedScriptValue serialized_val =
|
| WebSerializedScriptValue::serialize(v8_val);
|
|
|
| - MessageLoop::current()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&MessageChannel::PostMessageToJavaScriptImpl,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - serialized_val));
|
| + if (instance_->module()->IsProxied()) {
|
| + // The proxy sent an asynchronous message, so the plugin is already
|
| + // unblocked. Therefore, there's no need to PostTask.
|
| + PostMessageToJavaScriptImpl(serialized_val);
|
| + } else {
|
| + MessageLoop::current()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&MessageChannel::PostMessageToJavaScriptImpl,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + serialized_val));
|
| + }
|
| }
|
|
|
| void MessageChannel::PostMessageToJavaScriptImpl(
|
| @@ -398,13 +405,20 @@ void MessageChannel::PostMessageToJavaScriptImpl(
|
| }
|
|
|
| void MessageChannel::PostMessageToNative(PP_Var message_data) {
|
| - // Make a copy of the message data for the Task we will run.
|
| - PP_Var var_copy(CopyPPVar(message_data));
|
| + if (instance_->module()->IsProxied()) {
|
| + // In the proxied case, the copy will happen via serialization, and the
|
| + // message is asynchronous. Therefore there's no need to copy the Var, nor
|
| + // to PostTask.
|
| + PostMessageToNativeImpl(message_data);
|
| + } else {
|
| + // Make a copy of the message data for the Task we will run.
|
| + PP_Var var_copy(CopyPPVar(message_data));
|
|
|
| - MessageLoop::current()->PostTask(FROM_HERE,
|
| - base::Bind(&MessageChannel::PostMessageToNativeImpl,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - var_copy));
|
| + MessageLoop::current()->PostTask(FROM_HERE,
|
| + base::Bind(&MessageChannel::PostMessageToNativeImpl,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + var_copy));
|
| + }
|
| }
|
|
|
| void MessageChannel::PostMessageToNativeImpl(PP_Var message_data) {
|
|
|