| 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 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 15 #include "base/task_runner.h" |
| 15 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 16 | 17 |
| 17 class FilePath; | 18 class FilePath; |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class MessageLoopProxy; | 22 class MessageLoopProxy; |
| 22 class TimeDelta; | 23 class TimeDelta; |
| 23 } | 24 } |
| 24 | 25 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 188 |
| 188 virtual void SetMaxRetries(int max_retries) = 0; | 189 virtual void SetMaxRetries(int max_retries) = 0; |
| 189 virtual int GetMaxRetries() const = 0; | 190 virtual int GetMaxRetries() const = 0; |
| 190 | 191 |
| 191 // Returns the back-off delay before the request will be retried, | 192 // Returns the back-off delay before the request will be retried, |
| 192 // when a 5xx response was received. | 193 // when a 5xx response was received. |
| 193 virtual base::TimeDelta GetBackoffDelay() const = 0; | 194 virtual base::TimeDelta GetBackoffDelay() const = 0; |
| 194 | 195 |
| 195 // By default, the response is saved in a string. Call this method to save the | 196 // By default, the response is saved in a string. Call this method to save the |
| 196 // response to a file instead. Must be called before Start(). | 197 // response to a file instead. Must be called before Start(). |
| 197 // |file_message_loop_proxy| will be used for all file operations. | 198 // |file_task_runner| will be used for all file operations. |
| 198 // To save to a temporary file, use SaveResponseToTemporaryFile(). | 199 // To save to a temporary file, use SaveResponseToTemporaryFile(). |
| 199 // The created file is removed when the URLFetcher is deleted unless you | 200 // The created file is removed when the URLFetcher is deleted unless you |
| 200 // take ownership by calling GetResponseAsFilePath(). | 201 // take ownership by calling GetResponseAsFilePath(). |
| 201 virtual void SaveResponseToFileAtPath( | 202 virtual void SaveResponseToFileAtPath( |
| 202 const FilePath& file_path, | 203 const FilePath& file_path, |
| 203 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0; | 204 scoped_refptr<base::TaskRunner> file_task_runner) = 0; |
| 204 | 205 |
| 205 // By default, the response is saved in a string. Call this method to save the | 206 // By default, the response is saved in a string. Call this method to save the |
| 206 // response to a temporary file instead. Must be called before Start(). | 207 // response to a temporary file instead. Must be called before Start(). |
| 207 // |file_message_loop_proxy| will be used for all file operations. | 208 // |file_task_runner| will be used for all file operations. |
| 208 // The created file is removed when the URLFetcher is deleted unless you | 209 // The created file is removed when the URLFetcher is deleted unless you |
| 209 // take ownership by calling GetResponseAsFilePath(). | 210 // take ownership by calling GetResponseAsFilePath(). |
| 210 virtual void SaveResponseToTemporaryFile( | 211 virtual void SaveResponseToTemporaryFile( |
| 211 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) = 0; | 212 scoped_refptr<base::TaskRunner> file_task_runner) = 0; |
| 212 | 213 |
| 213 // Retrieve the response headers from the request. Must only be called after | 214 // Retrieve the response headers from the request. Must only be called after |
| 214 // the OnURLFetchComplete callback has run. | 215 // the OnURLFetchComplete callback has run. |
| 215 virtual HttpResponseHeaders* GetResponseHeaders() const = 0; | 216 virtual HttpResponseHeaders* GetResponseHeaders() const = 0; |
| 216 | 217 |
| 217 // Retrieve the remote socket address from the request. Must only | 218 // Retrieve the remote socket address from the request. Must only |
| 218 // be called after the OnURLFetchComplete callback has run and if | 219 // be called after the OnURLFetchComplete callback has run and if |
| 219 // the request has not failed. | 220 // the request has not failed. |
| 220 virtual HostPortPair GetSocketAddress() const = 0; | 221 virtual HostPortPair GetSocketAddress() const = 0; |
| 221 | 222 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // true, caller takes responsibility for the file, and it will not | 263 // true, caller takes responsibility for the file, and it will not |
| 263 // be removed once the URLFetcher is destroyed. User should not take | 264 // be removed once the URLFetcher is destroyed. User should not take |
| 264 // ownership more than once, or call this method after taking ownership. | 265 // ownership more than once, or call this method after taking ownership. |
| 265 virtual bool GetResponseAsFilePath(bool take_ownership, | 266 virtual bool GetResponseAsFilePath(bool take_ownership, |
| 266 FilePath* out_response_path) const = 0; | 267 FilePath* out_response_path) const = 0; |
| 267 }; | 268 }; |
| 268 | 269 |
| 269 } // namespace net | 270 } // namespace net |
| 270 | 271 |
| 271 #endif // NET_URL_REQUEST_URL_FETCHER_H_ | 272 #endif // NET_URL_REQUEST_URL_FETCHER_H_ |
| OLD | NEW |