OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_URL_REQUEST_URL_FETCHER_H_ | 5 #ifndef NET_URL_REQUEST_URL_FETCHER_H_ |
6 #define NET_URL_REQUEST_URL_FETCHER_H_ | 6 #define NET_URL_REQUEST_URL_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 // will be called, with the URLFetcher's URL set to the redirect destination, | 179 // will be called, with the URLFetcher's URL set to the redirect destination, |
180 // its status set to CANCELED, and its response code set to the relevant 3xx | 180 // its status set to CANCELED, and its response code set to the relevant 3xx |
181 // server response code. | 181 // server response code. |
182 virtual void SetStopOnRedirect(bool stop_on_redirect) = 0; | 182 virtual void SetStopOnRedirect(bool stop_on_redirect) = 0; |
183 | 183 |
184 // If |retry| is false, 5xx responses will be propagated to the observer, | 184 // If |retry| is false, 5xx responses will be propagated to the observer, |
185 // if it is true URLFetcher will automatically re-execute the request, | 185 // if it is true URLFetcher will automatically re-execute the request, |
186 // after backoff_delay() elapses. URLFetcher has it set to true by default. | 186 // after backoff_delay() elapses. URLFetcher has it set to true by default. |
187 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; | 187 virtual void SetAutomaticallyRetryOn5xx(bool retry) = 0; |
188 | 188 |
189 virtual void SetMaxRetries(int max_retries) = 0; | 189 virtual void SetMaxRetriesOn5xx(int max_retries) = 0; |
190 virtual int GetMaxRetries() const = 0; | 190 virtual int GetMaxRetriesOn5xx() const = 0; |
191 | 191 |
192 // Returns the back-off delay before the request will be retried, | 192 // Returns the back-off delay before the request will be retried, |
193 // when a 5xx response was received. | 193 // when a 5xx response was received. |
194 virtual base::TimeDelta GetBackoffDelay() const = 0; | 194 virtual base::TimeDelta GetBackoffDelay() const = 0; |
195 | 195 |
196 // Retries up to |max_retries| times when requests fail with | |
197 // ERR_NETWORK_CHANGED. If ERR_NETWORK_CHANGED is received after having | |
198 // retried |max_retries| times then it is propagated to the observer. | |
199 // Each retry can be delayed if the network if currently offline, and will be | |
200 // attempted once the network connection is back. | |
szym
2012/12/12 19:50:46
Not immediately obvious here is that if |max_retri
Joao da Silva
2012/12/12 20:17:20
Clarified that in the comment.
| |
201 virtual void SetAutomaticallyRetryOnNetworkChanges(int max_retries) = 0; | |
202 | |
196 // By default, the response is saved in a string. Call this method to save the | 203 // By default, the response is saved in a string. Call this method to save the |
197 // response to a file instead. Must be called before Start(). | 204 // response to a file instead. Must be called before Start(). |
198 // |file_task_runner| will be used for all file operations. | 205 // |file_task_runner| will be used for all file operations. |
199 // To save to a temporary file, use SaveResponseToTemporaryFile(). | 206 // To save to a temporary file, use SaveResponseToTemporaryFile(). |
200 // The created file is removed when the URLFetcher is deleted unless you | 207 // The created file is removed when the URLFetcher is deleted unless you |
201 // take ownership by calling GetResponseAsFilePath(). | 208 // take ownership by calling GetResponseAsFilePath(). |
202 virtual void SaveResponseToFileAtPath( | 209 virtual void SaveResponseToFileAtPath( |
203 const FilePath& file_path, | 210 const FilePath& file_path, |
204 scoped_refptr<base::TaskRunner> file_task_runner) = 0; | 211 scoped_refptr<base::TaskRunner> file_task_runner) = 0; |
205 | 212 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 // true, caller takes responsibility for the file, and it will not | 270 // true, caller takes responsibility for the file, and it will not |
264 // be removed once the URLFetcher is destroyed. User should not take | 271 // be removed once the URLFetcher is destroyed. User should not take |
265 // ownership more than once, or call this method after taking ownership. | 272 // ownership more than once, or call this method after taking ownership. |
266 virtual bool GetResponseAsFilePath(bool take_ownership, | 273 virtual bool GetResponseAsFilePath(bool take_ownership, |
267 FilePath* out_response_path) const = 0; | 274 FilePath* out_response_path) const = 0; |
268 }; | 275 }; |
269 | 276 |
270 } // namespace net | 277 } // namespace net |
271 | 278 |
272 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 279 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
OLD | NEW |