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 /* From ppb_messaging.idl modified Wed Jun 5 10:32:59 2013. */ | 6 /* From ppb_messaging.idl modified Mon Jun 2 11:00:28 2014. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_MESSAGING_H_ | 8 #ifndef PPAPI_C_PPB_MESSAGING_H_ |
9 #define PPAPI_C_PPB_MESSAGING_H_ | 9 #define PPAPI_C_PPB_MESSAGING_H_ |
10 | 10 |
11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
12 #include "ppapi/c/pp_instance.h" | 12 #include "ppapi/c/pp_instance.h" |
13 #include "ppapi/c/pp_macros.h" | 13 #include "ppapi/c/pp_macros.h" |
| 14 #include "ppapi/c/pp_resource.h" |
14 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
15 #include "ppapi/c/pp_var.h" | 16 #include "ppapi/c/pp_var.h" |
| 17 #include "ppapi/c/ppp_message_handler.h" |
16 | 18 |
17 #define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0" | 19 #define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0" |
| 20 #define PPB_MESSAGING_INTERFACE_1_1 "PPB_Messaging;1.1" /* dev */ |
18 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_0 | 21 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_0 |
19 | 22 |
20 /** | 23 /** |
21 * @file | 24 * @file |
22 * This file defines the <code>PPB_Messaging</code> interface implemented | 25 * This file defines the <code>PPB_Messaging</code> interface implemented |
23 * by the browser for sending messages to DOM elements associated with a | 26 * by the browser for sending messages to DOM elements associated with a |
24 * specific module instance. | 27 * specific module instance. |
25 */ | 28 */ |
26 | 29 |
27 | 30 |
28 /** | 31 /** |
29 * @addtogroup Interfaces | 32 * @addtogroup Interfaces |
30 * @{ | 33 * @{ |
31 */ | 34 */ |
32 /** | 35 /** |
33 * The <code>PPB_Messaging</code> interface is implemented by the browser | 36 * The <code>PPB_Messaging</code> interface is implemented by the browser |
34 * and is related to sending messages to JavaScript message event listeners on | 37 * and is related to sending messages to JavaScript message event listeners on |
35 * the DOM element associated with specific module instance. | 38 * the DOM element associated with specific module instance. |
36 */ | 39 */ |
37 struct PPB_Messaging_1_0 { | 40 struct PPB_Messaging_1_1 { /* dev */ |
38 /** | 41 /** |
39 * PostMessage() asynchronously invokes any listeners for message events on | 42 * PostMessage() asynchronously invokes any listeners for message events on |
40 * the DOM element for the given module instance. A call to PostMessage() | 43 * the DOM element for the given module instance. A call to PostMessage() |
41 * will not block while the message is processed. | 44 * will not block while the message is processed. |
42 * | 45 * |
43 * @param[in] instance A <code>PP_Instance</code> identifying one instance | 46 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
44 * of a module. | 47 * of a module. |
45 * @param[in] message A <code>PP_Var</code> containing the data to be sent to | 48 * @param[in] message A <code>PP_Var</code> containing the data to be sent to |
46 * JavaScript. | 49 * JavaScript. |
47 * <code>message</code> can be any <code>PP_Var</code> type except | 50 * <code>message</code> can be any <code>PP_Var</code> type except |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 * hello_world, | 92 * hello_world, |
90 * sizeof(hello_world)); | 93 * sizeof(hello_world)); |
91 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. | 94 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. |
92 * ppb_var_interface->Release(hello_var); | 95 * ppb_var_interface->Release(hello_var); |
93 * | 96 * |
94 * @endcode | 97 * @endcode |
95 * | 98 * |
96 * The browser will pop-up an alert saying "Hello world!" | 99 * The browser will pop-up an alert saying "Hello world!" |
97 */ | 100 */ |
98 void (*PostMessage)(PP_Instance instance, struct PP_Var message); | 101 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
| 102 /** |
| 103 * <strong>Note:</strong> This function is not yet implemented. Please use |
| 104 * PPB_Messaging_1_0. |
| 105 * |
| 106 * Registers a handler for receiving messages from JavaScript. If a handler |
| 107 * is registered this way, it will replace PPP_Messaging, and all messages |
| 108 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will |
| 109 * be dispatched to <code>handler</code>. |
| 110 * |
| 111 * The function calls will be dispatched via <code>message_loop</code>. This |
| 112 * means that the functions will be invoked on the thread to which |
| 113 * <code>message_loop</code> is attached, when <code>message_loop</code> is |
| 114 * run. It is illegal to pass the main thread message loop; |
| 115 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. |
| 116 * |
| 117 * Attempting to register a message handler when one is already registered |
| 118 * will cause the current MessageHandler to be unregistered and replaced. In |
| 119 * that case, no messages will be sent to the "default" message handler |
| 120 * (PPP_Messaging). Messages will stop arriving at the prior message handler |
| 121 * and will begin to be dispatched at the new message handler. |
| 122 * |
| 123 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 124 * of a module. |
| 125 * @param[in] user_data A pointer the plugin may choose to use when handling |
| 126 * calls to functions within PPP_MessageHandler. The browser will pass this |
| 127 * same pointer when invoking functions within PPP_MessageHandler. |
| 128 * @param[in] handler The plugin-provided set of functions for handling |
| 129 * messages. |
| 130 * @param[in] message_loop Represents the message loop on which |
| 131 * PPP_MessageHandler functions should be invoked. |
| 132 * @return PP_OK on success, or an error from pp_errors.h. |
| 133 */ |
| 134 int32_t (*RegisterMessageHandler)( |
| 135 PP_Instance instance, |
| 136 void* user_data, |
| 137 const struct PPP_MessageHandler_0_1* handler, |
| 138 PP_Resource message_loop); |
| 139 /** |
| 140 * <strong>Note:</strong> This function is not yet implemented. Please use |
| 141 * PPB_Messaging_1_0. |
| 142 * |
| 143 * Unregisters the current message handler for <code>instance</code> if one |
| 144 * is registered. After this call, the message handler (if one was |
| 145 * registered) will have "Destroy" called on it and will receive no further |
| 146 * messages after that point. After that point, all messages sent from |
| 147 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if |
| 148 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call |
| 149 * postMessageAndAwaitResponse() from JavaScript will fail. |
| 150 * |
| 151 * Attempting to unregister a message handler when none is registered has no |
| 152 * effect. |
| 153 * |
| 154 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 155 * of a module. |
| 156 */ |
| 157 void (*UnregisterMessageHandler)(PP_Instance instance); |
| 158 }; |
| 159 |
| 160 struct PPB_Messaging_1_0 { |
| 161 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
99 }; | 162 }; |
100 | 163 |
101 typedef struct PPB_Messaging_1_0 PPB_Messaging; | 164 typedef struct PPB_Messaging_1_0 PPB_Messaging; |
102 /** | 165 /** |
103 * @} | 166 * @} |
104 */ | 167 */ |
105 | 168 |
106 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ | 169 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ |
107 | 170 |
OLD | NEW |