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 */ |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 * ppb_var_interface->Release(hello_var); | 79 * ppb_var_interface->Release(hello_var); |
80 * | 80 * |
81 * @endcode | 81 * @endcode |
82 * | 82 * |
83 * The browser will pop-up an alert saying "Hello world!" | 83 * The browser will pop-up an alert saying "Hello world!" |
84 */ | 84 */ |
85 [version=1.0] | 85 [version=1.0] |
86 void PostMessage([in] PP_Instance instance, [in] PP_Var message); | 86 void PostMessage([in] PP_Instance instance, [in] PP_Var message); |
87 | 87 |
88 /** | 88 /** |
89 * <strong>Note:</strong> This function is not yet implemented. Please use | |
90 * PPB_Messaging_1_0. | |
91 * | |
92 * Registers a handler for receiving messages from JavaScript. If a handler | 89 * Registers a handler for receiving messages from JavaScript. If a handler |
93 * is registered this way, it will replace PPP_Messaging, and all messages | 90 * is registered this way, it will replace PPP_Messaging, and all messages |
94 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will | 91 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will |
95 * be dispatched to <code>handler</code>. | 92 * be dispatched to <code>handler</code>. |
96 * | 93 * |
97 * The function calls will be dispatched via <code>message_loop</code>. This | 94 * The function calls will be dispatched via <code>message_loop</code>. This |
98 * means that the functions will be invoked on the thread to which | 95 * means that the functions will be invoked on the thread to which |
99 * <code>message_loop</code> is attached, when <code>message_loop</code> is | 96 * <code>message_loop</code> is attached, when <code>message_loop</code> is |
100 * run. It is illegal to pass the main thread message loop; | 97 * run. It is illegal to pass the main thread message loop; |
101 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. | 98 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. |
| 99 * If you quit <code>message_loop</code> before calling Unregister(), |
| 100 * the browser will not be able to call functions in the plugin's message |
| 101 * handler any more. That could mean missing some messages or could cause a |
| 102 * leak if you depend on Destroy() to free hander data. So you should, |
| 103 * whenever possible, Unregister() the handler prior to quitting its event |
| 104 * loop. |
102 * | 105 * |
103 * Attempting to register a message handler when one is already registered | 106 * Attempting to register a message handler when one is already registered |
104 * will cause the current MessageHandler to be unregistered and replaced. In | 107 * will cause the current MessageHandler to be unregistered and replaced. In |
105 * that case, no messages will be sent to the "default" message handler | 108 * that case, no messages will be sent to the "default" message handler |
106 * (PPP_Messaging). Messages will stop arriving at the prior message handler | 109 * (PPP_Messaging). Messages will stop arriving at the prior message handler |
107 * and will begin to be dispatched at the new message handler. | 110 * and will begin to be dispatched at the new message handler. |
108 * | 111 * |
109 * @param[in] instance A <code>PP_Instance</code> identifying one instance | 112 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
110 * of a module. | 113 * of a module. |
111 * @param[in] user_data A pointer the plugin may choose to use when handling | 114 * @param[in] user_data A pointer the plugin may choose to use when handling |
112 * calls to functions within PPP_MessageHandler. The browser will pass this | 115 * calls to functions within PPP_MessageHandler. The browser will pass this |
113 * same pointer when invoking functions within PPP_MessageHandler. | 116 * same pointer when invoking functions within PPP_MessageHandler. |
114 * @param[in] handler The plugin-provided set of functions for handling | 117 * @param[in] handler The plugin-provided set of functions for handling |
115 * messages. | 118 * messages. |
116 * @param[in] message_loop Represents the message loop on which | 119 * @param[in] message_loop Represents the message loop on which |
117 * PPP_MessageHandler functions should be invoked. | 120 * PPP_MessageHandler functions should be invoked. |
118 * @return PP_OK on success, or an error from pp_errors.h. | 121 * @return PP_OK on success, or an error from pp_errors.h. |
119 */ | 122 */ |
120 [version=1.1] | 123 [version=1.1] |
121 int32_t RegisterMessageHandler([in] PP_Instance instance, | 124 int32_t RegisterMessageHandler([in] PP_Instance instance, |
122 [inout] mem_t user_data, | 125 [inout] mem_t user_data, |
123 [in] PPP_MessageHandler handler, | 126 [in] PPP_MessageHandler handler, |
124 [in] PP_Resource message_loop); | 127 [in] PP_Resource message_loop); |
125 /** | 128 /** |
126 * <strong>Note:</strong> This function is not yet implemented. Please use | |
127 * PPB_Messaging_1_0. | |
128 * | |
129 * Unregisters the current message handler for <code>instance</code> if one | 129 * Unregisters the current message handler for <code>instance</code> if one |
130 * is registered. After this call, the message handler (if one was | 130 * is registered. After this call, the message handler (if one was |
131 * registered) will have "Destroy" called on it and will receive no further | 131 * registered) will have "Destroy" called on it and will receive no further |
132 * messages after that point. After that point, all messages sent from | 132 * messages after that point. After that point, all messages sent from |
133 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if | 133 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if |
134 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call | 134 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call |
135 * postMessageAndAwaitResponse() from JavaScript will fail. | 135 * postMessageAndAwaitResponse() from JavaScript will fail. |
136 * | 136 * |
137 * Attempting to unregister a message handler when none is registered has no | 137 * Attempting to unregister a message handler when none is registered has no |
138 * effect. | 138 * effect. |
139 * | 139 * |
140 * @param[in] instance A <code>PP_Instance</code> identifying one instance | 140 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
141 * of a module. | 141 * of a module. |
142 */ | 142 */ |
143 [version=1.1] | 143 [version=1.1] |
144 void UnregisterMessageHandler([in] PP_Instance instance); | 144 void UnregisterMessageHandler([in] PP_Instance instance); |
145 }; | 145 }; |
146 | 146 |
OLD | NEW |