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 /* From pp_completion_callback.idl modified Thu Mar 28 15:25:03 2013. */ | 6 /* From pp_completion_callback.idl modified Thu May 9 14:59:57 2013. */ |
7 | 7 |
8 #ifndef PPAPI_C_PP_COMPLETION_CALLBACK_H_ | 8 #ifndef PPAPI_C_PP_COMPLETION_CALLBACK_H_ |
9 #define PPAPI_C_PP_COMPLETION_CALLBACK_H_ | 9 #define PPAPI_C_PP_COMPLETION_CALLBACK_H_ |
10 | 10 |
11 #include "ppapi/c/pp_macros.h" | 11 #include "ppapi/c/pp_macros.h" |
12 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
13 | 13 |
14 /** | 14 /** |
15 * @file | 15 * @file |
16 * This file defines the API to create and run a callback. | 16 * This file defines the API to create and run a callback. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 * <code>PP_CompletionCallback</code> is a common mechanism for supporting | 89 * <code>PP_CompletionCallback</code> is a common mechanism for supporting |
90 * potentially asynchronous calls in browser interfaces. Any method that takes a | 90 * potentially asynchronous calls in browser interfaces. Any method that takes a |
91 * <code>PP_CompletionCallback</code> can be used in one of three different | 91 * <code>PP_CompletionCallback</code> can be used in one of three different |
92 * ways: | 92 * ways: |
93 * - Required: The callback will always be invoked asynchronously on the | 93 * - Required: The callback will always be invoked asynchronously on the |
94 * thread where the associated PPB method was invoked. The method | 94 * thread where the associated PPB method was invoked. The method |
95 * will always return PP_OK_COMPLETIONPENDING when a required | 95 * will always return PP_OK_COMPLETIONPENDING when a required |
96 * callback, and the callback will be invoked later (barring | 96 * callback, and the callback will be invoked later (barring |
97 * system or thread shutdown; see PPB_MessageLoop for details). | 97 * system or thread shutdown; see PPB_MessageLoop for details). |
98 * Required callbacks are the default. | 98 * Required callbacks are the default. |
99 * | 99 * <br /><br /> |
100 * NOTE: If you use a required callback on a background thread, | 100 * NOTE: If you use a required callback on a background thread, |
101 * you must have created and attached a PPB_MessageLoop. | 101 * you must have created and attached a PPB_MessageLoop. |
102 * Otherwise, the system can not run your callback on that thread, | 102 * Otherwise, the system can not run your callback on that thread, |
103 * and will instead emit a log message and crash your plugin to | 103 * and will instead emit a log message and crash your plugin to |
104 * make the problem more obvious. | 104 * make the problem more obvious. |
105 * | 105 * |
106 * - Optional: The callback may be invoked asynchronously, or the PPB method | 106 * - Optional: The callback may be invoked asynchronously, or the PPB method |
107 * may complete synchronously if it can do so without blocking. | 107 * may complete synchronously if it can do so without blocking. |
108 * If the method will complete asynchronously, it will return | 108 * If the method will complete asynchronously, it will return |
109 * PP_OK_COMPLETIONPENDING. Otherwise, it will complete | 109 * PP_OK_COMPLETIONPENDING. Otherwise, it will complete |
110 * synchronously and return an appropriate code (see below for | 110 * synchronously and return an appropriate code (see below for |
111 * more information on the return code). Optional callbacks are | 111 * more information on the return code). Optional callbacks are |
112 * generally more difficult to use correctly than Required | 112 * generally more difficult to use correctly than Required |
113 * callbacks, but can provide better performance for some APIs | 113 * callbacks, but can provide better performance for some APIs |
114 * (especially APIs with buffered reads, such as PPB_URLLoader or | 114 * (especially APIs with buffered reads, such as PPB_URLLoader or |
115 * PPB_FileIO). | 115 * PPB_FileIO). |
116 * | 116 * <br /><br /> |
117 * NOTE: If you use an optional callback on a background thread, | 117 * NOTE: If you use an optional callback on a background thread, |
118 * and you have not created and attached a PPB_MessageLoop, then | 118 * and you have not created and attached a PPB_MessageLoop, then |
119 * the method you invoke will fail without running and return | 119 * the method you invoke will fail without running and return |
120 * PP_ERROR_NO_MESSAGE_LOOP. | 120 * PP_ERROR_NO_MESSAGE_LOOP. |
121 * | 121 * |
122 * - Blocking: In this case, the callback's function pointer is NULL, and the | 122 * - Blocking: In this case, the callback's function pointer is NULL, and the |
123 * invoked method must complete synchronously. The method will | 123 * invoked method must complete synchronously. The method will |
124 * run to completion and return an appropriate code when finished | 124 * run to completion and return an appropriate code when finished |
125 * (see below for more information). Blocking completion | 125 * (see below for more information). Blocking completion |
126 * callbacks are only supported on background threads. | 126 * callbacks are only supported on background threads. |
127 * | 127 * <br /><br /> |
128 * <code>PP_BlockUntilComplete()</code> provides a convenient way | 128 * <code>PP_BlockUntilComplete()</code> provides a convenient way |
129 * to specify blocking behavior. Refer to | 129 * to specify blocking behavior. Refer to |
130 * <code>PP_BlockUntilComplete</code> for more information. | 130 * <code>PP_BlockUntilComplete</code> for more information. |
131 * | 131 * |
132 * When the callback is run asynchronously, the result parameter passed to | 132 * When the callback is run asynchronously, the result parameter passed to |
133 * <code>func</code> is an int32_t that, if negative indicates an error code | 133 * <code>func</code> is an int32_t that, if negative indicates an error code |
134 * whose meaning is specific to the calling method (refer to | 134 * whose meaning is specific to the calling method (refer to |
135 * <code>pp_error.h</code> for further information). A positive or 0 value is a | 135 * <code>pp_error.h</code> for further information). A positive or 0 value is a |
136 * return result indicating success whose meaning depends on the calling method | 136 * return result indicating success whose meaning depends on the calling method |
137 * (e.g. number of bytes read). | 137 * (e.g. number of bytes read). |
138 */ | 138 */ |
139 struct PP_CompletionCallback { | 139 struct PP_CompletionCallback { |
140 /** | 140 /** |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 struct PP_CompletionCallback temp = *cc; | 280 struct PP_CompletionCallback temp = *cc; |
281 *cc = PP_BlockUntilComplete(); | 281 *cc = PP_BlockUntilComplete(); |
282 PP_RunCompletionCallback(&temp, res); | 282 PP_RunCompletionCallback(&temp, res); |
283 } | 283 } |
284 /** | 284 /** |
285 * @} | 285 * @} |
286 */ | 286 */ |
287 | 287 |
288 #endif /* PPAPI_C_PP_COMPLETION_CALLBACK_H_ */ | 288 #endif /* PPAPI_C_PP_COMPLETION_CALLBACK_H_ */ |
289 | 289 |
OLD | NEW |