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

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

Issue 253813006: PPAPI: Synchronous postMessage proposal #1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/c/pp_macros.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('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 Wed Jun 5 10:32:59 2013. */ 6 /* From ppb_messaging.idl modified Mon Apr 28 13:06:18 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_completion_callback.h"
12 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_macros.h" 14 #include "ppapi/c/pp_macros.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"
16 17
17 #define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0" 18 #define PPB_MESSAGING_INTERFACE_1_0 "PPB_Messaging;1.0"
18 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_0 19 #define PPB_MESSAGING_INTERFACE_1_1 "PPB_Messaging;1.1"
20 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_1_1
19 21
20 /** 22 /**
21 * @file 23 * @file
22 * This file defines the <code>PPB_Messaging</code> interface implemented 24 * This file defines the <code>PPB_Messaging</code> interface implemented
23 * by the browser for sending messages to DOM elements associated with a 25 * by the browser for sending messages to DOM elements associated with a
24 * specific module instance. 26 * specific module instance.
25 */ 27 */
26 28
27 29
28 /** 30 /**
29 * @addtogroup Interfaces 31 * @addtogroup Interfaces
30 * @{ 32 * @{
31 */ 33 */
32 /** 34 /**
33 * The <code>PPB_Messaging</code> interface is implemented by the browser 35 * The <code>PPB_Messaging</code> interface is implemented by the browser
34 * and is related to sending messages to JavaScript message event listeners on 36 * and is related to sending messages to JavaScript message event listeners on
35 * the DOM element associated with specific module instance. 37 * the DOM element associated with specific module instance.
36 */ 38 */
37 struct PPB_Messaging_1_0 { 39 struct PPB_Messaging_1_1 {
38 /** 40 /**
39 * PostMessage() asynchronously invokes any listeners for message events on 41 * PostMessage() asynchronously invokes any listeners for message events on
40 * the DOM element for the given module instance. A call to PostMessage() 42 * the DOM element for the given module instance. A call to PostMessage()
41 * will not block while the message is processed. 43 * will not block while the message is processed.
42 * 44 *
43 * @param[in] instance A <code>PP_Instance</code> identifying one instance 45 * @param[in] instance A <code>PP_Instance</code> identifying one instance
44 * of a module. 46 * of a module.
45 * @param[in] message A <code>PP_Var</code> containing the data to be sent to 47 * @param[in] message A <code>PP_Var</code> containing the data to be sent to
46 * JavaScript. 48 * JavaScript.
47 * <code>message</code> can be any <code>PP_Var</code> type except 49 * <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, 91 * hello_world,
90 * sizeof(hello_world)); 92 * sizeof(hello_world));
91 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. 93 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var.
92 * ppb_var_interface->Release(hello_var); 94 * ppb_var_interface->Release(hello_var);
93 * 95 *
94 * @endcode 96 * @endcode
95 * 97 *
96 * The browser will pop-up an alert saying "Hello world!" 98 * The browser will pop-up an alert saying "Hello world!"
97 */ 99 */
98 void (*PostMessage)(PP_Instance instance, struct PP_Var message); 100 void (*PostMessage)(PP_Instance instance, struct PP_Var message);
101 /**
102 * Call this to prepare to receive a blocking message from JavaScript.
103 * When JavaScript invokes postMessageAndAwaitResponse(), the callback will
104 * be invoked (or, if a blocking completion callback was used,
105 * WaitForBlockingMessage will return).
106 *
107 * When the call completes, |message| will be a PP_Var containing a copy of
108 * the data passed from JavaScript to postMessageAndAwaitResponse().
109 *
110 * Upon receipt of the callback, the plugin must respond to the plugin by
111 * calling RespondToBlockingMessage. The JavaScript invocation of
112 * postMessageAndAwaitResponse will not return until the response is
113 * received, so it is important to respond quickly.
114 *
115 * Invocations of WaitForBlockingMessage will fail if JavaScript is still
116 * awaiting a response to a prior invocation of the callback. Therefore, the
117 * plugin must always call RespondToBlockingMessage before calling
118 * WaitForBlockingMessage again.
119 *
120 * Example usage:
121 * void thread_func() {
122 * while (!ShouldQuit()) {
123 * PP_Var param = PP_MakeUndefined();
124 * WaitForBlockingMessage(pp_instance, &param,
125 * PP_BlockUntilComplete());
126 * PP_Var response = ComputeSomething(param);
127 * RespondToBlockingMessage(pp_instance, response);
128 * var_if.Release(param);
129 * var_if.Release(response);
130 * }
131 * }
132 *
133 * WaitForBlockingMessage will only work if called from a background thread.
134 * If it is invoked from the main Pepper thread, the result will be
135 * PP_ERROR_WRONG_THREAD.
136 */
137 int32_t (*WaitForBlockingMessage)(PP_Instance instance,
138 struct PP_Var* message,
139 struct PP_CompletionCallback callback);
140 /**
141 * Send a response to JavaScript. This only makes sense if JavaScript is
142 * currently blocked on postMessagAndAwaitResponse. JavaScript's
143 * postMessageAndAwaitResponse function will return a JavaScript value
144 * representing a copy of |response|.
145 */
146 void (*RespondToBlockingMessage)(PP_Instance instance,
147 struct PP_Var response);
99 }; 148 };
100 149
101 typedef struct PPB_Messaging_1_0 PPB_Messaging; 150 typedef struct PPB_Messaging_1_1 PPB_Messaging;
151
152 struct PPB_Messaging_1_0 {
153 void (*PostMessage)(PP_Instance instance, struct PP_Var message);
154 };
102 /** 155 /**
103 * @} 156 * @}
104 */ 157 */
105 158
106 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ 159 #endif /* PPAPI_C_PPB_MESSAGING_H_ */
107 160
OLDNEW
« no previous file with comments | « ppapi/c/pp_macros.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698