Pepper_42_C++_interfaces
|
#include <url_loader.h>
Public Member Functions | |
URLLoader () | |
URLLoader (PP_Resource resource) | |
URLLoader (const InstanceHandle &instance) | |
URLLoader (const URLLoader &other) | |
int32_t | Open (const URLRequestInfo &request_info, const CompletionCallback &cc) |
int32_t | FollowRedirect (const CompletionCallback &cc) |
bool | GetUploadProgress (int64_t *bytes_sent, int64_t *total_bytes_to_be_sent) const |
bool | GetDownloadProgress (int64_t *bytes_received, int64_t *total_bytes_to_be_received) const |
URLResponseInfo | GetResponseInfo () const |
int32_t | ReadResponseBody (void *buffer, int32_t bytes_to_read, const CompletionCallback &cc) |
int32_t | FinishStreamingToFile (const CompletionCallback &cc) |
void | Close () |
![]() | |
Resource () | |
The default constructor. More... | |
Resource (const Resource &other) | |
virtual | ~Resource () |
Destructor. More... | |
Resource & | operator= (const Resource &other) |
bool | is_null () const |
PP_Resource | pp_resource () const |
PP_Resource | detach () |
Additional Inherited Members | |
![]() | |
Resource (PP_Resource resource) | |
Resource (PassRef, PP_Resource resource) | |
void | PassRefFromConstructor (PP_Resource resource) |
void | Clear () |
Sets this resource to null. This releases ownership of the resource. More... | |
URLLoader provides an API for loading URLs. Refer to ppapi/examples/url_loader/streaming.cc
for an example of how to use this class.
Definition at line 23 of file url_loader.h.
|
inline |
Default constructor for creating an is_null() URLLoader
object.
Definition at line 27 of file url_loader.h.
|
explicit |
A constructor used when a PP_Resource
is provided as a return value whose reference count we need to increment.
[in] | resource | A PP_Resource corresponding to a URLLoader resource. |
|
explicit |
A constructor used to allocate a new URLLoader in the browser. The resulting object will be is_null
if the allocation failed.
[in] | instance | The instance with which this resource will be associated. |
pp::URLLoader::URLLoader | ( | const URLLoader & | other | ) |
void pp::URLLoader::Close | ( | ) |
This function is used to cancel any pending IO and close the URLLoader object. Any pending callbacks will still run, reporting PP_ERROR_ABORTED
if pending IO was interrupted. It is NOT valid to call Open() again after a call to this function.
Note: If the URLLoader
object is destroyed while it is still open, then it will be implicitly closed so you are not required to call Close().
int32_t pp::URLLoader::FinishStreamingToFile | ( | const CompletionCallback & | cc | ) |
This function is used to wait for the response body to be completely downloaded to the file provided by the GetBodyAsFileRef() in the current URLResponseInfo
. This function is only used if PP_URLREQUESTPROPERTY_STREAMTOFILE
was set on the URLRequestInfo
passed to Open().
[in] | cc | A CompletionCallback to run on asynchronous completion. This callback will run when body is downloaded or an error occurs after FinishStreamingToFile() returns PP_OK_COMPLETIONPENDING . |
pp_errors.h
. int32_t pp::URLLoader::FollowRedirect | ( | const CompletionCallback & | cc | ) |
This function can be invoked to follow a redirect after Open() completed on receiving redirect headers.
[in] | cc | A CompletionCallback to run on asynchronous completion of FollowRedirect(). This callback will run when response headers for the redirect url are received or error occurred. This callback will only run if FollowRedirect() returns PP_OK_COMPLETIONPENDING . |
pp_errors.h
. bool pp::URLLoader::GetDownloadProgress | ( | int64_t * | bytes_received, |
int64_t * | total_bytes_to_be_received | ||
) | const |
This function returns the current download progress, which is meaningful after Open() has been called. Progress only refers to the response body and does not include the headers.
This data is only available if the URLRequestInfo
passed to Open() had the PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS
property set to PP_TRUE.
[in] | bytes_received | The number of bytes received thus far. |
[in] | total_bytes_to_be_received | The total number of bytes to be received. The total bytes to be received may be unknown, in which case total_bytes_to_be_received will be set to -1. |
URLResponseInfo pp::URLLoader::GetResponseInfo | ( | ) | const |
This is a function that returns the current URLResponseInfo
object.
URLResponseInfo
corresponding to the URLResponseInfo
if successful, an is_null
object if the loader is not a valid resource or if Open() has not been called. bool pp::URLLoader::GetUploadProgress | ( | int64_t * | bytes_sent, |
int64_t * | total_bytes_to_be_sent | ||
) | const |
This function returns the current upload progress (which is only meaningful after Open() has been called). Progress only refers to the request body and does not include the headers.
This data is only available if the URLRequestInfo
passed to Open() had the PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS
property set to PP_TRUE
.
[in] | bytes_sent | The number of bytes sent thus far. |
[in] | total_bytes_to_be_sent | The total number of bytes to be sent. |
int32_t pp::URLLoader::Open | ( | const URLRequestInfo & | request_info, |
const CompletionCallback & | cc | ||
) |
This function begins loading the URLRequestInfo
. The operation completes when response headers are received or when an error occurs. Use GetResponseInfo() to access the response headers.
[in] | request_info | A URLRequestInfo corresponding to a URLRequestInfo. |
[in] | cc | A CompletionCallback to run on asynchronous completion of Open(). This callback will run when response headers for the url are received or error occurred. This callback will only run if Open() returns PP_OK_COMPLETIONPENDING . |
pp_errors.h
. int32_t pp::URLLoader::ReadResponseBody | ( | void * | buffer, |
int32_t | bytes_to_read, | ||
const CompletionCallback & | cc | ||
) |
This function is used to read the response body. The size of the buffer must be large enough to hold the specified number of bytes to read. This function might perform a partial read.
[in,out] | buffer | A pointer to the buffer for the response body. |
[in] | bytes_to_read | The number of bytes to read. |
[in] | cc | A CompletionCallback to run on asynchronous completion. The callback will run if the bytes (full or partial) are read or an error occurs asynchronously. This callback will run only if this function returns PP_OK_COMPLETIONPENDING . |
pp_errors.h
.