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_PP_COMPLETION_CALLBACK_H_ | 5 #ifndef PPAPI_C_PP_COMPLETION_CALLBACK_H_ |
6 #define PPAPI_C_PP_COMPLETION_CALLBACK_H_ | 6 #define PPAPI_C_PP_COMPLETION_CALLBACK_H_ |
7 | 7 |
8 /** | 8 /** |
9 * @file | 9 * @file |
10 * Defines the API ... | 10 * Defines the API ... |
11 * | 11 * |
12 * @addtogroup PP | 12 * @addtogroup PP |
13 * @{ | 13 * @{ |
14 */ | 14 */ |
(...skipping 18 matching lines...) Expand all Loading... |
33 * value then it may carry additional information. | 33 * value then it may carry additional information. |
34 */ | 34 */ |
35 struct PP_CompletionCallback { | 35 struct PP_CompletionCallback { |
36 PP_CompletionCallback_Func func; | 36 PP_CompletionCallback_Func func; |
37 void* user_data; | 37 void* user_data; |
38 }; | 38 }; |
39 | 39 |
40 PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback( | 40 PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback( |
41 PP_CompletionCallback_Func func, | 41 PP_CompletionCallback_Func func, |
42 void* user_data) { | 42 void* user_data) { |
43 struct PP_CompletionCallback cc = { func, user_data }; | 43 struct PP_CompletionCallback cc; |
| 44 cc.func = func; |
| 45 cc.user_data = user_data; |
44 return cc; | 46 return cc; |
45 } | 47 } |
46 | 48 |
47 PP_INLINE void PP_RunCompletionCallback(struct PP_CompletionCallback* cc, | 49 PP_INLINE void PP_RunCompletionCallback(struct PP_CompletionCallback* cc, |
48 int32_t res) { | 50 int32_t res) { |
49 cc->func(cc->user_data, res); | 51 cc->func(cc->user_data, res); |
50 } | 52 } |
51 | 53 |
52 /** | 54 /** |
53 * Use this in place of an actual completion callback to request blocking | 55 * Use this in place of an actual completion callback to request blocking |
54 * behavior. If specified, the calling thread will block until a method | 56 * behavior. If specified, the calling thread will block until a method |
55 * completes. This is only usable from background threads. | 57 * completes. This is only usable from background threads. |
56 */ | 58 */ |
57 PP_INLINE struct PP_CompletionCallback PP_BlockUntilComplete() { | 59 PP_INLINE struct PP_CompletionCallback PP_BlockUntilComplete() { |
58 return PP_MakeCompletionCallback(NULL, NULL); | 60 return PP_MakeCompletionCallback(NULL, NULL); |
59 } | 61 } |
60 | 62 |
61 /** | 63 /** |
62 * @} | 64 * @} |
63 * End of addtogroup PP | 65 * End of addtogroup PP |
64 */ | 66 */ |
65 #endif // PPAPI_C_PP_COMPLETION_CALLBACK_H_ | 67 #endif /* PPAPI_C_PP_COMPLETION_CALLBACK_H_ */ |
| 68 |
OLD | NEW |