| 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_CPP_URL_LOADER_H_ | 5 #ifndef PPAPI_CPP_URL_LOADER_H_ |
| 6 #define PPAPI_CPP_URL_LOADER_H_ | 6 #define PPAPI_CPP_URL_LOADER_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_stdint.h" | 8 #include "ppapi/c/pp_stdint.h" |
| 9 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
| 10 | 10 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 const CompletionCallback& cc); | 124 const CompletionCallback& cc); |
| 125 | 125 |
| 126 /// This function can be invoked to follow a | 126 /// This function can be invoked to follow a |
| 127 /// redirect after Open() completed on receiving redirect headers. | 127 /// redirect after Open() completed on receiving redirect headers. |
| 128 /// | 128 /// |
| 129 /// @param[in] cc A <code>CompletionCallback</code> to run on asynchronous | 129 /// @param[in] cc A <code>CompletionCallback</code> to run on asynchronous |
| 130 /// completion of FollowRedirect(). This callback will run when response | 130 /// completion of FollowRedirect(). This callback will run when response |
| 131 /// headers for the redirect url are received or error occured. This callback | 131 /// headers for the redirect url are received or error occured. This callback |
| 132 /// will only run if FollowRedirect() returns | 132 /// will only run if FollowRedirect() returns |
| 133 /// <code>PP_OK_COMPLETIONPENDING</code>. | 133 /// <code>PP_OK_COMPLETIONPENDING</code>. |
| 134 /// |
| 134 /// @return An int32_t containing an error code from | 135 /// @return An int32_t containing an error code from |
| 135 /// <code>pp_errors.h</code>. | 136 /// <code>pp_errors.h</code>. |
| 136 int32_t FollowRedirect(const CompletionCallback& cc); | 137 int32_t FollowRedirect(const CompletionCallback& cc); |
| 137 | 138 |
| 138 /// This function returns the current upload progress (which is only | 139 /// This function returns the current upload progress (which is only |
| 139 /// meaningful after Open() has been called). Progress only refers to the | 140 /// meaningful after Open() has been called). Progress only refers to the |
| 140 /// request body and does not include the headers. | 141 /// request body and does not include the headers. |
| 141 /// | 142 /// |
| 142 /// This data is only available if the <code>URLRequestInfo</code> passed to | 143 /// This data is only available if the <code>URLRequestInfo</code> passed to |
| 143 /// Open() had the | 144 /// Open() had the |
| 144 /// <code>PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS</code> property set to | 145 /// <code>PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS</code> property set to |
| 145 /// <code>PP_TRUE</code>. | 146 /// <code>PP_TRUE</code>. |
| 146 /// | 147 /// |
| 147 /// @param[in] bytes_sent The number of bytes sent thus far. | 148 /// @param[in] bytes_sent The number of bytes sent thus far. |
| 148 /// @param[in] total_bytes_to_be_sent The total number of bytes to be sent. | 149 /// @param[in] total_bytes_to_be_sent The total number of bytes to be sent. |
| 150 /// |
| 149 /// @return True if the upload progress is available, false if it is not | 151 /// @return True if the upload progress is available, false if it is not |
| 150 /// available. | 152 /// available. |
| 151 bool GetUploadProgress(int64_t* bytes_sent, | 153 bool GetUploadProgress(int64_t* bytes_sent, |
| 152 int64_t* total_bytes_to_be_sent) const; | 154 int64_t* total_bytes_to_be_sent) const; |
| 153 | 155 |
| 154 /// This function returns the current download progress, which is meaningful | 156 /// This function returns the current download progress, which is meaningful |
| 155 /// after Open() has been called. Progress only refers to the response body | 157 /// after Open() has been called. Progress only refers to the response body |
| 156 /// and does not include the headers. | 158 /// and does not include the headers. |
| 157 /// | 159 /// |
| 158 /// This data is only available if the <code>URLRequestInfo</code> passed to | 160 /// This data is only available if the <code>URLRequestInfo</code> passed to |
| 159 /// Open() had the | 161 /// Open() had the |
| 160 /// <code>PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS</code> property set to | 162 /// <code>PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS</code> property set to |
| 161 /// PP_TRUE. | 163 /// PP_TRUE. |
| 162 /// | 164 /// |
| 163 /// @param[in] bytes_received The number of bytes received thus far. | 165 /// @param[in] bytes_received The number of bytes received thus far. |
| 164 /// @param[in] total_bytes_to_be_received The total number of bytes to be | 166 /// @param[in] total_bytes_to_be_received The total number of bytes to be |
| 165 /// received. The total bytes to be received may be unknown, in which case | 167 /// received. The total bytes to be received may be unknown, in which case |
| 166 /// <code>total_bytes_to_be_received</code> will be set to -1. | 168 /// <code>total_bytes_to_be_received</code> will be set to -1. |
| 169 /// |
| 167 /// @return True if the download progress is available, false if it is | 170 /// @return True if the download progress is available, false if it is |
| 168 /// not available. | 171 /// not available. |
| 169 bool GetDownloadProgress(int64_t* bytes_received, | 172 bool GetDownloadProgress(int64_t* bytes_received, |
| 170 int64_t* total_bytes_to_be_received) const; | 173 int64_t* total_bytes_to_be_received) const; |
| 171 | 174 |
| 172 /// This is a function that returns the current | 175 /// This is a function that returns the current |
| 173 /// <code>URLResponseInfo</code> object. | 176 /// <code>URLResponseInfo</code> object. |
| 174 /// | 177 /// |
| 175 /// @return A <code>URLResponseInfo</code> corresponding to the | 178 /// @return A <code>URLResponseInfo</code> corresponding to the |
| 176 /// <code>URLResponseInfo</code> if successful, an <code>is_null</code> | 179 /// <code>URLResponseInfo</code> if successful, an <code>is_null</code> |
| 177 /// object if the loader is not a valid resource or if Open() has not been | 180 /// object if the loader is not a valid resource or if Open() has not been |
| 178 /// called. | 181 /// called. |
| 179 URLResponseInfo GetResponseInfo() const; | 182 URLResponseInfo GetResponseInfo() const; |
| 180 | 183 |
| 181 /// This function is used to read the response body. The size of the buffer | 184 /// This function is used to read the response body. The size of the buffer |
| 182 /// must be large enough to hold the specified number of bytes to read. | 185 /// must be large enough to hold the specified number of bytes to read. |
| 183 /// This function might perform a partial read. | 186 /// This function might perform a partial read. |
| 184 /// | 187 /// |
| 185 /// @param[in,out] buffer A pointer to the buffer for the response body. | 188 /// @param[in,out] buffer A pointer to the buffer for the response body. |
| 186 /// @param[in] bytes_to_read The number of bytes to read. | 189 /// @param[in] bytes_to_read The number of bytes to read. |
| 187 /// @param[in] cc A <code>CompletionCallback</code> to run on asynchronous | 190 /// @param[in] cc A <code>CompletionCallback</code> to run on asynchronous |
| 188 /// completion. The callback will run if the bytes (full or partial) are | 191 /// completion. The callback will run if the bytes (full or partial) are |
| 189 /// read or an error occurs asynchronously. This callback will run only if | 192 /// read or an error occurs asynchronously. This callback will run only if |
| 190 /// this function returns <code>PP_OK_COMPLETIONPENDING</code>. | 193 /// this function returns <code>PP_OK_COMPLETIONPENDING</code>. |
| 194 /// |
| 191 /// @return An int32_t containing the number of bytes read or an error code | 195 /// @return An int32_t containing the number of bytes read or an error code |
| 192 /// from <code>pp_errors.h</code>. | 196 /// from <code>pp_errors.h</code>. |
| 193 int32_t ReadResponseBody(void* buffer, | 197 int32_t ReadResponseBody(void* buffer, |
| 194 int32_t bytes_to_read, | 198 int32_t bytes_to_read, |
| 195 const CompletionCallback& cc); | 199 const CompletionCallback& cc); |
| 196 | 200 |
| 197 /// This function is used to wait for the response body to be completely | 201 /// This function is used to wait for the response body to be completely |
| 198 /// downloaded to the file provided by the GetBodyAsFileRef() in the current | 202 /// downloaded to the file provided by the GetBodyAsFileRef() in the current |
| 199 /// <code>URLResponseInfo</code>. This function is only used if | 203 /// <code>URLResponseInfo</code>. This function is only used if |
| 200 /// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the | 204 /// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the |
| 201 /// <code>URLRequestInfo</code> passed to Open(). | 205 /// <code>URLRequestInfo</code> passed to Open(). |
| 202 /// | 206 /// |
| 203 /// @param[in] cc A <code>CompletionCallback</code> to run on asynchronous | 207 /// @param[in] cc A <code>CompletionCallback</code> to run on asynchronous |
| 204 /// completion. This callback will run when body is downloaded or an error | 208 /// completion. This callback will run when body is downloaded or an error |
| 205 /// occurs after FinishStreamingToFile() returns | 209 /// occurs after FinishStreamingToFile() returns |
| 206 /// <code>PP_OK_COMPLETIONPENDING</code>. | 210 /// <code>PP_OK_COMPLETIONPENDING</code>. |
| 211 /// |
| 207 /// @return An int32_t containing the number of bytes read or an error code | 212 /// @return An int32_t containing the number of bytes read or an error code |
| 208 /// from <code>pp_errors.h</code>. | 213 /// from <code>pp_errors.h</code>. |
| 209 int32_t FinishStreamingToFile(const CompletionCallback& cc); | 214 int32_t FinishStreamingToFile(const CompletionCallback& cc); |
| 210 | 215 |
| 211 /// This function is used to cancel any pending IO and close the URLLoader | 216 /// This function is used to cancel any pending IO and close the URLLoader |
| 212 /// object. Any pending callbacks will still run, reporting | 217 /// object. Any pending callbacks will still run, reporting |
| 213 /// <code>PP_ERROR_ABORTED</code> if pending IO was interrupted. It is NOT | 218 /// <code>PP_ERROR_ABORTED</code> if pending IO was interrupted. It is NOT |
| 214 /// valid to call Open() again after a call to this function. | 219 /// valid to call Open() again after a call to this function. |
| 215 /// | 220 /// |
| 216 /// <strong>Note:</strong> If the <code>URLLoader</code> object is destroyed | 221 /// <strong>Note:</strong> If the <code>URLLoader</code> object is destroyed |
| 217 /// while it is still open, then it will be implicitly closed so you are not | 222 /// while it is still open, then it will be implicitly closed so you are not |
| 218 /// required to call Close(). | 223 /// required to call Close(). |
| 219 void Close(); | 224 void Close(); |
| 220 }; | 225 }; |
| 221 | 226 |
| 222 } // namespace pp | 227 } // namespace pp |
| 223 | 228 |
| 224 #endif // PPAPI_CPP_URL_LOADER_H_ | 229 #endif // PPAPI_CPP_URL_LOADER_H_ |
| OLD | NEW |