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 #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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // Methods for allocating new, single-use CompletionCallbacks. | 187 // Methods for allocating new, single-use CompletionCallbacks. |
188 // The CompletionCallback must be run in order for the memory | 188 // The CompletionCallback must be run in order for the memory |
189 // allocated by the methods to be freed. | 189 // allocated by the methods to be freed. |
190 // NewRequiredCallback() creates callbacks that will always run. | 190 // NewRequiredCallback() creates callbacks that will always run. |
191 // NewOptionalCallback() creates callbacks that might not run if the method | 191 // NewOptionalCallback() creates callbacks that might not run if the method |
192 // taking them can complete synchronously. Thus, if after passing the | 192 // taking them can complete synchronously. Thus, if after passing the |
193 // CompletionCallback to a PPAPI method, the method does not return | 193 // CompletionCallback to a PPAPI method, the method does not return |
194 // PP_OK_COMPLETIONPENDING, then you should manually call the | 194 // PP_OK_COMPLETIONPENDING, then you should manually call the |
195 // CompletionCallback's Run method, or memory will be leaked. | 195 // CompletionCallback's Run method, or memory will be leaked. |
196 // NewCallback() is equivalent to NewOptionalCallback(). | 196 // NewCallback() is equivalent to NewRequiredCallback(). |
197 // TODO(polina): update this comment when this is no longer true. | |
198 | 197 |
199 template <typename Method> | 198 template <typename Method> |
200 CompletionCallback NewCallback(Method method) { | 199 CompletionCallback NewCallback(Method method) { |
201 PP_DCHECK(object_); | 200 PP_DCHECK(object_); |
202 return NewCallbackHelper(Dispatcher0<Method>(method)); | 201 return NewCallbackHelper(Dispatcher0<Method>(method)); |
203 } | 202 } |
204 | 203 |
205 template <typename Method> | 204 template <typename Method> |
206 CompletionCallback NewRequiredCallback(Method method) { | 205 CompletionCallback NewRequiredCallback(Method method) { |
207 CompletionCallback cc = NewCallback(method); | 206 CompletionCallback cc = NewCallback(method); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 CompletionCallbackFactory(const CompletionCallbackFactory&); | 393 CompletionCallbackFactory(const CompletionCallbackFactory&); |
395 CompletionCallbackFactory& operator=(const CompletionCallbackFactory&); | 394 CompletionCallbackFactory& operator=(const CompletionCallbackFactory&); |
396 | 395 |
397 T* object_; | 396 T* object_; |
398 BackPointer* back_pointer_; | 397 BackPointer* back_pointer_; |
399 }; | 398 }; |
400 | 399 |
401 } // namespace pp | 400 } // namespace pp |
402 | 401 |
403 #endif // PPAPI_CPP_COMPLETION_CALLBACK_H_ | 402 #endif // PPAPI_CPP_COMPLETION_CALLBACK_H_ |
OLD | NEW |