summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 19:39:29 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 19:39:29 +0000
commit51df0c71a8a411016c23645be92e2066160a464a (patch)
tree238fde8421a1a818da2026ab7e9574969b33aba4 /ppapi
parent1de08b360a306baa27e5f810fa5b5dd7a382ccde (diff)
downloadchromium_src-51df0c71a8a411016c23645be92e2066160a464a.zip
chromium_src-51df0c71a8a411016c23645be92e2066160a464a.tar.gz
chromium_src-51df0c71a8a411016c23645be92e2066160a464a.tar.bz2
Add callback ability for URLLoader so an asynchronous proxy can send the
current progress to another process. Adds a DOWNLOADPROGRESS flag to track download progress to be symetrical with the upload progress. I implemented the backend of these two flags and made it refuse to provide progress unless these flags were set. TEST=none BUG=none Review URL: http://codereview.chromium.org/4423001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_url_loader_dev.h25
-rw-r--r--ppapi/c/dev/ppb_url_loader_trusted_dev.h28
-rw-r--r--ppapi/c/dev/ppb_url_request_info_dev.h14
3 files changed, 56 insertions, 11 deletions
diff --git a/ppapi/c/dev/ppb_url_loader_dev.h b/ppapi/c/dev/ppb_url_loader_dev.h
index 44f4dc90..9d63b31 100644
--- a/ppapi/c/dev/ppb_url_loader_dev.h
+++ b/ppapi/c/dev/ppb_url_loader_dev.h
@@ -52,20 +52,27 @@ struct PPB_URLLoader_Dev {
struct PP_CompletionCallback callback);
// Returns the current upload progress, which is meaningful after Open has
- // been called, and the request given to Open must have been configured with
- // PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS set to true. Progress only
- // refers to the request body. This data is only available if the
- // PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS was set to true on the
- // URLRequestInfo. This method returns false if upload progress is not
- // available.
+ // 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 flag set to true.
+ //
+ // This method returns false if upload progress is not available.
bool (*GetUploadProgress)(PP_Resource loader,
int64_t* bytes_sent,
int64_t* total_bytes_to_be_sent);
// Returns the current download progress, which is meaningful after Open has
- // been called. Progress only refers to the response body. The total bytes
- // to be received may be unknown, in which case -1 is returned. This method
- // returns false if download progress is not available.
+ // 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 flag set to true.
+ //
+ // The total bytes to be received may be unknown, in which case
+ // total_bytes_to_be_received will be set to -1. This method returns false if
+ // download progress is not available.
bool (*GetDownloadProgress)(PP_Resource loader,
int64_t* bytes_received,
int64_t* total_bytes_to_be_received);
diff --git a/ppapi/c/dev/ppb_url_loader_trusted_dev.h b/ppapi/c/dev/ppb_url_loader_trusted_dev.h
index 4eabe14..84aff0e 100644
--- a/ppapi/c/dev/ppb_url_loader_trusted_dev.h
+++ b/ppapi/c/dev/ppb_url_loader_trusted_dev.h
@@ -5,15 +5,41 @@
#ifndef PPAPI_C_DEV_PPB_URL_LOADER_TRUSTED_DEV_H_
#define PPAPI_C_DEV_PPB_URL_LOADER_TRUSTED_DEV_H_
+#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
-#define PPB_URLLOADERTRUSTED_DEV_INTERFACE "PPB_URLLoaderTrusted(Dev);0.1"
+#define PPB_URLLOADERTRUSTED_DEV_INTERFACE "PPB_URLLoaderTrusted(Dev);0.2"
+
+// Callback that indicates the status of the download and upload for the
+// given URLLoader resource.
+typedef void (*PP_URLLoaderTrusted_StatusCallback)(
+ PP_Instance pp_instance,
+ PP_Resource pp_resource,
+ int64_t bytes_sent,
+ int64_t total_bytes_to_be_sent,
+ int64_t bytes_received,
+ int64_t total_bytes_to_be_received);
// Available only to trusted implementations.
struct PPB_URLLoaderTrusted_Dev {
// Grant this URLLoader the capability to make unrestricted cross-origin
// requests.
void (*GrantUniversalAccess)(PP_Resource loader);
+
+ // Registers that the given function will be called when the upload or
+ // downloaded byte count has changed. This is not exposed on the untrusted
+ // interface because it can be quite chatty and encourages people to write
+ // feedback UIs that update as frequently as the progress updates.
+ //
+ // The other serious gotcha with this callback is that the callback must not
+ // mutate the URL loader or cause it to be destroyed.
+ //
+ // However, the proxy layer needs this information to push to the other
+ // process, so we expose it here. Only one callback can be set per URL
+ // Loader. Setting to a NULL callback will disable it.
+ void (*RegisterStatusCallback)(PP_Resource loader,
+ PP_URLLoaderTrusted_StatusCallback cb);
};
#endif // PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_
diff --git a/ppapi/c/dev/ppb_url_request_info_dev.h b/ppapi/c/dev/ppb_url_request_info_dev.h
index 2503a0c..9916804 100644
--- a/ppapi/c/dev/ppb_url_request_info_dev.h
+++ b/ppapi/c/dev/ppb_url_request_info_dev.h
@@ -18,7 +18,19 @@ typedef enum {
PP_URLREQUESTPROPERTY_HEADERS, // string, \n-delim
PP_URLREQUESTPROPERTY_STREAMTOFILE, // bool (default=false)
PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, // bool (default=true)
- PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS // bool (default=false)
+
+ // Set to true if you want to be able to poll the download progress via the
+ // URLLoader.GetDownloadProgress function.
+ //
+ // Boolean (default = false).
+ PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS,
+
+ // Set to true if you want to be able to pull the upload progress via the
+ // URLLoader.GetUploadProgress function.
+ //
+ // Boolean (default = false).
+ PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS
+
// TODO(darin): Add security/privacy options?
} PP_URLRequestProperty_Dev;