Index: ppapi/c/ppb_messaging.h |
diff --git a/ppapi/c/ppb_messaging.h b/ppapi/c/ppb_messaging.h |
index 06e31205167eb495e54c51ebd5a9bafcb6c7731f..f80a3f1d1767f8cff3b058da403d727ecdc25c6f 100644 |
--- a/ppapi/c/ppb_messaging.h |
+++ b/ppapi/c/ppb_messaging.h |
@@ -3,19 +3,21 @@ |
* found in the LICENSE file. |
*/ |
-/* From ppb_messaging.idl modified Wed Jun 5 10:32:59 2013. */ |
+/* From ppb_messaging.idl modified Mon Apr 28 13:06:18 2014. */ |
#ifndef PPAPI_C_PPB_MESSAGING_H_ |
#define PPAPI_C_PPB_MESSAGING_H_ |
#include "ppapi/c/pp_bool.h" |
+#include "ppapi/c/pp_completion_callback.h" |
#include "ppapi/c/pp_instance.h" |
#include "ppapi/c/pp_macros.h" |
#include "ppapi/c/pp_stdint.h" |
#include "ppapi/c/pp_var.h" |
#define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0" |
-#define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_0 |
+#define PPB_MESSAGING_INTERFACE_1_1 "PPB_Messaging;1.1" |
+#define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_1 |
/** |
* @file |
@@ -34,7 +36,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_0 { |
+struct PPB_Messaging_1_1 { |
/** |
* PostMessage() asynchronously invokes any listeners for message events on |
* the DOM element for the given module instance. A call to PostMessage() |
@@ -96,9 +98,60 @@ struct PPB_Messaging_1_0 { |
* The browser will pop-up an alert saying "Hello world!" |
*/ |
void (*PostMessage)(PP_Instance instance, struct 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, ¶m, |
+ * 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. |
+ */ |
+ int32_t (*WaitForBlockingMessage)(PP_Instance instance, |
+ struct PP_Var* message, |
+ struct 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|. |
+ */ |
+ void (*RespondToBlockingMessage)(PP_Instance instance, |
+ struct PP_Var response); |
}; |
-typedef struct PPB_Messaging_1_0 PPB_Messaging; |
+typedef struct PPB_Messaging_1_1 PPB_Messaging; |
+ |
+struct PPB_Messaging_1_0 { |
+ void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
+}; |
/** |
* @} |
*/ |