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 #include "net/proxy/proxy_list.h" | 5 #include "net/proxy/proxy_list.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/rand_util.h" | |
10 #include "base/strings/string_tokenizer.h" | 9 #include "base/strings/string_tokenizer.h" |
11 #include "base/time/time.h" | 10 #include "base/time/time.h" |
12 #include "base/values.h" | 11 #include "base/values.h" |
13 #include "net/proxy/proxy_server.h" | 12 #include "net/proxy/proxy_server.h" |
14 | 13 |
15 using base::TimeDelta; | 14 using base::TimeDelta; |
16 using base::TimeTicks; | 15 using base::TimeTicks; |
17 | 16 |
18 namespace net { | 17 namespace net { |
19 | 18 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 // | 159 // |
161 // And also, before failing the transaction wholesale, we could go back and | 160 // And also, before failing the transaction wholesale, we could go back and |
162 // retry the "bad proxies" which we never tried to begin with. | 161 // retry the "bad proxies" which we never tried to begin with. |
163 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete | 162 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete |
164 // them from the list, so we would know what they were). | 163 // them from the list, so we would know what they were). |
165 | 164 |
166 if (proxies_.empty()) { | 165 if (proxies_.empty()) { |
167 NOTREACHED(); | 166 NOTREACHED(); |
168 return false; | 167 return false; |
169 } | 168 } |
170 UpdateRetryInfoOnFallback(proxy_retry_info, base::TimeDelta(), true, | 169 // By default, proxies are not retried for 5 minutes. |
170 UpdateRetryInfoOnFallback(proxy_retry_info, TimeDelta::FromMinutes(5), true, | |
171 ProxyServer(), net_log); | 171 ProxyServer(), net_log); |
Ryan Sleevi
2014/07/22 08:22:25
This needs to be separated and dealt with first, i
Not at Google. Contact bengr
2014/07/22 23:03:53
I am isolating this to a separate cl. Will send it
| |
172 | 172 |
173 // Remove this proxy from our list. | 173 // Remove this proxy from our list. |
174 proxies_.erase(proxies_.begin()); | 174 proxies_.erase(proxies_.begin()); |
175 return !proxies_.empty(); | 175 return !proxies_.empty(); |
176 } | 176 } |
177 | 177 |
178 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, | 178 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, |
179 base::TimeDelta retry_delay, | 179 base::TimeDelta retry_delay, |
180 bool try_while_bad, | 180 bool try_while_bad, |
181 const ProxyServer& proxy_to_retry, | 181 const ProxyServer& proxy_to_retry, |
(...skipping 15 matching lines...) Expand all Loading... | |
197 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, | 197 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, |
198 NetLog::StringCallback("bad_proxy", &proxy_key)); | 198 NetLog::StringCallback("bad_proxy", &proxy_key)); |
199 } | 199 } |
200 | 200 |
201 void ProxyList::UpdateRetryInfoOnFallback( | 201 void ProxyList::UpdateRetryInfoOnFallback( |
202 ProxyRetryInfoMap* proxy_retry_info, | 202 ProxyRetryInfoMap* proxy_retry_info, |
203 base::TimeDelta retry_delay, | 203 base::TimeDelta retry_delay, |
204 bool reconsider, | 204 bool reconsider, |
205 const ProxyServer& another_proxy_to_bypass, | 205 const ProxyServer& another_proxy_to_bypass, |
206 const BoundNetLog& net_log) const { | 206 const BoundNetLog& net_log) const { |
207 // Time to wait before retrying a bad proxy server. | 207 DCHECK(retry_delay != base::TimeDelta()); |
Ryan Sleevi
2014/07/22 01:56:31
No documentation/comment that I can tell why you'r
Not at Google. Contact bengr
2014/07/22 23:03:53
We randomize the duration for data reduction proxy
| |
208 if (retry_delay == base::TimeDelta()) { | |
209 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
210 // Randomize the timeout over a range from one to five minutes. | |
211 retry_delay = | |
212 TimeDelta::FromMilliseconds( | |
213 base::RandInt(1 * 60 * 1000, 5 * 60 * 1000)); | |
214 #else | |
215 retry_delay = TimeDelta::FromMinutes(5); | |
216 #endif | |
217 } | |
218 | |
219 if (proxies_.empty()) { | 208 if (proxies_.empty()) { |
220 NOTREACHED(); | 209 NOTREACHED(); |
221 return; | 210 return; |
222 } | 211 } |
223 | 212 |
224 if (!proxies_[0].is_direct()) { | 213 if (!proxies_[0].is_direct()) { |
225 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, proxies_[0], | 214 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, proxies_[0], |
226 net_log); | 215 net_log); |
227 | 216 |
228 // If an additional proxy to bypass is specified, add it to the retry map | 217 // If an additional proxy to bypass is specified, add it to the retry map |
229 // as well. | 218 // as well. |
230 if (another_proxy_to_bypass.is_valid()) { | 219 if (another_proxy_to_bypass.is_valid()) { |
231 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, | 220 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, |
232 another_proxy_to_bypass, net_log); | 221 another_proxy_to_bypass, net_log); |
233 } | 222 } |
234 } | 223 } |
235 } | 224 } |
236 | 225 |
237 } // namespace net | 226 } // namespace net |
OLD | NEW |