Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 URLRequest that handles | 5 // This file contains URLFetcher, a wrapper around 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // Set the URLRequestContext on the request. Must be called before the | 145 // Set the URLRequestContext on the request. Must be called before the |
| 146 // request is started. | 146 // request is started. |
| 147 void set_request_context( | 147 void set_request_context( |
| 148 URLRequestContextGetter* request_context_getter); | 148 URLRequestContextGetter* request_context_getter); |
| 149 | 149 |
| 150 // If |retry| is false, 5xx responses will be propagated to the observer, | 150 // If |retry| is false, 5xx responses will be propagated to the observer, |
| 151 // if it is true URLFetcher will automatically re-execute the request, | 151 // if it is true URLFetcher will automatically re-execute the request, |
| 152 // after backoff_delay() elapses. URLFetcher has it set to true by default. | 152 // after backoff_delay() elapses. URLFetcher has it set to true by default. |
| 153 void set_automatically_retry_on_5xx(bool retry); | 153 void set_automatically_retry_on_5xx(bool retry); |
| 154 | 154 |
| 155 int max_retries() const { return max_retries_; } | |
| 156 | |
| 157 void set_max_retries(int max_retries) { max_retries_ = max_retries; } | |
| 158 | |
| 155 // Returns the back-off delay before the request will be retried, | 159 // Returns the back-off delay before the request will be retried, |
| 156 // when a 5xx response was received. | 160 // when a 5xx response was received. |
| 157 base::TimeDelta backoff_delay() const { return backoff_delay_; } | 161 base::TimeDelta backoff_delay() const { return backoff_delay_; } |
| 158 | 162 |
| 159 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests. | 163 // Sets the back-off delay, allowing to mock 5xx requests in unit-tests. |
| 160 #if defined(UNIT_TEST) | 164 #if defined(UNIT_TEST) |
| 161 void set_backoff_delay(base::TimeDelta backoff_delay) { | 165 void set_backoff_delay(base::TimeDelta backoff_delay) { |
| 162 backoff_delay_ = backoff_delay; | 166 backoff_delay_ = backoff_delay; |
| 163 } | 167 } |
| 164 #endif // defined(UNIT_TEST) | 168 #endif // defined(UNIT_TEST) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 | 200 |
| 197 static Factory* factory_; | 201 static Factory* factory_; |
| 198 | 202 |
| 199 // If |automatically_retry_on_5xx_| is false, 5xx responses will be | 203 // If |automatically_retry_on_5xx_| is false, 5xx responses will be |
| 200 // propagated to the observer, if it is true URLFetcher will automatically | 204 // propagated to the observer, if it is true URLFetcher will automatically |
| 201 // re-execute the request, after the back-off delay has expired. | 205 // re-execute the request, after the back-off delay has expired. |
| 202 // true by default. | 206 // true by default. |
| 203 bool automatically_retry_on_5xx_; | 207 bool automatically_retry_on_5xx_; |
| 204 // Back-off time delay. 0 by default. | 208 // Back-off time delay. 0 by default. |
| 205 base::TimeDelta backoff_delay_; | 209 base::TimeDelta backoff_delay_; |
| 210 // Maximum retris allowed. | |
|
Jói
2010/11/12 00:12:08
retris -> retries
yzshen
2010/11/12 02:05:46
Done.
| |
| 211 int max_retries_; | |
| 206 | 212 |
| 207 static bool g_interception_enabled; | 213 static bool g_interception_enabled; |
| 208 | 214 |
| 209 DISALLOW_COPY_AND_ASSIGN(URLFetcher); | 215 DISALLOW_COPY_AND_ASSIGN(URLFetcher); |
| 210 }; | 216 }; |
| 211 | 217 |
| 212 #endif // CHROME_COMMON_NET_URL_FETCHER_H_ | 218 #endif // CHROME_COMMON_NET_URL_FETCHER_H_ |
| OLD | NEW |