OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 /** | 6 /** |
7 * This file defines the <code>PPB_Messaging</code> interface implemented | 7 * This file defines the <code>PPB_Messaging</code> interface implemented |
8 * by the browser for sending messages to DOM elements associated with a | 8 * by the browser for sending messages to DOM elements associated with a |
9 * specific module instance. | 9 * specific module instance. |
10 */ | 10 */ |
11 | 11 |
12 [generate_thunk] | 12 [generate_thunk] |
13 | 13 |
14 label Chrome { | 14 label Chrome { |
15 M14 = 1.0 | 15 M14 = 1.0, |
| 16 M36 = 1.1 |
16 }; | 17 }; |
17 | 18 |
18 /** | 19 /** |
19 * The <code>PPB_Messaging</code> interface is implemented by the browser | 20 * The <code>PPB_Messaging</code> interface is implemented by the browser |
20 * and is related to sending messages to JavaScript message event listeners on | 21 * and is related to sending messages to JavaScript message event listeners on |
21 * the DOM element associated with specific module instance. | 22 * the DOM element associated with specific module instance. |
22 */ | 23 */ |
| 24 [version=1.0] |
23 interface PPB_Messaging { | 25 interface PPB_Messaging { |
24 /** | 26 /** |
25 * PostMessage() asynchronously invokes any listeners for message events on | 27 * PostMessage() asynchronously invokes any listeners for message events on |
26 * the DOM element for the given module instance. A call to PostMessage() | 28 * the DOM element for the given module instance. A call to PostMessage() |
27 * will not block while the message is processed. | 29 * will not block while the message is processed. |
28 * | 30 * |
29 * @param[in] instance A <code>PP_Instance</code> identifying one instance | 31 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
30 * of a module. | 32 * of a module. |
31 * @param[in] message A <code>PP_Var</code> containing the data to be sent to | 33 * @param[in] message A <code>PP_Var</code> containing the data to be sent to |
32 * JavaScript. | 34 * JavaScript. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 * hello_world, | 77 * hello_world, |
76 * sizeof(hello_world)); | 78 * sizeof(hello_world)); |
77 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. | 79 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. |
78 * ppb_var_interface->Release(hello_var); | 80 * ppb_var_interface->Release(hello_var); |
79 * | 81 * |
80 * @endcode | 82 * @endcode |
81 * | 83 * |
82 * The browser will pop-up an alert saying "Hello world!" | 84 * The browser will pop-up an alert saying "Hello world!" |
83 */ | 85 */ |
84 void PostMessage([in] PP_Instance instance, [in] PP_Var message); | 86 void PostMessage([in] PP_Instance instance, [in] PP_Var message); |
| 87 |
| 88 /** |
| 89 * Call this to prepare to receive a blocking message from JavaScript. |
| 90 * When JavaScript invokes postMessageAndAwaitResponse(), the callback will |
| 91 * be invoked (or, if a blocking completion callback was used, |
| 92 * WaitForBlockingMessage will return). |
| 93 * |
| 94 * When the call completes, |message| will be a PP_Var containing a copy of |
| 95 * the data passed from JavaScript to postMessageAndAwaitResponse(). |
| 96 * |
| 97 * Upon receipt of the callback, the plugin must respond to the plugin by |
| 98 * calling RespondToBlockingMessage. The JavaScript invocation of |
| 99 * postMessageAndAwaitResponse will not return until the response is |
| 100 * received, so it is important to respond quickly. |
| 101 * |
| 102 * Invocations of WaitForBlockingMessage will fail if JavaScript is still |
| 103 * awaiting a response to a prior invocation of the callback. Therefore, the |
| 104 * plugin must always call RespondToBlockingMessage before calling |
| 105 * WaitForBlockingMessage again. |
| 106 * |
| 107 * Example usage: |
| 108 * void thread_func() { |
| 109 * while (!ShouldQuit()) { |
| 110 * PP_Var param = PP_MakeUndefined(); |
| 111 * WaitForBlockingMessage(pp_instance, ¶m, |
| 112 * PP_BlockUntilComplete()); |
| 113 * PP_Var response = ComputeSomething(param); |
| 114 * RespondToBlockingMessage(pp_instance, response); |
| 115 * var_if.Release(param); |
| 116 * var_if.Release(response); |
| 117 * } |
| 118 * } |
| 119 * |
| 120 * WaitForBlockingMessage will only work if called from a background thread. |
| 121 * If it is invoked from the main Pepper thread, the result will be |
| 122 * PP_ERROR_WRONG_THREAD. |
| 123 */ |
| 124 [version=1.1] |
| 125 int32_t WaitForBlockingMessage([in] PP_Instance instance, |
| 126 [out] PP_Var message, |
| 127 [in] PP_CompletionCallback callback); |
| 128 /** |
| 129 * Send a response to JavaScript. This only makes sense if JavaScript is |
| 130 * currently blocked on postMessagAndAwaitResponse. JavaScript's |
| 131 * postMessageAndAwaitResponse function will return a JavaScript value |
| 132 * representing a copy of |response|. |
| 133 */ |
| 134 [version=1.1] |
| 135 void RespondToBlockingMessage([in] PP_Instance instance, |
| 136 [in] PP_Var response); |
85 }; | 137 }; |
86 | 138 |
OLD | NEW |