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 // This file contains URLFetcher, a wrapper around net::URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around net::URLRequest that handles |
6 // low-level details like thread safety, ref counting, and incremental buffer | 6 // low-level details like thread safety, ref counting, and incremental buffer |
7 // reading. This is useful for callers who simply want to get the data from a | 7 // reading. This is useful for callers who simply want to get the data from a |
8 // URL and don't care about all the nitty-gritty details. | 8 // URL and don't care about all the nitty-gritty details. |
9 // | 9 // |
10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a | 10 // NOTE(willchan): Only one "IO" thread is supported for URLFetcher. This is a |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 int max_retries() const; | 181 int max_retries() const; |
182 | 182 |
183 void set_max_retries(int max_retries); | 183 void set_max_retries(int max_retries); |
184 | 184 |
185 // Returns the back-off delay before the request will be retried, | 185 // Returns the back-off delay before the request will be retried, |
186 // when a 5xx response was received. | 186 // when a 5xx response was received. |
187 base::TimeDelta backoff_delay() const { return backoff_delay_; } | 187 base::TimeDelta backoff_delay() const { return backoff_delay_; } |
188 | 188 |
189 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests. | 189 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests. |
190 #if defined(UNIT_TEST) | 190 void set_backoff_delay_for_testing(base::TimeDelta backoff_delay) { |
191 void set_backoff_delay(base::TimeDelta backoff_delay) { | |
192 backoff_delay_ = backoff_delay; | 191 backoff_delay_ = backoff_delay; |
193 } | 192 } |
194 #endif // defined(UNIT_TEST) | |
195 | 193 |
196 // By default, the response is saved in a string. Call this method to save the | 194 // By default, the response is saved in a string. Call this method to save the |
197 // response to a temporary file instead. Must be called before Start(). | 195 // response to a temporary file instead. Must be called before Start(). |
198 // |file_message_loop_proxy| will be used for all file operations. | 196 // |file_message_loop_proxy| will be used for all file operations. |
199 void SaveResponseToTemporaryFile( | 197 void SaveResponseToTemporaryFile( |
200 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); | 198 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); |
201 | 199 |
202 // Retrieve the response headers from the request. Must only be called after | 200 // Retrieve the response headers from the request. Must only be called after |
203 // the OnURLFetchComplete callback has run. | 201 // the OnURLFetchComplete callback has run. |
204 virtual net::HttpResponseHeaders* response_headers() const; | 202 virtual net::HttpResponseHeaders* response_headers() const; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 317 |
320 // Back-off time delay. 0 by default. | 318 // Back-off time delay. 0 by default. |
321 base::TimeDelta backoff_delay_; | 319 base::TimeDelta backoff_delay_; |
322 | 320 |
323 static bool g_interception_enabled; | 321 static bool g_interception_enabled; |
324 | 322 |
325 DISALLOW_COPY_AND_ASSIGN(URLFetcher); | 323 DISALLOW_COPY_AND_ASSIGN(URLFetcher); |
326 }; | 324 }; |
327 | 325 |
328 #endif // CONTENT_COMMON_NET_URL_FETCHER_H_ | 326 #endif // CONTENT_COMMON_NET_URL_FETCHER_H_ |
OLD | NEW |