| 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/strings/string_tokenizer.h" | 9 #include "base/strings/string_tokenizer.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // And also, before failing the transaction wholesale, we could go back and | 165 // And also, before failing the transaction wholesale, we could go back and |
| 166 // retry the "bad proxies" which we never tried to begin with. | 166 // retry the "bad proxies" which we never tried to begin with. |
| 167 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete | 167 // (RemoveBadProxies would annotate them as 'expected bad' rather then delete |
| 168 // them from the list, so we would know what they were). | 168 // them from the list, so we would know what they were). |
| 169 | 169 |
| 170 if (proxies_.empty()) { | 170 if (proxies_.empty()) { |
| 171 NOTREACHED(); | 171 NOTREACHED(); |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 // By default, proxies are not retried for 5 minutes. | 174 // By default, proxies are not retried for 5 minutes. |
| 175 UpdateRetryInfoOnFallback(proxy_retry_info, | 175 UpdateRetryInfoOnFallback(proxy_retry_info, TimeDelta::FromMinutes(5), true, |
| 176 TimeDelta::FromMinutes(5), | 176 std::vector<ProxyServer>(), net_error, net_log); |
| 177 true, | |
| 178 ProxyServer(), | |
| 179 net_error, | |
| 180 net_log); | |
| 181 | 177 |
| 182 // Remove this proxy from our list. | 178 // Remove this proxy from our list. |
| 183 proxies_.erase(proxies_.begin()); | 179 proxies_.erase(proxies_.begin()); |
| 184 return !proxies_.empty(); | 180 return !proxies_.empty(); |
| 185 } | 181 } |
| 186 | 182 |
| 187 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, | 183 void ProxyList::AddProxyToRetryList(ProxyRetryInfoMap* proxy_retry_info, |
| 188 base::TimeDelta retry_delay, | 184 base::TimeDelta retry_delay, |
| 189 bool try_while_bad, | 185 bool try_while_bad, |
| 190 const ProxyServer& proxy_to_retry, | 186 const ProxyServer& proxy_to_retry, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 (*proxy_retry_info)[proxy_key] = retry_info; | 202 (*proxy_retry_info)[proxy_key] = retry_info; |
| 207 } | 203 } |
| 208 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, | 204 net_log.AddEvent(NetLog::TYPE_PROXY_LIST_FALLBACK, |
| 209 NetLog::StringCallback("bad_proxy", &proxy_key)); | 205 NetLog::StringCallback("bad_proxy", &proxy_key)); |
| 210 } | 206 } |
| 211 | 207 |
| 212 void ProxyList::UpdateRetryInfoOnFallback( | 208 void ProxyList::UpdateRetryInfoOnFallback( |
| 213 ProxyRetryInfoMap* proxy_retry_info, | 209 ProxyRetryInfoMap* proxy_retry_info, |
| 214 base::TimeDelta retry_delay, | 210 base::TimeDelta retry_delay, |
| 215 bool reconsider, | 211 bool reconsider, |
| 216 const ProxyServer& another_proxy_to_bypass, | 212 const std::vector<ProxyServer>& additional_proxies_to_bypass, |
| 217 int net_error, | 213 int net_error, |
| 218 const BoundNetLog& net_log) const { | 214 const BoundNetLog& net_log) const { |
| 219 DCHECK(retry_delay != base::TimeDelta()); | 215 DCHECK(retry_delay != base::TimeDelta()); |
| 220 | 216 |
| 221 if (proxies_.empty()) { | 217 if (proxies_.empty()) { |
| 222 NOTREACHED(); | 218 NOTREACHED(); |
| 223 return; | 219 return; |
| 224 } | 220 } |
| 225 | 221 |
| 226 if (!proxies_[0].is_direct()) { | 222 if (!proxies_[0].is_direct()) { |
| 227 AddProxyToRetryList(proxy_retry_info, | 223 AddProxyToRetryList(proxy_retry_info, |
| 228 retry_delay, | 224 retry_delay, |
| 229 reconsider, | 225 reconsider, |
| 230 proxies_[0], | 226 proxies_[0], |
| 231 net_error, | 227 net_error, |
| 232 net_log); | 228 net_log); |
| 233 | 229 // If any additional proxies to bypass are specified, add to the retry map |
| 234 // If an additional proxy to bypass is specified, add it to the retry map | |
| 235 // as well. | 230 // as well. |
| 236 if (another_proxy_to_bypass.is_valid()) { | 231 for (const ProxyServer& additional_proxy : additional_proxies_to_bypass) { |
| 237 AddProxyToRetryList(proxy_retry_info, | 232 AddProxyToRetryList(proxy_retry_info, retry_delay, reconsider, |
| 238 retry_delay, | 233 additional_proxy, net_error, net_log); |
| 239 reconsider, | |
| 240 another_proxy_to_bypass, | |
| 241 net_error, | |
| 242 net_log); | |
| 243 } | 234 } |
| 244 } | 235 } |
| 245 } | 236 } |
| 246 | 237 |
| 247 } // namespace net | 238 } // namespace net |
| OLD | NEW |