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 #ifndef PPAPI_CPP_COMPLETION_CALLBACK_H_ | 5 #ifndef PPAPI_CPP_COMPLETION_CALLBACK_H_ |
6 #define PPAPI_CPP_COMPLETION_CALLBACK_H_ | 6 #define PPAPI_CPP_COMPLETION_CALLBACK_H_ |
7 | 7 |
8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/cpp/logging.h" | 10 #include "ppapi/cpp/logging.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 class CompletionCallbackWithOutput : public CompletionCallback { | 178 class CompletionCallbackWithOutput : public CompletionCallback { |
179 public: | 179 public: |
180 /// The type that will actually be stored in the completion callback. In the | 180 /// The type that will actually be stored in the completion callback. In the |
181 /// common case, this will be equal to the template parameter (for example, | 181 /// common case, this will be equal to the template parameter (for example, |
182 /// CompletionCallbackWithOutput<int> would obviously take an int*. However, | 182 /// CompletionCallbackWithOutput<int> would obviously take an int*. However, |
183 /// resources are passed as PP_Resource, vars as PP_Var, and arrays as our | 183 /// resources are passed as PP_Resource, vars as PP_Var, and arrays as our |
184 /// special ArrayOutputAdapter object. The CallbackOutputTraits defines | 184 /// special ArrayOutputAdapter object. The CallbackOutputTraits defines |
185 /// specializations for all of these cases. | 185 /// specializations for all of these cases. |
186 typedef typename internal::CallbackOutputTraits<T>::StorageType | 186 typedef typename internal::CallbackOutputTraits<T>::StorageType |
187 OutputStorageType; | 187 OutputStorageType; |
| 188 typedef typename internal::CallbackOutputTraits<T>::APIArgType |
| 189 APIArgType; |
188 | 190 |
189 /// The default constructor will create a blocking | 191 /// The default constructor will create a blocking |
190 /// <code>CompletionCallback</code> that references the given output | 192 /// <code>CompletionCallback</code> that references the given output |
191 /// data. | 193 /// data. |
192 /// | 194 /// |
193 /// @param[in] output A pointer to the data associated with the callback. The | 195 /// @param[in] output A pointer to the data associated with the callback. The |
194 /// caller must ensure that this pointer outlives the completion callback. | 196 /// caller must ensure that this pointer outlives the completion callback. |
195 /// | 197 /// |
196 /// <strong>Note:</strong> Blocking completion callbacks are only allowed from | 198 /// <strong>Note:</strong> Blocking completion callbacks are only allowed from |
197 /// from background threads. | 199 /// from background threads. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 /// @param[in] output A pointer to the data associated with the callback. The | 232 /// @param[in] output A pointer to the data associated with the callback. The |
231 /// caller must ensure that this pointer outlives the completion callback. | 233 /// caller must ensure that this pointer outlives the completion callback. |
232 CompletionCallbackWithOutput(PP_CompletionCallback_Func func, | 234 CompletionCallbackWithOutput(PP_CompletionCallback_Func func, |
233 void* user_data, | 235 void* user_data, |
234 int32_t flags, | 236 int32_t flags, |
235 OutputStorageType* output) | 237 OutputStorageType* output) |
236 : CompletionCallback(func, user_data, flags), | 238 : CompletionCallback(func, user_data, flags), |
237 output_(output) { | 239 output_(output) { |
238 } | 240 } |
239 | 241 |
240 OutputStorageType* output() const { return output_; } | 242 APIArgType output() const { |
| 243 return internal::CallbackOutputTraits<T>::StorageToAPIArg(*output_); |
| 244 } |
241 | 245 |
242 private: | 246 private: |
243 OutputStorageType* output_; | 247 OutputStorageType* output_; |
244 }; | 248 }; |
245 | 249 |
246 /// BlockUntilComplete() is used in place of an actual completion callback | 250 /// BlockUntilComplete() is used in place of an actual completion callback |
247 /// to request blocking behavior. If specified, the calling thread will block | 251 /// to request blocking behavior. If specified, the calling thread will block |
248 /// until the function completes. Blocking completion callbacks are only | 252 /// until the function completes. Blocking completion callbacks are only |
249 /// allowed from background threads. | 253 /// allowed from background threads. |
250 /// | 254 /// |
251 /// @return A <code>CompletionCallback</code> corresponding to a NULL callback. | 255 /// @return A <code>CompletionCallback</code> corresponding to a NULL callback. |
252 CompletionCallback BlockUntilComplete(); | 256 CompletionCallback BlockUntilComplete(); |
253 | 257 |
254 } // namespace pp | 258 } // namespace pp |
255 | 259 |
256 #endif // PPAPI_CPP_COMPLETION_CALLBACK_H_ | 260 #endif // PPAPI_CPP_COMPLETION_CALLBACK_H_ |
OLD | NEW |