Support asynchronous continuation of custom scheme handler responses (issue #269).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@278 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-08-17 01:55:07 +00:00
parent ad66d3774c
commit 88a46e0b44
14 changed files with 693 additions and 258 deletions

View File

@@ -2270,7 +2270,36 @@ typedef struct _cef_scheme_handler_factory_t
///
// Structure used to represent a custom scheme handler structure. The functions
// Structure used to facilitate asynchronous responses to custom scheme handler
// requests. The functions of this structure may be called on any thread.
///
typedef struct _cef_scheme_handler_callback_t
{
// Base structure.
cef_base_t base;
///
// Notify that header information is now available for retrieval.
///
void (CEF_CALLBACK *headers_available)(
struct _cef_scheme_handler_callback_t* self);
///
// Notify that response data is now available for reading.
///
void (CEF_CALLBACK *bytes_available)(
struct _cef_scheme_handler_callback_t* self);
///
// Cancel processing of the request.
///
void (CEF_CALLBACK *cancel)(struct _cef_scheme_handler_callback_t* self);
} cef_scheme_handler_callback_t;
///
// Structure used to implement a custom scheme handler structure. The functions
// of this structure will always be called on the IO thread.
///
typedef struct _cef_scheme_handler_t
@@ -2279,35 +2308,44 @@ typedef struct _cef_scheme_handler_t
cef_base_t base;
///
// Process the request. All response generation should take place in this
// function. If there is no response set |response_length| to zero or return
// false (0) and read_response() will not be called. If the response length is
// not known set |response_length| to -1 and read_response() will be called
// until it returns false (0) or until the value of |bytes_read| is set to 0.
// If the response length is known set |response_length| to a positive value
// and read_response() will be called until it returns false (0), the value of
// |bytes_read| is set to 0 or the specified number of bytes have been read.
// Use the |response| object to set the mime type, http status code and
// optional header values for the response and return true (1). To redirect
// the request to a new URL set |redirectUrl| to the new URL and return true
// (1).
// Begin processing the request. To handle the request return true (1) and
// call headers_available() once the response header information is available
// (headers_available() can also be called from inside this function if header
// information is available immediately). To redirect the request to a new URL
// set |redirectUrl| to the new URL and return true (1). To cancel the request
// return false (0).
///
int (CEF_CALLBACK *process_request)(struct _cef_scheme_handler_t* self,
struct _cef_request_t* request, cef_string_t* redirectUrl,
struct _cef_response_t* response, int* response_length);
struct _cef_scheme_handler_callback_t* callback);
///
// Cancel processing of the request.
// Retrieve response header information. If the response length is not known
// set |response_length| to -1 and read_response() will be called until it
// returns false (0). If the response length is known set |response_length| to
// a positive value and read_response() will be called until it returns false
// (0) or the specified number of bytes have been read. Use the |response|
// object to set the mime type, http status code and other optional header
// values.
///
void (CEF_CALLBACK *cancel)(struct _cef_scheme_handler_t* self);
void (CEF_CALLBACK *get_response_headers)(struct _cef_scheme_handler_t* self,
struct _cef_response_t* response, int64* response_length);
///
// Copy up to |bytes_to_read| bytes into |data_out|. If the copy succeeds set
// |bytes_read| to the number of bytes copied and return true (1). If the copy
// fails return false (0) and read_response() will not be called again.
// Read response data. If data is available immediately copy up to
// |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of
// bytes copied, and return true (1). To read the data at a later time set
// |bytes_read| to 0, return true (1) and call bytes_available() when the data
// is available. To indicate response completion return false (0).
///
int (CEF_CALLBACK *read_response)(struct _cef_scheme_handler_t* self,
void* data_out, int bytes_to_read, int* bytes_read);
void* data_out, int bytes_to_read, int* bytes_read,
struct _cef_scheme_handler_callback_t* callback);
///
// Request processing has been canceled.
///
void (CEF_CALLBACK *cancel)(struct _cef_scheme_handler_t* self);
} cef_scheme_handler_t;