Commit 9be4c268 authored by dmichael's avatar dmichael Committed by Commit bot

PPAPI: Move PPB_Messaging 1.2 to stable

This adds postMessageAndAwaitResponse() support to Pepper stable.

Open issues:
1) This is arguably an expansion on what JavaScript can do today. In particular,
it would be possible to make JavaScript block on PNaCl, which blocks on another
thread, which blocks on something like synchronous FileIO.
2) Not all types are supported yet; e.g. FileRef and FileSystem. I want to fix
that prior to M39. (see https://code.google.com/p/chromium/codesearch#chromium/src/content/renderer/pepper/message_channel.cc&l=305)

BUG=367896

Review URL: https://codereview.chromium.org/600893002

Cr-Commit-Position: refs/heads/master@{#297026}
parent 5a32aaf0
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "content/public/common/content_client.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/pepper/host_array_buffer_var.h" #include "content/renderer/pepper/host_array_buffer_var.h"
#include "content/renderer/pepper/pepper_plugin_instance_impl.h" #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/pepper_try_catch.h" #include "content/renderer/pepper/pepper_try_catch.h"
...@@ -63,10 +61,6 @@ const char kVarToV8ConversionError[] = ...@@ -63,10 +61,6 @@ const char kVarToV8ConversionError[] =
"argument from a PP_Var to a Javascript value. It may have cycles or be of " "argument from a PP_Var to a Javascript value. It may have cycles or be of "
"an unsupported type."; "an unsupported type.";
bool HasDevPermission() {
return GetContentClient()->renderer()->IsPluginAllowedToUseDevChannelAPIs();
}
} // namespace } // namespace
// MessageChannel -------------------------------------------------------------- // MessageChannel --------------------------------------------------------------
...@@ -227,7 +221,7 @@ v8::Local<v8::Value> MessageChannel::GetNamedProperty( ...@@ -227,7 +221,7 @@ v8::Local<v8::Value> MessageChannel::GetNamedProperty(
return gin::CreateFunctionTemplate(isolate, return gin::CreateFunctionTemplate(isolate,
base::Bind(&MessageChannel::PostMessageToNative, base::Bind(&MessageChannel::PostMessageToNative,
weak_ptr_factory_.GetWeakPtr()))->GetFunction(); weak_ptr_factory_.GetWeakPtr()))->GetFunction();
} else if (identifier == kPostMessageAndAwaitResponse && HasDevPermission()) { } else if (identifier == kPostMessageAndAwaitResponse) {
return gin::CreateFunctionTemplate(isolate, return gin::CreateFunctionTemplate(isolate,
base::Bind(&MessageChannel::PostBlockingMessageToNative, base::Bind(&MessageChannel::PostBlockingMessageToNative,
weak_ptr_factory_.GetWeakPtr()))->GetFunction(); weak_ptr_factory_.GetWeakPtr()))->GetFunction();
...@@ -256,7 +250,7 @@ bool MessageChannel::SetNamedProperty(v8::Isolate* isolate, ...@@ -256,7 +250,7 @@ bool MessageChannel::SetNamedProperty(v8::Isolate* isolate,
PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars, PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars,
isolate); isolate);
if (identifier == kPostMessage || if (identifier == kPostMessage ||
(identifier == kPostMessageAndAwaitResponse && HasDevPermission())) { (identifier == kPostMessageAndAwaitResponse)) {
try_catch.ThrowException("Cannot set properties with the name postMessage" try_catch.ThrowException("Cannot set properties with the name postMessage"
"or postMessageAndAwaitResponse"); "or postMessageAndAwaitResponse");
return true; return true;
...@@ -276,8 +270,7 @@ std::vector<std::string> MessageChannel::EnumerateNamedProperties( ...@@ -276,8 +270,7 @@ std::vector<std::string> MessageChannel::EnumerateNamedProperties(
if (plugin_object) if (plugin_object)
result = plugin_object->EnumerateNamedProperties(isolate); result = plugin_object->EnumerateNamedProperties(isolate);
result.push_back(kPostMessage); result.push_back(kPostMessage);
if (HasDevPermission()) result.push_back(kPostMessageAndAwaitResponse);
result.push_back(kPostMessageAndAwaitResponse);
return result; return result;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
label Chrome { label Chrome {
M14 = 1.0, M14 = 1.0,
[channel=dev] M39 = 1.2 M39 = 1.2
}; };
/** /**
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
*/ */
label Chrome { label Chrome {
[channel=dev] M39 = 0.2 M39 = 0.2
}; };
/** /**
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
/* From ppb_messaging.idl modified Wed Sep 10 15:41:14 2014. */ /* From ppb_messaging.idl modified Wed Sep 24 10:48:37 2014. */
#ifndef PPAPI_C_PPB_MESSAGING_H_ #ifndef PPAPI_C_PPB_MESSAGING_H_
#define PPAPI_C_PPB_MESSAGING_H_ #define PPAPI_C_PPB_MESSAGING_H_
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "ppapi/c/ppp_message_handler.h" #include "ppapi/c/ppp_message_handler.h"
#define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0" #define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0"
#define PPB_MESSAGING_INTERFACE_1_2 "PPB_Messaging;1.2" /* dev */ #define PPB_MESSAGING_INTERFACE_1_2 "PPB_Messaging;1.2"
#define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_0 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_2
/** /**
* @file * @file
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* and is related to sending messages to JavaScript message event listeners on * and is related to sending messages to JavaScript message event listeners on
* the DOM element associated with specific module instance. * the DOM element associated with specific module instance.
*/ */
struct PPB_Messaging_1_2 { /* dev */ struct PPB_Messaging_1_2 {
/** /**
* PostMessage() asynchronously invokes any listeners for message events on * PostMessage() asynchronously invokes any listeners for message events on
* the DOM element for the given module instance. A call to PostMessage() * the DOM element for the given module instance. A call to PostMessage()
...@@ -157,11 +157,11 @@ struct PPB_Messaging_1_2 { /* dev */ ...@@ -157,11 +157,11 @@ struct PPB_Messaging_1_2 { /* dev */
void (*UnregisterMessageHandler)(PP_Instance instance); void (*UnregisterMessageHandler)(PP_Instance instance);
}; };
typedef struct PPB_Messaging_1_2 PPB_Messaging;
struct PPB_Messaging_1_0 { struct PPB_Messaging_1_0 {
void (*PostMessage)(PP_Instance instance, struct PP_Var message); void (*PostMessage)(PP_Instance instance, struct PP_Var message);
}; };
typedef struct PPB_Messaging_1_0 PPB_Messaging;
/** /**
* @} * @}
*/ */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
/* From ppp_message_handler.idl modified Wed Sep 17 16:54:35 2014. */ /* From ppp_message_handler.idl modified Wed Sep 24 10:48:49 2014. */
#ifndef PPAPI_C_PPP_MESSAGE_HANDLER_H_ #ifndef PPAPI_C_PPP_MESSAGE_HANDLER_H_
#define PPAPI_C_PPP_MESSAGE_HANDLER_H_ #define PPAPI_C_PPP_MESSAGE_HANDLER_H_
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
* This interface struct should not be returned by PPP_GetInterface; instead it * This interface struct should not be returned by PPP_GetInterface; instead it
* must be passed as a parameter to PPB_Messaging::RegisterMessageHandler. * must be passed as a parameter to PPB_Messaging::RegisterMessageHandler.
*/ */
struct PPP_MessageHandler_0_2 { /* dev */ struct PPP_MessageHandler_0_2 {
/** /**
* Invoked as a result of JavaScript invoking postMessage() on the plugin's * Invoked as a result of JavaScript invoking postMessage() on the plugin's
* DOM element. * DOM element.
...@@ -86,6 +86,8 @@ struct PPP_MessageHandler_0_2 { /* dev */ ...@@ -86,6 +86,8 @@ struct PPP_MessageHandler_0_2 { /* dev */
*/ */
void (*Destroy)(PP_Instance instance, void* user_data); void (*Destroy)(PP_Instance instance, void* user_data);
}; };
typedef struct PPP_MessageHandler_0_2 PPP_MessageHandler;
/** /**
* @} * @}
*/ */
......
...@@ -13,7 +13,6 @@ PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_1, PPB_CompositorLayer_0_1) ...@@ -13,7 +13,6 @@ PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_1, PPB_CompositorLayer_0_1)
PROXIED_IFACE(PPB_FILEMAPPING_INTERFACE_0_1, PPB_FileMapping_0_1) PROXIED_IFACE(PPB_FILEMAPPING_INTERFACE_0_1, PPB_FileMapping_0_1)
PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_1_DEPRECATED, PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_1_DEPRECATED,
PPB_Messaging_1_1_Deprecated) PPB_Messaging_1_1_Deprecated)
PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_2, PPB_Messaging_1_2)
PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1) PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1)
// Note, PPB_TraceEvent is special. We don't want to actually make it stable, // Note, PPB_TraceEvent is special. We don't want to actually make it stable,
......
...@@ -77,6 +77,7 @@ PROXIED_IFACE(PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1, ...@@ -77,6 +77,7 @@ PROXIED_IFACE(PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1,
PROXIED_IFACE(PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1, PROXIED_IFACE(PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1,
PPB_MediaStreamVideoTrack_0_1) PPB_MediaStreamVideoTrack_0_1)
PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_0, PPB_Messaging_1_0) PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_0, PPB_Messaging_1_0)
PROXIED_IFACE(PPB_MESSAGING_INTERFACE_1_2, PPB_Messaging_1_2)
PROXIED_IFACE(PPB_MOUSECURSOR_INTERFACE_1_0, PPB_MouseCursor_1_0) PROXIED_IFACE(PPB_MOUSECURSOR_INTERFACE_1_0, PPB_MouseCursor_1_0)
PROXIED_IFACE(PPB_MOUSELOCK_INTERFACE_1_0, PPB_MouseLock_1_0) PROXIED_IFACE(PPB_MOUSELOCK_INTERFACE_1_0, PPB_MouseLock_1_0)
PROXIED_IFACE(PPB_NETADDRESS_INTERFACE_1_0, PPB_NetAddress_1_0) PROXIED_IFACE(PPB_NETADDRESS_INTERFACE_1_0, PPB_NetAddress_1_0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment