OLD | NEW |
1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2010 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_INSTANCE_H_ | 5 #ifndef PPAPI_C_PPB_INSTANCE_H_ |
6 #define PPAPI_C_PPB_INSTANCE_H_ | 6 #define PPAPI_C_PPB_INSTANCE_H_ |
7 | 7 |
8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
11 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
12 | 12 |
13 #define PPB_INSTANCE_INTERFACE "PPB_Instance;0.4" | 13 #define PPB_INSTANCE_INTERFACE "PPB_Instance;0.5" |
14 | 14 |
15 /** | 15 /** |
16 * @file | 16 * @file |
17 * This file defines the PPB_Instance interface implemented by the | 17 * This file defines the PPB_Instance interface implemented by the |
18 * browser and containing pointers to functions related to | 18 * browser and containing pointers to functions related to |
19 * the module instance on a web page. | 19 * the module instance on a web page. |
20 * | 20 * |
21 * @addtogroup Interfaces | 21 * @addtogroup Interfaces |
22 * @{ | 22 * @{ |
23 */ | 23 */ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 * @param[in/out] exception PP_Var containing the exception. Initialize | 100 * @param[in/out] exception PP_Var containing the exception. Initialize |
101 * this to NULL if you don't want exception info; initialize this to a void | 101 * this to NULL if you don't want exception info; initialize this to a void |
102 * exception if want exception info. | 102 * exception if want exception info. |
103 * | 103 * |
104 * @return The result of the script execution, or a "void" var | 104 * @return The result of the script execution, or a "void" var |
105 * if execution failed. | 105 * if execution failed. |
106 */ | 106 */ |
107 struct PP_Var (*ExecuteScript)(PP_Instance instance, | 107 struct PP_Var (*ExecuteScript)(PP_Instance instance, |
108 struct PP_Var script, | 108 struct PP_Var script, |
109 struct PP_Var* exception); | 109 struct PP_Var* exception); |
| 110 |
| 111 /** |
| 112 * PostMessage asynchronously invokes the onmessage handler of the 'embed' |
| 113 * instance, if one exists. This is analogous to listening for messages from |
| 114 * Web Workers. |
| 115 * See: |
| 116 * http://www.whatwg.org/specs/web-workers/current-work/ |
| 117 * |
| 118 * For example: |
| 119 * |
| 120 * <body> |
| 121 * <object id="module" |
| 122 * type="application/x-ppapi-postMessage-example"/> |
| 123 * <script type="text/javascript"> |
| 124 * document.getElementById('module').onmessage = function(message) { |
| 125 * alert(message.data); |
| 126 * } |
| 127 * </script> |
| 128 * </body> |
| 129 * |
| 130 * If the module then invokes PostMessage as follows: |
| 131 * char hello_world[] = "Hello world!"; |
| 132 * PP_Var hello_var = ppb_var_if->VarFromUtf8(instance, |
| 133 * hello_world, |
| 134 * sizeof(hello_world)); |
| 135 * the_ppb_instance->PostMessage(instance, hello_var); |
| 136 * |
| 137 * The browser will pop-up an alert saying "Hello world!". |
| 138 */ |
| 139 void (*PostMessage)(PP_Instance instance, struct PP_Var message); |
110 }; | 140 }; |
111 /** | 141 /** |
112 * @} | 142 * @} |
113 */ | 143 */ |
114 | 144 |
115 #endif /* PPAPI_C_PPB_INSTANCE_H_ */ | 145 #endif /* PPAPI_C_PPB_INSTANCE_H_ */ |
116 | 146 |
OLD | NEW |