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