Inheritance diagram for pp::CompletionCallback:

List of all members.

Public Member Functions

 CompletionCallback ()
 CompletionCallback (PP_CompletionCallback_Func func, void *user_data)
 CompletionCallback (PP_CompletionCallback_Func func, void *user_data, int32_t flags)
void set_flags (int32_t flags)
void Run (int32_t result)
void RunAndClear (int32_t result)
bool IsOptional () const
const PP_CompletionCallback & pp_completion_callback () const
int32_t flags () const
int32_t MayForce (int32_t result) const

Protected Attributes

PP_CompletionCallback cc_

Detailed Description

This API enables you to implement and receive callbacks when Pepper operations complete asynchronously.

You can create these objects yourself, but it is most common to use the CompletionCallbackFactory to allow the callbacks to call class member functions.


Constructor & Destructor Documentation

The default constructor will create a blocking CompletionCallback that can be passed to a method to indicate that the calling thread should be blocked until the asynchronous operation corresponding to the method completes.

Note: Blocking completion callbacks are only allowed from from background threads.

pp::CompletionCallback::CompletionCallback(PP_CompletionCallback_Func func,
void * user_data 
) [inline]

A constructor for creating a CompletionCallback.

Parameters:
[in]funcThe function to be called on completion.
[in]user_dataThe user data to be passed to the callback function. This is optional and is typically used to help track state in case of multiple pending callbacks.
pp::CompletionCallback::CompletionCallback(PP_CompletionCallback_Func func,
void * user_data,
int32_t flags 
) [inline]

A constructor for creating a CompletionCallback with specified flags.

Parameters:
[in]funcThe function to be called on completion.
[in]user_dataThe user data to be passed to the callback function. This is optional and is typically used to help track state in case of multiple pending callbacks.
[in]flagsBit field combination of PP_CompletionCallback_Flag flags used to control how non-NULL callbacks are scheduled by asynchronous methods.

Member Function Documentation

int32_t pp::CompletionCallback::flags()const [inline]

The flags() function returns flags used to control how non-NULL callbacks are scheduled by asynchronous methods.

Returns:
An int32_t containing a bit field combination of PP_CompletionCallback_Flag flags.

IsOptional() is used to determine the setting of the PP_COMPLETIONCALLBACK_FLAG_OPTIONAL flag.

This flag allows any method taking such callback to complete synchronously and not call the callback if the operation would not block. This is useful when performance is an issue, and the operation bandwidth should not be limited to the processing speed of the message loop.

On synchronous method completion, the completion result will be returned by the method itself. Otherwise, the method will return PP_OK_COMPLETIONPENDING, and the callback will be invoked asynchronously on the same thread where the PPB method was invoked.

Returns:
true if this callback is optional, otherwise false.
int32_t pp::CompletionCallback::MayForce(int32_t result)const [inline]

MayForce() is used when implementing functions taking callbacks.

If the callback is required and result indicates that it has not been scheduled, it will be forced on the main thread.

Example:

 int32_t OpenURL(pp::URLLoader* loader,
                 pp::URLRequestInfo* url_request_info,
                 const CompletionCallback& cc) {
   if (loader == NULL || url_request_info == NULL)
     return cc.MayForce(PP_ERROR_BADRESOURCE);
   return loader->Open(*loader, *url_request_info, cc);
 }
Parameters:
[in]resultPP_OK_COMPLETIONPENDING or the result of the completed operation to be passed to the callback function. PP_OK_COMPLETIONPENDING indicates that the callback has already been scheduled. Other non-positive values correspond to error codes from pp_errors.h. Positive values indicate additional information such as bytes read.
Returns:
PP_OK_COMPLETIONPENDING if the callback has been forced, result parameter otherwise.
const PP_CompletionCallback& pp::CompletionCallback::pp_completion_callback()const [inline]

The pp_completion_callback() function returns the underlying PP_CompletionCallback

Returns:
A PP_CompletionCallback.
void pp::CompletionCallback::Run(int32_t result) [inline]

Run() is used to run the CompletionCallback.

Normally, the system runs a CompletionCallback after an asynchronous operation completes, but programs may wish to run the CompletionCallback manually in order to reuse the same code paths.

Parameters:
[in]resultThe result of the operation to be passed to the callback function. 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.
void pp::CompletionCallback::RunAndClear(int32_t result) [inline]

RunAndClear() is used to run the CompletionCallback and clear out the callback so that it cannot be run a second time.

Parameters:
[in]resultThe result of the operation to be passed to the callback function. 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.
void pp::CompletionCallback::set_flags(int32_t flags) [inline]

The set_flags() function is used to set the flags used to control how non-NULL callbacks are scheduled by asynchronous methods.

Parameters:
[in]flagsBit field combination of PP_CompletionCallback_Flag flags used to control how non-NULL callbacks are scheduled by asynchronous methods.

Member Data Documentation

PP_CompletionCallback pp::CompletionCallback::cc_ [protected]

The documentation for this class was generated from the following file:
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.