Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: ppapi/c/ppb_messaging.h

Issue 264303002: PPAPI: Implement synchronous postMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/api/ppp_message_handler.idl ('k') | ppapi/c/ppp_message_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Mon Jun 2 11:00:28 2014. */ 6 /* From ppb_messaging.idl modified Fri Jun 13 15:28:26 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_resource.h"
15 #include "ppapi/c/pp_stdint.h" 15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_var.h" 16 #include "ppapi/c/pp_var.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * sizeof(hello_world)); 93 * sizeof(hello_world));
94 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. 94 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var.
95 * ppb_var_interface->Release(hello_var); 95 * ppb_var_interface->Release(hello_var);
96 * 96 *
97 * @endcode 97 * @endcode
98 * 98 *
99 * The browser will pop-up an alert saying "Hello world!" 99 * The browser will pop-up an alert saying "Hello world!"
100 */ 100 */
101 void (*PostMessage)(PP_Instance instance, struct PP_Var message); 101 void (*PostMessage)(PP_Instance instance, struct PP_Var message);
102 /** 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 103 * Registers a handler for receiving messages from JavaScript. If a handler
107 * is registered this way, it will replace PPP_Messaging, and all messages 104 * is registered this way, it will replace PPP_Messaging, and all messages
108 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will 105 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will
109 * be dispatched to <code>handler</code>. 106 * be dispatched to <code>handler</code>.
110 * 107 *
111 * The function calls will be dispatched via <code>message_loop</code>. This 108 * 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 109 * 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 110 * <code>message_loop</code> is attached, when <code>message_loop</code> is
114 * run. It is illegal to pass the main thread message loop; 111 * run. It is illegal to pass the main thread message loop;
115 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case. 112 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case.
113 * If you quit <code>message_loop</code> before calling Unregister(),
114 * the browser will not be able to call functions in the plugin's message
115 * handler any more. That could mean missing some messages or could cause a
116 * leak if you depend on Destroy() to free hander data. So you should,
117 * whenever possible, Unregister() the handler prior to quitting its event
118 * loop.
116 * 119 *
117 * Attempting to register a message handler when one is already registered 120 * Attempting to register a message handler when one is already registered
118 * will cause the current MessageHandler to be unregistered and replaced. In 121 * will cause the current MessageHandler to be unregistered and replaced. In
119 * that case, no messages will be sent to the "default" message handler 122 * that case, no messages will be sent to the "default" message handler
120 * (PPP_Messaging). Messages will stop arriving at the prior message handler 123 * (PPP_Messaging). Messages will stop arriving at the prior message handler
121 * and will begin to be dispatched at the new message handler. 124 * and will begin to be dispatched at the new message handler.
122 * 125 *
123 * @param[in] instance A <code>PP_Instance</code> identifying one instance 126 * @param[in] instance A <code>PP_Instance</code> identifying one instance
124 * of a module. 127 * of a module.
125 * @param[in] user_data A pointer the plugin may choose to use when handling 128 * @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 129 * calls to functions within PPP_MessageHandler. The browser will pass this
127 * same pointer when invoking functions within PPP_MessageHandler. 130 * same pointer when invoking functions within PPP_MessageHandler.
128 * @param[in] handler The plugin-provided set of functions for handling 131 * @param[in] handler The plugin-provided set of functions for handling
129 * messages. 132 * messages.
130 * @param[in] message_loop Represents the message loop on which 133 * @param[in] message_loop Represents the message loop on which
131 * PPP_MessageHandler functions should be invoked. 134 * PPP_MessageHandler functions should be invoked.
132 * @return PP_OK on success, or an error from pp_errors.h. 135 * @return PP_OK on success, or an error from pp_errors.h.
133 */ 136 */
134 int32_t (*RegisterMessageHandler)( 137 int32_t (*RegisterMessageHandler)(
135 PP_Instance instance, 138 PP_Instance instance,
136 void* user_data, 139 void* user_data,
137 const struct PPP_MessageHandler_0_1* handler, 140 const struct PPP_MessageHandler_0_1* handler,
138 PP_Resource message_loop); 141 PP_Resource message_loop);
139 /** 142 /**
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 143 * Unregisters the current message handler for <code>instance</code> if one
144 * is registered. After this call, the message handler (if one was 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 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 146 * messages after that point. After that point, all messages sent from
147 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if 147 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if
148 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call 148 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call
149 * postMessageAndAwaitResponse() from JavaScript will fail. 149 * postMessageAndAwaitResponse() from JavaScript will fail.
150 * 150 *
151 * Attempting to unregister a message handler when none is registered has no 151 * Attempting to unregister a message handler when none is registered has no
152 * effect. 152 * effect.
153 * 153 *
154 * @param[in] instance A <code>PP_Instance</code> identifying one instance 154 * @param[in] instance A <code>PP_Instance</code> identifying one instance
155 * of a module. 155 * of a module.
156 */ 156 */
157 void (*UnregisterMessageHandler)(PP_Instance instance); 157 void (*UnregisterMessageHandler)(PP_Instance instance);
158 }; 158 };
159 159
160 struct PPB_Messaging_1_0 { 160 struct PPB_Messaging_1_0 {
161 void (*PostMessage)(PP_Instance instance, struct PP_Var message); 161 void (*PostMessage)(PP_Instance instance, struct PP_Var message);
162 }; 162 };
163 163
164 typedef struct PPB_Messaging_1_0 PPB_Messaging; 164 typedef struct PPB_Messaging_1_0 PPB_Messaging;
165 /** 165 /**
166 * @} 166 * @}
167 */ 167 */
168 168
169 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ 169 #endif /* PPAPI_C_PPB_MESSAGING_H_ */
170 170
OLDNEW
« no previous file with comments | « ppapi/api/ppp_message_handler.idl ('k') | ppapi/c/ppp_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698