Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1264)

Unified Diff: ppapi/c/ppb_url_loader.h

Issue 11417145: Provide a safer URLLoader ReadResponseBody API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/api/ppb_url_loader.idl ('k') | ppapi/cpp/file_io.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/c/ppb_url_loader.h
diff --git a/ppapi/c/ppb_url_loader.h b/ppapi/c/ppb_url_loader.h
index c19cc9d444f966684e04825b24b876d739546405..9a3588e0876d4765c0a27567488d810c66f93748 100644
--- a/ppapi/c/ppb_url_loader.h
+++ b/ppapi/c/ppb_url_loader.h
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-/* From ppb_url_loader.idl modified Wed Oct 5 14:06:02 2011. */
+/* From ppb_url_loader.idl modified Thu Nov 22 16:52:29 2012. */
#ifndef PPAPI_C_PPB_URL_LOADER_H_
#define PPAPI_C_PPB_URL_LOADER_H_
+#include "ppapi/c/pp_array_output.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_instance.h"
@@ -16,7 +17,8 @@
#include "ppapi/c/pp_stdint.h"
#define PPB_URLLOADER_INTERFACE_1_0 "PPB_URLLoader;1.0"
-#define PPB_URLLOADER_INTERFACE PPB_URLLOADER_INTERFACE_1_0
+#define PPB_URLLOADER_INTERFACE_1_1 "PPB_URLLoader;1.1"
+#define PPB_URLLOADER_INTERFACE PPB_URLLOADER_INTERFACE_1_1
/**
* @file
@@ -48,7 +50,7 @@
* - Then, access the downloaded file using the GetBodyAsFileRef() function of
* the <code>URLResponseInfo</code> returned in step #4.
*/
-struct PPB_URLLoader_1_0 {
+struct PPB_URLLoader_1_1 {
/**
* Create() creates a new <code>URLLoader</code> object. The
* <code>URLLoader</code> is associated with a particular instance, so that
@@ -166,6 +168,9 @@ struct PPB_URLLoader_1_0 {
* buffer must be large enough to hold the specified number of bytes to read.
* This function might perform a partial read.
*
+ * ReadResponseBodyToArray() is preferred to ReadResponseBody() when doing
+ * asynchronous operations.
+ *
* @param[in] loader A <code>PP_Resource</code> corresponding to a
* <code>URLLoader</code>.
* @param[in,out] buffer A pointer to the buffer for the response body.
@@ -215,9 +220,54 @@ struct PPB_URLLoader_1_0 {
* <code>URLLoader</code>.
*/
void (*Close)(PP_Resource loader);
+ /**
+ * ReadResponseBody() 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.
+ *
+ * @param[in] loader A <code>PP_Resource</code> corresponding to a
+ * <code>URLLoader</code>.
+ * @param[in,out] output A <code>PP_ArrayOutput</code> to hold the output.
+ * @param[in] max_read_length The number of bytes to read.
+ * @param[in] callback A <code>PP_CompletionCallback</code> 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 <code>PP_OK_COMPLETIONPENDING</code>.
+ *
+ * @return An int32_t containing the number of bytes read or an error code
+ * from <code>pp_errors.h</code>.
+ */
+ int32_t (*ReadResponseBodyToArray)(PP_Resource loader,
+ int32_t max_read_length,
+ struct PP_ArrayOutput* output,
+ struct PP_CompletionCallback callback);
};
-typedef struct PPB_URLLoader_1_0 PPB_URLLoader;
+typedef struct PPB_URLLoader_1_1 PPB_URLLoader;
+
+struct PPB_URLLoader_1_0 {
+ PP_Resource (*Create)(PP_Instance instance);
+ PP_Bool (*IsURLLoader)(PP_Resource resource);
+ int32_t (*Open)(PP_Resource loader,
+ PP_Resource request_info,
+ struct PP_CompletionCallback callback);
+ int32_t (*FollowRedirect)(PP_Resource loader,
+ struct PP_CompletionCallback callback);
+ PP_Bool (*GetUploadProgress)(PP_Resource loader,
+ int64_t* bytes_sent,
+ int64_t* total_bytes_to_be_sent);
+ PP_Bool (*GetDownloadProgress)(PP_Resource loader,
+ int64_t* bytes_received,
+ int64_t* total_bytes_to_be_received);
+ PP_Resource (*GetResponseInfo)(PP_Resource loader);
+ int32_t (*ReadResponseBody)(PP_Resource loader,
+ void* buffer,
+ int32_t bytes_to_read,
+ struct PP_CompletionCallback callback);
+ int32_t (*FinishStreamingToFile)(PP_Resource loader,
+ struct PP_CompletionCallback callback);
+ void (*Close)(PP_Resource loader);
+};
/**
* @}
*/
« no previous file with comments | « ppapi/api/ppb_url_loader.idl ('k') | ppapi/cpp/file_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698