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

Unified Diff: ppapi/api/ppb_messaging.idl

Issue 253813006: PPAPI: Synchronous postMessage proposal #1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « no previous file | ppapi/c/pp_macros.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/api/ppb_messaging.idl
diff --git a/ppapi/api/ppb_messaging.idl b/ppapi/api/ppb_messaging.idl
index 0f9a3aa8c2bbeb49c2341179e49771534a01a5a5..4008d730c4b55b6f0a671c7d6a307775a9ef4941 100644
--- a/ppapi/api/ppb_messaging.idl
+++ b/ppapi/api/ppb_messaging.idl
@@ -12,7 +12,8 @@
[generate_thunk]
label Chrome {
- M14 = 1.0
+ M14 = 1.0,
+ M36 = 1.1
};
/**
@@ -20,6 +21,7 @@ label Chrome {
* and is related to sending messages to JavaScript message event listeners on
* the DOM element associated with specific module instance.
*/
+[version=1.0]
interface PPB_Messaging {
/**
* PostMessage() asynchronously invokes any listeners for message events on
@@ -82,5 +84,55 @@ interface PPB_Messaging {
* The browser will pop-up an alert saying "Hello world!"
*/
void PostMessage([in] PP_Instance instance, [in] PP_Var message);
+
+ /**
+ * Call this to prepare to receive a blocking message from JavaScript.
+ * When JavaScript invokes postMessageAndAwaitResponse(), the callback will
+ * be invoked (or, if a blocking completion callback was used,
+ * WaitForBlockingMessage will return).
+ *
+ * When the call completes, |message| will be a PP_Var containing a copy of
+ * the data passed from JavaScript to postMessageAndAwaitResponse().
+ *
+ * Upon receipt of the callback, the plugin must respond to the plugin by
+ * calling RespondToBlockingMessage. The JavaScript invocation of
+ * postMessageAndAwaitResponse will not return until the response is
+ * received, so it is important to respond quickly.
+ *
+ * Invocations of WaitForBlockingMessage will fail if JavaScript is still
+ * awaiting a response to a prior invocation of the callback. Therefore, the
+ * plugin must always call RespondToBlockingMessage before calling
+ * WaitForBlockingMessage again.
+ *
+ * Example usage:
+ * void thread_func() {
+ * while (!ShouldQuit()) {
+ * PP_Var param = PP_MakeUndefined();
+ * WaitForBlockingMessage(pp_instance, &param,
+ * PP_BlockUntilComplete());
+ * PP_Var response = ComputeSomething(param);
+ * RespondToBlockingMessage(pp_instance, response);
+ * var_if.Release(param);
+ * var_if.Release(response);
+ * }
+ * }
+ *
+ * WaitForBlockingMessage will only work if called from a background thread.
+ * If it is invoked from the main Pepper thread, the result will be
+ * PP_ERROR_WRONG_THREAD.
+ */
+ [version=1.1]
+ int32_t WaitForBlockingMessage([in] PP_Instance instance,
+ [out] PP_Var message,
+ [in] PP_CompletionCallback callback);
+ /**
+ * Send a response to JavaScript. This only makes sense if JavaScript is
+ * currently blocked on postMessagAndAwaitResponse. JavaScript's
+ * postMessageAndAwaitResponse function will return a JavaScript value
+ * representing a copy of |response|.
+ */
+ [version=1.1]
+ void RespondToBlockingMessage([in] PP_Instance instance,
+ [in] PP_Var response);
};
« no previous file with comments | « no previous file | ppapi/c/pp_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698