Skip to content

Commit

Permalink
PPAPI: Move PPB_Messaging 1.2 to stable
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
davemichael authored and Commit bot committed Sep 26, 2014
1 parent 5a32aaf commit 9be4c26
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
13 changes: 3 additions & 10 deletions content/renderer/pepper/message_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "base/bind.h"
#include "base/logging.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/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/pepper_try_catch.h"
Expand Down Expand Up @@ -63,10 +61,6 @@ const char kVarToV8ConversionError[] =
"argument from a PP_Var to a Javascript value. It may have cycles or be of "
"an unsupported type.";

bool HasDevPermission() {
return GetContentClient()->renderer()->IsPluginAllowedToUseDevChannelAPIs();
}

} // namespace

// MessageChannel --------------------------------------------------------------
Expand Down Expand Up @@ -227,7 +221,7 @@ v8::Local<v8::Value> MessageChannel::GetNamedProperty(
return gin::CreateFunctionTemplate(isolate,
base::Bind(&MessageChannel::PostMessageToNative,
weak_ptr_factory_.GetWeakPtr()))->GetFunction();
} else if (identifier == kPostMessageAndAwaitResponse && HasDevPermission()) {
} else if (identifier == kPostMessageAndAwaitResponse) {
return gin::CreateFunctionTemplate(isolate,
base::Bind(&MessageChannel::PostBlockingMessageToNative,
weak_ptr_factory_.GetWeakPtr()))->GetFunction();
Expand Down Expand Up @@ -256,7 +250,7 @@ bool MessageChannel::SetNamedProperty(v8::Isolate* isolate,
PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars,
isolate);
if (identifier == kPostMessage ||
(identifier == kPostMessageAndAwaitResponse && HasDevPermission())) {
(identifier == kPostMessageAndAwaitResponse)) {
try_catch.ThrowException("Cannot set properties with the name postMessage"
"or postMessageAndAwaitResponse");
return true;
Expand All @@ -276,8 +270,7 @@ std::vector<std::string> MessageChannel::EnumerateNamedProperties(
if (plugin_object)
result = plugin_object->EnumerateNamedProperties(isolate);
result.push_back(kPostMessage);
if (HasDevPermission())
result.push_back(kPostMessageAndAwaitResponse);
result.push_back(kPostMessageAndAwaitResponse);
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion ppapi/api/ppb_messaging.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

label Chrome {
M14 = 1.0,
[channel=dev] M39 = 1.2
M39 = 1.2
};

/**
Expand Down
2 changes: 1 addition & 1 deletion ppapi/api/ppp_message_handler.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

label Chrome {
[channel=dev] M39 = 0.2
M39 = 0.2
};

/**
Expand Down
12 changes: 6 additions & 6 deletions ppapi/c/ppb_messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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_
#define PPAPI_C_PPB_MESSAGING_H_
Expand All @@ -17,8 +17,8 @@
#include "ppapi/c/ppp_message_handler.h"

#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 PPB_MESSAGING_INTERFACE_1_0
#define PPB_MESSAGING_INTERFACE_1_2 "PPB_Messaging;1.2"
#define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_2

/**
* @file
Expand All @@ -37,7 +37,7 @@
* and is related to sending messages to JavaScript message event listeners on
* 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
* the DOM element for the given module instance. A call to PostMessage()
Expand Down Expand Up @@ -157,11 +157,11 @@ struct PPB_Messaging_1_2 { /* dev */
void (*UnregisterMessageHandler)(PP_Instance instance);
};

typedef struct PPB_Messaging_1_2 PPB_Messaging;

struct PPB_Messaging_1_0 {
void (*PostMessage)(PP_Instance instance, struct PP_Var message);
};

typedef struct PPB_Messaging_1_0 PPB_Messaging;
/**
* @}
*/
Expand Down
6 changes: 4 additions & 2 deletions ppapi/c/ppp_message_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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_
#define PPAPI_C_PPP_MESSAGE_HANDLER_H_
Expand Down Expand Up @@ -36,7 +36,7 @@
* This interface struct should not be returned by PPP_GetInterface; instead it
* 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
* DOM element.
Expand Down Expand Up @@ -86,6 +86,8 @@ struct PPP_MessageHandler_0_2 { /* dev */
*/
void (*Destroy)(PP_Instance instance, void* user_data);
};

typedef struct PPP_MessageHandler_0_2 PPP_MessageHandler;
/**
* @}
*/
Expand Down
1 change: 0 additions & 1 deletion ppapi/thunk/interfaces_ppb_public_dev_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_MESSAGING_INTERFACE_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)

// Note, PPB_TraceEvent is special. We don't want to actually make it stable,
Expand Down
1 change: 1 addition & 0 deletions ppapi/thunk/interfaces_ppb_public_stable.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ PROXIED_IFACE(PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1,
PROXIED_IFACE(PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1,
PPB_MediaStreamVideoTrack_0_1)
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_MOUSELOCK_INTERFACE_1_0, PPB_MouseLock_1_0)
PROXIED_IFACE(PPB_NETADDRESS_INTERFACE_1_0, PPB_NetAddress_1_0)
Expand Down

0 comments on commit 9be4c26

Please sign in to comment.