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