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

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

Issue 252023009: PPAPI: Add dev synchronous JS->Plugin messaging API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Getting ready for landing 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
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 Wed Jun 5 10:32:59 2013. */ 6 /* From ppb_messaging.idl modified Thu May 29 15:54:46 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"
18 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_0 20 #define PPB_MESSAGING_INTERFACE_1_1 "PPB_Messaging;1.1"
21 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_1
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 {
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
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 *
104 * <strong>Note:</strong> This function is not yet implemented. Please use
105 * PPB_Messaging_1_0.
106 *
107 * Registers a handler for receiving messages from JavaScript. If a handler
108 * is registered this way, it will replace PPP_Messaging, and all messages
109 * sent from JavaScript via postMessage and postMessageAndAwaitResponse will
110 * be dispatched to <code>handler</code>.
111 *
112 * The function calls will be dispatched via <code>message_loop</code>. This
113 * means that the functions will be invoked on the thread to which
114 * <code>message_loop</code> is attached, when <code>message_loop</code> is
115 * run. It is illegal to pass the main thread message loop;
116 * RegisterMessageHandler will return PP_ERROR_WRONG_THREAD in that case.
117 *
118 * Attempting to register a message handler when one is already registered
119 * will cause the current MessageHandler to be unregistered and replaced. In
120 * that case, no messages will be sent to the "default" message handler
121 * (PPP_Messaging). Messages will stop arriving at the prior message handler
122 * and will begin to be dispatched at the new message handler.
123 *
124 * @param[in] instance A <code>PP_Instance</code> identifying one instance
125 * of a module.
126 * @param[in] user_data A pointer the plugin may choose to use when handling
127 * calls to functions within PPP_MessageHandler. The browser will pass this
128 * same pointer when invoking functions within PPP_MessageHandler.
129 * @param[in] handler The plugin-provided set of functions for handling
130 * messages.
131 * @param[in] message_loop represents the message loop on which
132 * PPP_MessageHandler functions should be invoked.
133 * @return PP_OK on success, or an error from pp_errors.h.
134 */
135 int32_t (*RegisterMessageHandler)(
136 PP_Instance instance,
137 void* user_data,
138 const struct PPP_MessageHandler_0_1* handler,
139 PP_Resource message_loop);
140 /**
141 *
142 * <strong>Note:</strong> This function is not yet implemented. Please use
143 * PPB_Messaging_1_0.
144 *
145 * Unregisters the current message handler for <code>instance</code> if one
146 * is registered. After this call, the message handler (if one was
147 * registered) will have "Destroy" called on it and will receive no further
148 * messages after that point. After that point, all messages sent from
149 * JavaScript using postMessage() will be dispatched to PPP_Messaging (if
150 * the plugin supports PPP_MESSAGING_INTERFACE). Attempts to call
151 * postMessageAndAwaitResponse() from JavaScript will fail.
152 *
153 * Attempting to unregister a message handler when none is registered has no
154 * effect.
155 *
156 * @param[in] instance A <code>PP_Instance</code> identifying one instance
157 * of a module.
158 */
159 void (*UnregisterMessageHandler)(PP_Instance instance);
160 };
161
162 struct PPB_Messaging_1_0 {
163 void (*PostMessage)(PP_Instance instance, struct PP_Var message);
99 }; 164 };
100 165
101 typedef struct PPB_Messaging_1_0 PPB_Messaging; 166 typedef struct PPB_Messaging_1_0 PPB_Messaging;
102 /** 167 /**
103 * @} 168 * @}
104 */ 169 */
105 170
106 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ 171 #endif /* PPAPI_C_PPB_MESSAGING_H_ */
107 172
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698