OLD | NEW |
1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 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 #ifndef PPAPI_C_PPP_MESSAGING_H_ | 5 #ifndef PPAPI_C_PPP_MESSAGING_H_ |
6 #define PPAPI_C_PPP_MESSAGING_H_ | 6 #define PPAPI_C_PPP_MESSAGING_H_ |
7 | 7 |
8 #include "ppapi/c/pp_instance.h" | 8 #include "ppapi/c/pp_instance.h" |
9 | 9 |
10 struct PP_Var; | 10 struct PP_Var; |
11 | 11 |
12 #define PPP_MESSAGING_INTERFACE "PPP_Messaging;0.1" | 12 #define PPP_MESSAGING_INTERFACE "PPP_Messaging;0.1" |
13 | 13 |
14 /** | 14 /** |
15 * @file | 15 * @file |
16 * This file defines the PPP_Messaging interface containing pointers to | 16 * This file defines the PPP_Messaging interface containing pointers to |
17 * functions that you must implement to handle postMessage messages | 17 * functions that you must implement to handle postMessage messages |
18 * on the associated DOM element. | 18 * on the associated DOM element. |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 /** @addtogroup Interfaces | 22 /** @addtogroup Interfaces |
23 * @{ | 23 * @{ |
24 */ | 24 */ |
25 | 25 |
26 /** | 26 /** |
27 * The PPP_Messaging interface contains pointers to functions that you must | 27 * The <code>PPP_Messaging</code> interface contains pointers to functions |
28 * implement to handle postMessage events on the associated DOM element. | 28 * that you must implement to handle postMessage events on the associated |
| 29 * DOM element. |
29 */ | 30 */ |
30 struct PPP_Messaging { | 31 struct PPP_Messaging { |
31 /** | 32 /** |
32 * HandleMessage is a pointer to a function that the browser calls when | 33 * HandleMessage() is a function that the browser calls when PostMessage() |
33 * PostMessage() is invoked on the DOM element for the module instance in | 34 * is invoked on the DOM element for the module instance in JavaScript. Note |
34 * JavaScript. Note that PostMessage() in the JavaScript interface is | 35 * that PostMessage() in the JavaScript interface is asynchronous, meaning |
35 * asynchronous, meaning JavaScript execution will not be blocked while | 36 * JavaScript execution will not be blocked while HandleMessage() is |
36 * HandleMessage() is processing the message. | 37 * processing the message. |
37 * | 38 * |
38 * @param[in] instance A PP_Instance indentifying one instance of a module. | 39 * @param[in] instance A <code>PP_Instance</code> indentifying one instance |
39 * @param[in] message A PP_Var containing the data to be sent to JavaScript. | 40 * of a module. |
40 * Message can have an int32_t, double, bool, or string value (objects | 41 * @param[in] message A <code>PP_Var</code> containing the data to be sent |
41 * are not supported). | 42 * to JavaScript. Message can have an int32_t, double, bool, or string value |
| 43 * (objects are not supported). |
42 * | 44 * |
43 * <strong>Example:</strong> | 45 * <strong>Example:</strong> |
44 * | 46 * |
45 * The following JavaScript code invokes HandleMessage, passing the module | 47 * The following JavaScript code invokes <code>HandleMessage</code>, passing |
46 * instance on which it was invoked, with <code>message</code> being a | 48 * the module instance on which it was invoked, with <code>message</code> |
47 * string PP_Var containing "Hello world!" | 49 * being a string <code>PP_Var</code> containing "Hello world!" |
48 * | 50 * |
49 * @code | 51 * @code |
50 * | 52 * |
51 * <body> | 53 * <body> |
52 * <object id="plugin" | 54 * <object id="plugin" |
53 * type="application/x-ppapi-postMessage-example"/> | 55 * type="application/x-ppapi-postMessage-example"/> |
54 * <script type="text/javascript"> | 56 * <script type="text/javascript"> |
55 * document.getElementById('plugin').postMessage("Hello world!"); | 57 * document.getElementById('plugin').postMessage("Hello world!"); |
56 * </script> | 58 * </script> |
57 * </body> | 59 * </body> |
58 * | 60 * |
59 * @endcode | 61 * @endcode |
60 * | 62 * |
61 */ | 63 */ |
62 void (*HandleMessage)(PP_Instance instance, struct PP_Var message); | 64 void (*HandleMessage)(PP_Instance instance, struct PP_Var message); |
63 }; | 65 }; |
64 /** | 66 /** |
65 * @} | 67 * @} |
66 */ | 68 */ |
67 #endif /* PPAPI_C_PPP_MESSAGING_H_ */ | 69 #endif /* PPAPI_C_PPP_MESSAGING_H_ */ |
68 | 70 |
OLD | NEW |