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 | 5 |
6 /* From ppb_messaging.idl modified Wed Jul 13 16:51:56 2011. */ | 6 /* From ppb_messaging.idl modified Tue Aug 23 11:31:12 2011. */ |
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_stdint.h" | 14 #include "ppapi/c/pp_stdint.h" |
15 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
16 | 16 |
(...skipping 17 matching lines...) Expand all Loading... |
34 * The <code>PPB_Messaging</code> interface is implemented by the browser | 34 * The <code>PPB_Messaging</code> interface is implemented by the browser |
35 * and is related to sending messages to JavaScript message event listeners on | 35 * and is related to sending messages to JavaScript message event listeners on |
36 * the DOM element associated with specific module instance. | 36 * the DOM element associated with specific module instance. |
37 */ | 37 */ |
38 struct PPB_Messaging { | 38 struct PPB_Messaging { |
39 /** | 39 /** |
40 * PostMessage() asynchronously invokes any listeners for message events on | 40 * PostMessage() asynchronously invokes any listeners for message events on |
41 * the DOM element for the given module instance. A call to PostMessage() | 41 * the DOM element for the given module instance. A call to PostMessage() |
42 * will not block while the message is processed. | 42 * will not block while the message is processed. |
43 * | 43 * |
44 * @param[in] instance A <code>PP_Instance</code> indentifying one instance | 44 * @param[in] instance A <code>PP_Instance</code> identifying one instance |
45 * of a module. | 45 * of a module. |
46 * @param[in] message A <code>PP_Var</code> containing the data to be sent to | 46 * @param[in] message A <code>PP_Var</code> containing the data to be sent to |
47 * JavaScript. | 47 * JavaScript. |
48 * Message can have a numeric, boolean, or string value; arrays and | 48 * Message can have a numeric, boolean, or string value; arrays and |
49 * dictionaries are not yet supported. Ref-counted var types are copied, and | 49 * dictionaries are not yet supported. Ref-counted var types are copied, and |
50 * are therefore not shared between the module instance and the browser. | 50 * are therefore not shared between the module instance and the browser. |
51 * | 51 * |
52 * Listeners for message events in JavaScript code will receive an object | 52 * Listeners for message events in JavaScript code will receive an object |
53 * conforming to the HTML 5 <code>MessageEvent</code> interface. | 53 * conforming to the HTML 5 <code>MessageEvent</code> interface. |
54 * Specifically, the value of message will be contained as a property called | 54 * Specifically, the value of message will be contained as a property called |
55 * data in the received <code>MessageEvent</code>. | 55 * data in the received <code>MessageEvent</code>. |
56 * | 56 * |
57 * This messaging system is similar to the system used for listening for | 57 * This messaging system is similar to the system used for listening for |
58 * messages from Web Workers. Refer to | 58 * messages from Web Workers. Refer to |
59 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for | 59 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for |
60 * further information. | 60 * further information. |
61 * | 61 * |
62 * <strong>Example:</strong> | 62 * <strong>Example:</strong> |
63 * | 63 * |
64 * @code | 64 * <code> |
65 * | 65 * |
66 * <body> | 66 * <body> |
67 * <object id="plugin" | 67 * <object id="plugin" |
68 * type="application/x-ppapi-postMessage-example"/> | 68 * type="application/x-ppapi-postMessage-example"/> |
69 * <script type="text/javascript"> | 69 * <script type="text/javascript"> |
70 * var plugin = document.getElementById('plugin'); | 70 * var plugin = document.getElementById('plugin'); |
71 * plugin.AddEventListener("message", | 71 * plugin.AddEventListener("message", |
72 * function(message) { alert(message.data); }, | 72 * function(message) { alert(message.data); }, |
73 * false); | 73 * false); |
74 * </script> | 74 * </script> |
75 * </body> | 75 * </body> |
76 * | 76 * |
77 * @endcode | 77 * </code> |
78 * | 78 * |
79 * The module instance then invokes PostMessage() as follows: | 79 * The module instance then invokes PostMessage() as follows: |
80 * | 80 * |
81 * @code | 81 * <code> |
82 * | 82 * |
83 * | 83 * |
84 * char hello_world[] = "Hello world!"; | 84 * char hello_world[] = "Hello world!"; |
85 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, | 85 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, |
86 * hello_world, | 86 * hello_world, |
87 * sizeof(hello_world)); | 87 * sizeof(hello_world)); |
88 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. | 88 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. |
89 * ppb_var_interface->Release(hello_var); | 89 * ppb_var_interface->Release(hello_var); |
90 * | 90 * |
91 * @endcode | 91 * </code> |
92 * | 92 * |
93 * The browser will pop-up an alert saying "Hello world!" | 93 * The browser will pop-up an alert saying "Hello world!" |
94 */ | 94 */ |
95 void (*PostMessage)(PP_Instance instance, struct PP_Var message); | 95 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
96 }; | 96 }; |
97 /** | 97 /** |
98 * @} | 98 * @} |
99 */ | 99 */ |
100 | 100 |
101 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ | 101 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ |
102 | 102 |
OLD | NEW |