| OLD | NEW |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #ifndef PPAPI_C_PPB_URL_LOADER_H_ | 5 #ifndef PPAPI_C_PPB_URL_LOADER_H_ |
| 6 #define PPAPI_C_PPB_URL_LOADER_H_ | 6 #define PPAPI_C_PPB_URL_LOADER_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 */ | 47 */ |
| 48 struct PPB_URLLoader { | 48 struct PPB_URLLoader { |
| 49 /** | 49 /** |
| 50 * Create() creates a new <code>URLLoader</code> object. The | 50 * Create() creates a new <code>URLLoader</code> object. The |
| 51 * <code>URLLoader</code> is associated with a particular instance, so that | 51 * <code>URLLoader</code> is associated with a particular instance, so that |
| 52 * any UI dialogs that need to be shown to the user can be positioned | 52 * any UI dialogs that need to be shown to the user can be positioned |
| 53 * relative to the window containing the instance. | 53 * relative to the window containing the instance. |
| 54 * | 54 * |
| 55 * @param[in] instance A <code>PP_Instance</code> indentifying one instance | 55 * @param[in] instance A <code>PP_Instance</code> indentifying one instance |
| 56 * of a module. | 56 * of a module. |
| 57 * |
| 57 * @return A <code>PP_Resource</code> corresponding to a URLLoader if | 58 * @return A <code>PP_Resource</code> corresponding to a URLLoader if |
| 58 * successful, 0 if the instance is invalid. | 59 * successful, 0 if the instance is invalid. |
| 59 */ | 60 */ |
| 60 PP_Resource (*Create)(PP_Instance instance); | 61 PP_Resource (*Create)(PP_Instance instance); |
| 61 | 62 |
| 62 /** | 63 /** |
| 63 * IsURLLoader() determines if a resource is an <code>URLLoader</code>. | 64 * IsURLLoader() determines if a resource is an <code>URLLoader</code>. |
| 64 * | 65 * |
| 65 * @param[in] resource A <code>PP_Resource</code> corresponding to a | 66 * @param[in] resource A <code>PP_Resource</code> corresponding to a |
| 66 * <code>URLLoader</code>. | 67 * <code>URLLoader</code>. |
| 68 * |
| 67 * @return <code>PP_TRUE</code> if the resource is a <code>URLLoader</code>, | 69 * @return <code>PP_TRUE</code> if the resource is a <code>URLLoader</code>, |
| 68 * <code>PP_FALSE</code> if the resource is invalid or some type other | 70 * <code>PP_FALSE</code> if the resource is invalid or some type other |
| 69 * than <code>URLLoader</code>. | 71 * than <code>URLLoader</code>. |
| 70 */ | 72 */ |
| 71 PP_Bool (*IsURLLoader)(PP_Resource resource); | 73 PP_Bool (*IsURLLoader)(PP_Resource resource); |
| 72 | 74 |
| 73 /** | 75 /** |
| 74 * Open() begins loading the <code>URLRequestInfo</code>. The operation | 76 * Open() begins loading the <code>URLRequestInfo</code>. The operation |
| 75 * completes when response headers are received or when an error occurs. Use | 77 * completes when response headers are received or when an error occurs. Use |
| 76 * GetResponseInfo() to access the response headers. | 78 * GetResponseInfo() to access the response headers. |
| 77 * | 79 * |
| 78 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 80 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 79 * <code>URLLoader</code>. | 81 * <code>URLLoader</code>. |
| 80 * @param[in] resource A <code>PP_Resource</code> corresponding to a | 82 * @param[in] resource A <code>PP_Resource</code> corresponding to a |
| 81 * <code>URLRequestInfo</code>. | 83 * <code>URLRequestInfo</code>. |
| 82 * @param[in] callback A <code>PP_CompletionCallback</code> to run on | 84 * @param[in] callback A <code>PP_CompletionCallback</code> to run on |
| 83 * asynchronous completion of Open(). This callback will run when response | 85 * asynchronous completion of Open(). This callback will run when response |
| 84 * headers for the url are received or error occured. This callback | 86 * headers for the url are received or error occured. This callback |
| 85 * will only run if Open() returns <code>PP_OK_COMPLETIONPENDING</code>. | 87 * will only run if Open() returns <code>PP_OK_COMPLETIONPENDING</code>. |
| 88 * |
| 89 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 86 */ | 90 */ |
| 87 int32_t (*Open)(PP_Resource loader, | 91 int32_t (*Open)(PP_Resource loader, |
| 88 PP_Resource request_info, | 92 PP_Resource request_info, |
| 89 struct PP_CompletionCallback callback); | 93 struct PP_CompletionCallback callback); |
| 90 | 94 |
| 91 /** | 95 /** |
| 92 * FollowRedirect()can be invoked to follow a redirect after Open() completed | 96 * FollowRedirect()can be invoked to follow a redirect after Open() completed |
| 93 * on receiving redirect headers. | 97 * on receiving redirect headers. |
| 94 * | 98 * |
| 95 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 99 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 96 * <code>URLLoader</code>. | 100 * <code>URLLoader</code>. |
| 97 * @param[in] callback A <code>PP_CompletionCallback</code> to run on | 101 * @param[in] callback A <code>PP_CompletionCallback</code> to run on |
| 98 * asynchronous completion of FollowRedirect(). This callback will run when | 102 * asynchronous completion of FollowRedirect(). This callback will run when |
| 99 * response headers for the redirect url are received or error occured. This | 103 * response headers for the redirect url are received or error occured. This |
| 100 * callback will only run if FollowRedirect() returns | 104 * callback will only run if FollowRedirect() returns |
| 101 * <code>PP_OK_COMPLETIONPENDING</code>. | 105 * <code>PP_OK_COMPLETIONPENDING</code>. |
| 106 * |
| 102 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 107 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 103 */ | 108 */ |
| 104 int32_t (*FollowRedirect)(PP_Resource loader, | 109 int32_t (*FollowRedirect)(PP_Resource loader, |
| 105 struct PP_CompletionCallback callback); | 110 struct PP_CompletionCallback callback); |
| 106 | 111 |
| 107 /** | 112 /** |
| 108 * GetUploadProgress() returns the current upload progress (which is | 113 * GetUploadProgress() returns the current upload progress (which is |
| 109 * meaningful after Open() has been called). Progress only refers to the | 114 * meaningful after Open() has been called). Progress only refers to the |
| 110 * request body and does not include the headers. | 115 * request body and does not include the headers. |
| 111 * | 116 * |
| 112 * This data is only available if the <code>URLRequestInfo</code> passed | 117 * This data is only available if the <code>URLRequestInfo</code> passed |
| 113 * to Open() had the <code>PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS</code> | 118 * to Open() had the <code>PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS</code> |
| 114 * property set to PP_TRUE. | 119 * property set to PP_TRUE. |
| 115 * | 120 * |
| 116 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 121 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 117 * <code>URLLoader</code>. | 122 * <code>URLLoader</code>. |
| 118 * @param[in] bytes_sent The number of bytes sent thus far. | 123 * @param[in] bytes_sent The number of bytes sent thus far. |
| 119 * @param[in] total_bytes_to_be_sent The total number of bytes to be sent. | 124 * @param[in] total_bytes_to_be_sent The total number of bytes to be sent. |
| 125 * |
| 120 * @return <code>PP_TRUE</code> if the upload progress is available, | 126 * @return <code>PP_TRUE</code> if the upload progress is available, |
| 121 * <code>PP_FALSE</code> if it is not available. | 127 * <code>PP_FALSE</code> if it is not available. |
| 122 */ | 128 */ |
| 123 PP_Bool (*GetUploadProgress)(PP_Resource loader, | 129 PP_Bool (*GetUploadProgress)(PP_Resource loader, |
| 124 int64_t* bytes_sent, | 130 int64_t* bytes_sent, |
| 125 int64_t* total_bytes_to_be_sent); | 131 int64_t* total_bytes_to_be_sent); |
| 126 | 132 |
| 127 /** | 133 /** |
| 128 * GetDownloadProgress() returns the current download progress, which is | 134 * GetDownloadProgress() returns the current download progress, which is |
| 129 * meaningful after Open() has been called. Progress only refers to the | 135 * meaningful after Open() has been called. Progress only refers to the |
| 130 * response body and does not include the headers. | 136 * response body and does not include the headers. |
| 131 * | 137 * |
| 132 * This data is only available if the <code>URLRequestInfo</code> passed to | 138 * This data is only available if the <code>URLRequestInfo</code> passed to |
| 133 * Open() had the <code>PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS</code> | 139 * Open() had the <code>PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS</code> |
| 134 * property set to <code>PP_TRUE</code>. | 140 * property set to <code>PP_TRUE</code>. |
| 135 * | 141 * |
| 136 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 142 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 137 * <code>URLLoader</code>. | 143 * <code>URLLoader</code>. |
| 138 * @param[in] bytes_received The number of bytes received thus far. | 144 * @param[in] bytes_received The number of bytes received thus far. |
| 139 * @param[in] total_bytes_to_be_received The total number of bytes to be | 145 * @param[in] total_bytes_to_be_received The total number of bytes to be |
| 140 * received. The total bytes to be received may be unknown, in which case | 146 * received. The total bytes to be received may be unknown, in which case |
| 141 * <code>total_bytes_to_be_received</code> will be set to -1. | 147 * <code>total_bytes_to_be_received</code> will be set to -1. |
| 148 * |
| 142 * @return <code>PP_TRUE</code> if the download progress is available, | 149 * @return <code>PP_TRUE</code> if the download progress is available, |
| 143 * <code>PP_FALSE</code> if it is not available. | 150 * <code>PP_FALSE</code> if it is not available. |
| 144 */ | 151 */ |
| 145 PP_Bool (*GetDownloadProgress)(PP_Resource loader, | 152 PP_Bool (*GetDownloadProgress)(PP_Resource loader, |
| 146 int64_t* bytes_received, | 153 int64_t* bytes_received, |
| 147 int64_t* total_bytes_to_be_received); | 154 int64_t* total_bytes_to_be_received); |
| 148 | 155 |
| 149 /** | 156 /** |
| 150 * GetResponseInfo() returns the current <code>URLResponseInfo</code> object. | 157 * GetResponseInfo() returns the current <code>URLResponseInfo</code> object. |
| 151 * | 158 * |
| 152 * @param[in] instance A <code>PP_Resource</code> corresponding to a | 159 * @param[in] instance A <code>PP_Resource</code> corresponding to a |
| 153 * <code>URLLoader</code>. | 160 * <code>URLLoader</code>. |
| 161 * |
| 154 * @return A <code>PP_Resource</code> corresponding to the | 162 * @return A <code>PP_Resource</code> corresponding to the |
| 155 * <code>URLResponseInfo</code> if successful, 0 if the loader is not a valid | 163 * <code>URLResponseInfo</code> if successful, 0 if the loader is not a valid |
| 156 * resource or if Open() has not been called. | 164 * resource or if Open() has not been called. |
| 157 */ | 165 */ |
| 158 PP_Resource (*GetResponseInfo)(PP_Resource loader); | 166 PP_Resource (*GetResponseInfo)(PP_Resource loader); |
| 159 | 167 |
| 160 /** | 168 /** |
| 161 * ReadResponseBody() is used to read the response body. The size of the | 169 * ReadResponseBody() is used to read the response body. The size of the |
| 162 * buffer must be large enough to hold the specified number of bytes to read. | 170 * buffer must be large enough to hold the specified number of bytes to read. |
| 163 * This function might perform a partial read. | 171 * This function might perform a partial read. |
| 164 * | 172 * |
| 165 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 173 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 166 * <code>URLLoader</code>. | 174 * <code>URLLoader</code>. |
| 167 * @param[in,out] buffer A pointer to the buffer for the response body. | 175 * @param[in,out] buffer A pointer to the buffer for the response body. |
| 168 * @param[in] bytes_to_read The number of bytes to read. | 176 * @param[in] bytes_to_read The number of bytes to read. |
| 169 * @param[in] callback A <code>PP_CompletionCallback</code> to run on | 177 * @param[in] callback A <code>PP_CompletionCallback</code> to run on |
| 170 * asynchronous completion. The callback will run if the bytes (full or | 178 * asynchronous completion. The callback will run if the bytes (full or |
| 171 * partial) are read or an error occurs asynchronously. This callback will | 179 * partial) are read or an error occurs asynchronously. This callback will |
| 172 * run only if this function returns <code>PP_OK_COMPLETIONPENDING</code>. | 180 * run only if this function returns <code>PP_OK_COMPLETIONPENDING</code>. |
| 181 * |
| 173 * @return An int32_t containing the number of bytes read or an error code | 182 * @return An int32_t containing the number of bytes read or an error code |
| 174 * from <code>pp_errors.h</code>. | 183 * from <code>pp_errors.h</code>. |
| 175 */ | 184 */ |
| 176 int32_t (*ReadResponseBody)(PP_Resource loader, | 185 int32_t (*ReadResponseBody)(PP_Resource loader, |
| 177 void* buffer, | 186 void* buffer, |
| 178 int32_t bytes_to_read, | 187 int32_t bytes_to_read, |
| 179 struct PP_CompletionCallback callback); | 188 struct PP_CompletionCallback callback); |
| 180 /** | 189 /** |
| 181 * FinishStreamingToFile() is used to wait for the response body to be | 190 * FinishStreamingToFile() is used to wait for the response body to be |
| 182 * completely downloaded to the file provided by the GetBodyAsFileRef() | 191 * completely downloaded to the file provided by the GetBodyAsFileRef() |
| 183 * in the current <code>URLResponseInfo</code>. This function is only used if | 192 * in the current <code>URLResponseInfo</code>. This function is only used if |
| 184 * <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the | 193 * <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the |
| 185 * <code>URLRequestInfo</code> passed to Open(). | 194 * <code>URLRequestInfo</code> passed to Open(). |
| 186 * | 195 * |
| 187 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 196 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 188 * <code>URLLoader</code>. | 197 * <code>URLLoader</code>. |
| 189 * @param[in] callback A <code>PP_CompletionCallback</code> to run on | 198 * @param[in] callback A <code>PP_CompletionCallback</code> to run on |
| 190 * asynchronous completion. This callback will run when body is downloaded | 199 * asynchronous completion. This callback will run when body is downloaded |
| 191 * or an error occurs after FinishStreamingToFile() returns | 200 * or an error occurs after FinishStreamingToFile() returns |
| 192 * <code>PP_OK_COMPLETIONPENDING</code>. | 201 * <code>PP_OK_COMPLETIONPENDING</code>. |
| 202 * |
| 193 * @return An int32_t containing the number of bytes read or an error code | 203 * @return An int32_t containing the number of bytes read or an error code |
| 194 * from <code>pp_errors.h</code>. | 204 * from <code>pp_errors.h</code>. |
| 195 */ | 205 */ |
| 196 int32_t (*FinishStreamingToFile)(PP_Resource loader, | 206 int32_t (*FinishStreamingToFile)(PP_Resource loader, |
| 197 struct PP_CompletionCallback callback); | 207 struct PP_CompletionCallback callback); |
| 198 | 208 |
| 199 /** | 209 /** |
| 200 * Close is a pointer to a function used to cancel any pending IO and close | 210 * Close is a pointer to a function used to cancel any pending IO and close |
| 201 * the <code>URLLoader</code> object. Any pending callbacks will still run, | 211 * the <code>URLLoader</code> object. Any pending callbacks will still run, |
| 202 * reporting <code>PP_ERROR_ABORTED</code> if pending IO was interrupted. | 212 * reporting <code>PP_ERROR_ABORTED</code> if pending IO was interrupted. |
| 203 * It is NOT valid to call Open() again after a call to this function. | 213 * It is NOT valid to call Open() again after a call to this function. |
| 204 * | 214 * |
| 205 * Note: If the <code>URLLoader</code> object is destroyed while it is still | 215 * <strong>Note:</strong> If the <code>URLLoader</code> object is destroyed |
| 206 * open, then it will be implicitly closed so you are not required to call | 216 * while it is still open, then it will be implicitly closed so you are not |
| 207 * Close(). | 217 * required to call Close(). |
| 208 * | 218 * |
| 209 * @param[in] loader A <code>PP_Resource</code> corresponding to a | 219 * @param[in] loader A <code>PP_Resource</code> corresponding to a |
| 210 * <code>URLLoader</code>. | 220 * <code>URLLoader</code>. |
| 211 */ | 221 */ |
| 212 void (*Close)(PP_Resource loader); | 222 void (*Close)(PP_Resource loader); |
| 213 }; | 223 }; |
| 214 /** | 224 /** |
| 215 * @} | 225 * @} |
| 216 */ | 226 */ |
| 217 | 227 |
| 218 #endif /* PPAPI_C_PPB_URL_LOADER_H_ */ | 228 #endif /* PPAPI_C_PPB_URL_LOADER_H_ */ |
| 219 | 229 |
| OLD | NEW |