| 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 Thu May 1 11:32:17 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 * Registers a handler for receiving messages from JavaScript. If a handler |
| 104 * is registered this way, it will replace PPP_Messaging, and all messages |
| 105 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will |
| 106 * be dispatched to <code>handler</code>. |
| 107 * |
| 108 * The function calls will be dispatched via <code>message_loop</code>. This |
| 109 * means that the functions will be invoked on the thread to which |
| 110 * <code>message_loop</code> is attached, when <code>message_loop</code> is |
| 111 * run. It is illegal to pass the main thread message loop; |
| 112 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. |
| 113 * |
| 114 * Attempting to register a message handler when one is already registered |
| 115 * will cause the current MessageHandler to be unregistered and replaced. In |
| 116 * that case, no messages will be sent to the "default" message handler |
| 117 * (PPP_Messaging). Messages will stop arriving at the prior message handler |
| 118 * and will begin to be dispatched at the new message handler. |
| 119 * |
| 120 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 121 * of a module. |
| 122 * @param[in] user_data A pointer the plugin may choose to use when handling |
| 123 * calls to functions within PPP_MessageHandler. The browser will pass this |
| 124 * same pointer when invoking functions within PPP_MessageHandler. |
| 125 * @param[in] handler The plugin-provided set of functions for handling |
| 126 * messages. |
| 127 * @param[in] message_loop represents the message loop on which |
| 128 * PPP_MessageHandler functions should be invoked. |
| 129 * @return PP_OK on success, or an error from pp_errors.h. |
| 130 */ |
| 131 int32_t (*RegisterMessageHandler)( |
| 132 PP_Instance instance, |
| 133 const void* user_data, |
| 134 const struct PPP_MessageHandler_0_1* handler, |
| 135 PP_Resource message_loop); |
| 136 /** |
| 137 * Unregisters the current message handler for <code>instance</code> if one |
| 138 * is registered. After this call, the message handler (if one was |
| 139 * registered) will have "Destroy" called on it and will receive no further |
| 140 * messages after that point. After that point, all messages sent from |
| 141 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if |
| 142 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call |
| 143 * postMessageAndAwaitResponse() from JavaScript will fail. |
| 144 * |
| 145 * Attempting to unregister a message handler when none is registered has no |
| 146 * effect. |
| 147 * |
| 148 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
| 149 * of a module. |
| 150 */ |
| 151 void (*UnregisterMessageHandler)(PP_Instance instance); |
| 152 }; |
| 153 |
| 154 struct PPB_Messaging_1_0 { |
| 155 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
| 99 }; | 156 }; |
| 100 | 157 |
| 101 typedef struct PPB_Messaging_1_0 PPB_Messaging; | 158 typedef struct PPB_Messaging_1_0 PPB_Messaging; |
| 102 /** | 159 /** |
| 103 * @} | 160 * @} |
| 104 */ | 161 */ |
| 105 | 162 |
| 106 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ | 163 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ |
| 107 | 164 |
| OLD | NEW |