Chromium Code Reviews| 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" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 // | 160 // |
| 161 // And also, before failing the transaction wholesale, we could go back and | 161 // And also, before failing the transaction wholesale, we could go back and |
| 162 // retry the "bad proxies" which we never tried to begin with. | 162 // retry the "bad proxies" which we never tried to begin with. |
| 163 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete | 163 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete |
| 164 // them from the list, so we would know what they were). | 164 // them from the list, so we would know what they were). |
| 165 | 165 |
| 166 if (proxies_.empty()) { | 166 if (proxies_.empty()) { |
| 167 NOTREACHED(); | 167 NOTREACHED(); |
| 168 return false; | 168 return false; |
| 169 } | 169 } |
| 170 UpdateRetryInfoOnFallback(proxy_retry_info, base::TimeDelta(), true, | 170 UpdateRetryInfoOnFallback(proxy_retry_info, TimeDelta::FromMinutes(5), true, |
| 171 ProxyServer(), net_log); | 171 ProxyServer(), net_log); |
| 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, |
| (...skipping 16 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()); |
|
bengr
2014/07/15 16:38:17
I think this is wrong too.
I think there are thr
Not at Google. Contact bengr
2014/07/16 22:41:34
Fixed now.
| |
| 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 |