Index: ppapi/c/pp_completion_callback.h |
=================================================================== |
--- ppapi/c/pp_completion_callback.h (revision 91508) |
+++ ppapi/c/pp_completion_callback.h (working copy) |
@@ -21,15 +21,14 @@ |
*/ |
/** |
- * PP_CompletionCallback_Func defines the function signature that you implement |
- * to receive callbacks on asynchronous completion of an operation. |
+ * This typedef defines the signature that you implement to |
der Springer
2011/08/09 20:40:40
Nit: join this line with the next and re-format to
jond
2011/08/10 21:05:59
Done.
jond
2011/08/10 21:05:59
Done.
|
+ * receive callbacks on asynchronous completion. |
* |
- * |user_data| is a pointer to user-specified data associated with this |
- * function at callback creation. See PP_MakeCompletionCallback() for details. |
- * |
- * |result| is the result of the operation. Non-positive values correspond to |
- * the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING). |
- * Positive values indicate additional information such as bytes read. |
+ * @param[in] user_data A pointer to user data passed to a callback function. |
+ * @param[in] result If result is 0 (PP_OK), the operation succeeded. Negative |
+ * values (other than -1) indicate error and are specified in pp_errors.h. |
der Springer
2011/08/09 20:40:40
Maybe mention that -1 is the same as PP_OK_COMPLET
jond
2011/08/10 21:05:59
Done.
|
+ * Positive values for result usually indicate success and have some |
+ * operation-dependent meaning (such as bytes read). |
*/ |
typedef void (*PP_CompletionCallback_Func)(void* user_data, int32_t result); |
/** |
@@ -80,17 +79,36 @@ |
*/ |
/** |
- * Any method that takes a PP_CompletionCallback can complete asynchronously. |
- * Refer to PP_CompletionCallback_Flag for more information. |
+ * Any method that takes a <code>PP_CompletionCallback</code> has the option of |
+ * completing asynchronously if the operation would block. Such a method |
+ * should return <code>PP_OK_COMPLETIONPENDING</code> to indicate that the |
+ * method will complete asynchronously and will always be invoked from the main |
der Springer
2011/08/09 20:40:40
..."complete asynchronously and notify the caller
jond
2011/08/10 21:05:59
Done.
jond
2011/08/10 21:05:59
Done.
|
+ * thread of PPAPI execution. If the completion callback is NULL, then the |
+ * operation will block if necessary to complete its work. |
+ * <code>PP_BlockUntilComplete()</code> provides a convenient way to specify |
+ * blocking behavior. Refer to <code>PP_BlockUntilComplete</code> for more |
+ * information. |
* |
- * If PP_CompletionCallback_Func is NULL, the operation might block if necessary |
- * to complete the work. Refer to PP_BlockUntilComplete for more information. |
- * |
- * See PP_MakeCompletionCallback() for the description of each field. |
+ * The result parameter passes an int32_t that, if negative or equal to 0, |
der Springer
2011/08/09 20:40:40
"...parameter passed to |func| is an int32_t that,
jond
2011/08/10 21:05:59
Done.
jond
2011/08/10 21:05:59
Done.
|
+ * indicate if the call will complete asynchronously (the callback will be |
+ * called with a status code). A value greater than zero indicates additional |
+ * information such as bytes read. |
der Springer
2011/08/09 20:40:40
I think |result| is actually an error or result co
jond
2011/08/10 21:05:59
Done.
|
*/ |
struct PP_CompletionCallback { |
+ /** |
+ * This value is a callback function that will be called. |
+ */ |
PP_CompletionCallback_Func func; |
+ |
+ /** |
+ * This value is a pointer to user data passed to a callback function. |
+ */ |
void* user_data; |
+ |
+ /** |
+ * Flags used to control how non-NULL callbacks are scheduled by |
+ * asynchronous methods. |
+ */ |
int32_t flags; |
}; |
/** |
@@ -102,20 +120,15 @@ |
* @{ |
*/ |
/** |
- * PP_MakeCompletionCallback() is used to create a PP_CompletionCallback |
- * without flags. If you want to alter the default callback behavior, set the |
- * flags to a bit field combination of PP_CompletionCallback_Flag's. |
+ * PP_MakeCompletionCallback() is used to create a |
+ * <code>PP_CompletionCallback</code>. |
* |
- * Example: |
- * struct PP_CompletionCallback cc = PP_MakeCompletionCallback(Foo, NULL); |
- * cc.flags = cc.flags | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL; |
- * |
- * @param[in] func A PP_CompletionCallback_Func to be called on completion. |
- * @param[in] user_data A pointer to user data passed to be passed to the |
- * callback function. This is optional and is typically used to help track state |
- * in case of multiple pending callbacks. |
- * |
- * @return A PP_CompletionCallback structure. |
+ * @param[in] func A <code>PP_CompletionCallback_Func</code> that will be |
+ * called. |
+ * @param[in] user_data A pointer to user data passed to your callback |
+ * function. This is optional and is typically used to help track state |
+ * when you may have multiple callbacks pending. |
+ * @return A <code>PP_CompletionCallback</code> structure. |
*/ |
PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback( |
PP_CompletionCallback_Func func, |
@@ -160,7 +173,8 @@ |
* the callback function passing it user data specified on creation and |
* completion |result|. |
* |
- * @param[in] cc A pointer to a PP_CompletionCallback that will be run. |
+ * @param[in] cc A pointer to a <code>PP_CompletionCallback</code> that will be |
+ * run. |
* @param[in] result The result of the operation. Non-positive values correspond |
* to the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING). |
* Positive values indicate additional information such as bytes read. |
@@ -185,24 +199,24 @@ |
* until the function completes. Blocking completion callbacks are only allowed |
* from background threads. |
* |
- * @return A PP_CompletionCallback structure corresponding to a NULL callback. |
+ * @return A <code>PP_CompletionCallback</code> structure. |
*/ |
PP_INLINE struct PP_CompletionCallback PP_BlockUntilComplete() { |
return PP_MakeCompletionCallback(NULL, NULL); |
} |
/** |
- * Runs a callback and clears the reference to it. |
+ * PP_RunAndClearCompletionCallback() runs a callback and clears the reference |
+ * to that callback. |
* |
- * This is used when the null-ness of a completion callback is used as a signal |
- * for whether a completion callback has been registered. In this case, after |
- * the execution of the callback, it should be cleared. |
- * |
- * However, this introduces a conflict if the completion callback wants to |
- * schedule more work that involves the same completion callback again (for |
- * example, when reading data from an URLLoader, one would typically queue up |
+ * This function is used when the null-ness of a completion callback is used as |
+ * a signal for whether a completion callback has been registered. In this |
+ * case, after the execution of the callback, it should be cleared. However, |
+ * this introduces a conflict if the completion callback wants to schedule more |
+ * work that involves the same completion callback again (for example, when |
+ * reading data from an URLLoader, one would typically queue up |
* another read callback). As a result, this function clears the pointer |
- * *before* the given callback is executed. |
+ * before the provided callback is executed. |
*/ |
PP_INLINE void PP_RunAndClearCompletionCallback( |
struct PP_CompletionCallback* cc, |