| 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 /** | 6 /** |
| 7 * This file defines the <code>PPB_Messaging</code> interface implemented | 7 * This file defines the <code>PPB_Messaging</code> interface implemented |
| 8 * by the browser for sending messages to DOM elements associated with a | 8 * by the browser for sending messages to DOM elements associated with a |
| 9 * specific module instance. | 9 * specific module instance. |
| 10 */ | 10 */ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * Specifically, the value of message will be contained as a property called | 39 * Specifically, the value of message will be contained as a property called |
| 40 * data in the received <code>MessageEvent</code>. | 40 * data in the received <code>MessageEvent</code>. |
| 41 * | 41 * |
| 42 * This messaging system is similar to the system used for listening for | 42 * This messaging system is similar to the system used for listening for |
| 43 * messages from Web Workers. Refer to | 43 * messages from Web Workers. Refer to |
| 44 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for | 44 * <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for |
| 45 * further information. | 45 * further information. |
| 46 * | 46 * |
| 47 * <strong>Example:</strong> | 47 * <strong>Example:</strong> |
| 48 * | 48 * |
| 49 * @code | 49 * <code> |
| 50 * | 50 * |
| 51 * <body> | 51 * <body> |
| 52 * <object id="plugin" | 52 * <object id="plugin" |
| 53 * type="application/x-ppapi-postMessage-example"/> | 53 * type="application/x-ppapi-postMessage-example"/> |
| 54 * <script type="text/javascript"> | 54 * <script type="text/javascript"> |
| 55 * var plugin = document.getElementById('plugin'); | 55 * var plugin = document.getElementById('plugin'); |
| 56 * plugin.AddEventListener("message", | 56 * plugin.AddEventListener("message", |
| 57 * function(message) { alert(message.data); }, | 57 * function(message) { alert(message.data); }, |
| 58 * false); | 58 * false); |
| 59 * </script> | 59 * </script> |
| 60 * </body> | 60 * </body> |
| 61 * | 61 * |
| 62 * @endcode | 62 * </code> |
| 63 * | 63 * |
| 64 * The module instance then invokes PostMessage() as follows: | 64 * The module instance then invokes PostMessage() as follows: |
| 65 * | 65 * |
| 66 * @code | 66 * <code> |
| 67 * | 67 * |
| 68 * | 68 * |
| 69 * char hello_world[] = "Hello world!"; | 69 * char hello_world[] = "Hello world!"; |
| 70 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, | 70 * PP_Var hello_var = ppb_var_interface->VarFromUtf8(instance, |
| 71 * hello_world, | 71 * hello_world, |
| 72 * sizeof(hello_world)); | 72 * sizeof(hello_world)); |
| 73 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. | 73 * ppb_messaging_interface->PostMessage(instance, hello_var); // Copies var. |
| 74 * ppb_var_interface->Release(hello_var); | 74 * ppb_var_interface->Release(hello_var); |
| 75 * | 75 * |
| 76 * @endcode | 76 * </code> |
| 77 * | 77 * |
| 78 * The browser will pop-up an alert saying "Hello world!" | 78 * The browser will pop-up an alert saying "Hello world!" |
| 79 */ | 79 */ |
| 80 void PostMessage([in] PP_Instance instance, [in] PP_Var message); | 80 void PostMessage([in] PP_Instance instance, [in] PP_Var message); |
| 81 }; | 81 }; |
| 82 | 82 |
| OLD | NEW |