| 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_PPB_MESSAGING_H_ | 5 #ifndef PPAPI_C_PPB_MESSAGING_H_ |
| 6 #define PPAPI_C_PPB_MESSAGING_H_ | 6 #define PPAPI_C_PPB_MESSAGING_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_instance.h" | 8 #include "ppapi/c/pp_instance.h" |
| 9 #include "ppapi/c/pp_var.h" | 9 #include "ppapi/c/pp_var.h" |
| 10 | 10 |
| 11 #define PPB_MESSAGING_INTERFACE_0_1 "PPB_Messaging;0.1" | 11 #define PPB_MESSAGING_INTERFACE_0_1 "PPB_Messaging;0.1" |
| 12 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_0_1 | 12 #define PPB_MESSAGING_INTERFACE PPB_MESSAGING_INTERFACE_0_1 |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * @file | 15 * @file |
| 16 * This file defines the PPB_Messaging interface implemented by the browser | 16 * This file defines the <code>PPB_Messaging</code> interface implemented |
| 17 * related to sending messages to DOM elements associated with a specific | 17 * by the browser for sending messages to DOM elements associated with a |
| 18 * module instance. | 18 * specific module instance. |
| 19 * | 19 * |
| 20 * @addtogroup Interfaces | 20 * @addtogroup Interfaces |
| 21 * @{ | 21 * @{ |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * The PPB_Messaging interface contains a pointer to a function related to | 25 * The <code>PPB_Messaging</code> interface is implemented by the browser |
| 26 * sending messages to JavaScript message event listeners on the DOM element | 26 * and is related to sending messages to JavaScript message event listeners on |
| 27 * associated with a specific module instance. | 27 * the DOM element associated with specific module instance. |
| 28 */ | 28 */ |
| 29 struct PPB_Messaging { | 29 struct PPB_Messaging { |
| 30 /** | 30 /** |
| 31 * PostMessage is a pointer to a function that asynchronously invokes any | 31 * PostMessage() asynchronously invokes any listeners for message events on |
| 32 * listeners for message events on the DOM element for the given module | 32 * the DOM element for the given module instance. A call to PostMessage() |
| 33 * instance. A call to PostMessage() will not block while the message is | 33 * will not block while the message is processed. |
| 34 * processed. | |
| 35 * | 34 * |
| 36 * @param[in] instance A PP_Instance indentifying one instance of a module. | 35 * @param[in] instance A <code>PP_Instance</code> indentifying one instance |
| 37 * @param[in] message A PP_Var containing the data to be sent to JavaScript. | 36 * of a module. |
| 37 * @param[in] message A <code>PP_Var</code> containing the data to be sent to |
| 38 * JavaScript. |
| 38 * Message can have a numeric, boolean, or string value; arrays and | 39 * Message can have a numeric, boolean, or string value; arrays and |
| 39 * dictionaries are not yet supported. Ref-counted var types are copied, and | 40 * dictionaries are not yet supported. Ref-counted var types are copied, and |
| 40 * are therefore not shared between the module instance and the browser. | 41 * are therefore not shared between the module instance and the browser. |
| 41 * | 42 * |
| 42 * Listeners for message events in JavaScript code will receive an object | 43 * Listeners for message events in JavaScript code will receive an object |
| 43 * conforming to the HTML 5 MessageEvent interface. Specifically, the value of | 44 * conforming to the HTML 5 <code>MessageEvent</code> interface. |
| 44 * message will be contained as a property called data in the received | 45 * Specifically, the value of message will be contained as a property called |
| 45 * MessageEvent. | 46 * data in the received <code>MessageEvent</code>. |
| 46 * | 47 * |
| 47 * This messaging system is similar to the system used for listening for | 48 * This messaging system is similar to the system used for listening for |
| 48 * messages from Web Workers. Refer to | 49 * messages from Web Workers. Refer to |
| 49 * http://www.whatwg.org/specs/web-workers/current-work/ for further | 50 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for |
| 50 * information. | 51 * further information. |
| 51 * | 52 * |
| 52 * <strong>Example:</strong> | 53 * <strong>Example:</strong> |
| 53 * | 54 * |
| 54 * @code | 55 * @code |
| 55 * | 56 * |
| 56 * <body> | 57 * <body> |
| 57 * <object id="plugin" | 58 * <object id="plugin" |
| 58 * type="application/x-ppapi-postMessage-example"/> | 59 * type="application/x-ppapi-postMessage-example"/> |
| 59 * <script type="text/javascript"> | 60 * <script type="text/javascript"> |
| 60 * var plugin = document.getElementById('plugin'); | 61 * var plugin = document.getElementById('plugin'); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 82 * | 83 * |
| 83 * The browser will pop-up an alert saying "Hello world!" | 84 * The browser will pop-up an alert saying "Hello world!" |
| 84 */ | 85 */ |
| 85 void (*PostMessage)(PP_Instance instance, struct PP_Var message); | 86 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
| 86 }; | 87 }; |
| 87 /** | 88 /** |
| 88 * @} | 89 * @} |
| 89 */ | 90 */ |
| 90 | 91 |
| 91 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ | 92 #endif /* PPAPI_C_PPB_MESSAGING_H_ */ |
| OLD | NEW |