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_service.h" | 5 #include "net/proxy/proxy_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1167 | 1167 |
1168 // We don't have new proxy settings to try, try to fallback to the next proxy | 1168 // We don't have new proxy settings to try, try to fallback to the next proxy |
1169 // in the list. | 1169 // in the list. |
1170 bool did_fallback = result->Fallback(net_log); | 1170 bool did_fallback = result->Fallback(net_log); |
1171 | 1171 |
1172 // Return synchronous failure if there is nothing left to fall-back to. | 1172 // Return synchronous failure if there is nothing left to fall-back to. |
1173 // TODO(eroman): This is a yucky API, clean it up. | 1173 // TODO(eroman): This is a yucky API, clean it up. |
1174 return did_fallback ? OK : ERR_FAILED; | 1174 return did_fallback ? OK : ERR_FAILED; |
1175 } | 1175 } |
1176 | 1176 |
1177 bool ProxyService::MarkProxyAsBad(const ProxyInfo& result, | |
1178 const BoundNetLog& net_log) { | |
1179 result.proxy_list_.UpdateRetryInfoOnFallback(&proxy_retry_info_, net_log); | |
1180 // Since we haven't modified proxy_list_, require at least two entries | |
1181 // to return true. With 1 or 0, we won't have any remaining proxy entries | |
1182 // to try after incorporating our bad proxy list, which now includes | |
1183 // the first entry of result.proxy_list_. | |
1184 return result.proxy_list_.size() > 1; | |
eroman
2012/10/08 22:29:25
I don't believe this is good enough to prevent loo
Michael Piatek
2012/10/09 21:05:08
Done.
| |
1185 } | |
1186 | |
1177 void ProxyService::ReportSuccess(const ProxyInfo& result) { | 1187 void ProxyService::ReportSuccess(const ProxyInfo& result) { |
1178 DCHECK(CalledOnValidThread()); | 1188 DCHECK(CalledOnValidThread()); |
1179 | 1189 |
1180 const ProxyRetryInfoMap& new_retry_info = result.proxy_retry_info(); | 1190 const ProxyRetryInfoMap& new_retry_info = result.proxy_retry_info(); |
1181 if (new_retry_info.empty()) | 1191 if (new_retry_info.empty()) |
1182 return; | 1192 return; |
1183 | 1193 |
1184 for (ProxyRetryInfoMap::const_iterator iter = new_retry_info.begin(); | 1194 for (ProxyRetryInfoMap::const_iterator iter = new_retry_info.begin(); |
1185 iter != new_retry_info.end(); ++iter) { | 1195 iter != new_retry_info.end(); ++iter) { |
1186 ProxyRetryInfoMap::iterator existing = proxy_retry_info_.find(iter->first); | 1196 ProxyRetryInfoMap::iterator existing = proxy_retry_info_.find(iter->first); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 OnCompletion(result_); | 1562 OnCompletion(result_); |
1553 } | 1563 } |
1554 } | 1564 } |
1555 | 1565 |
1556 void SyncProxyServiceHelper::OnCompletion(int rv) { | 1566 void SyncProxyServiceHelper::OnCompletion(int rv) { |
1557 result_ = rv; | 1567 result_ = rv; |
1558 event_.Signal(); | 1568 event_.Signal(); |
1559 } | 1569 } |
1560 | 1570 |
1561 } // namespace net | 1571 } // namespace net |
OLD | NEW |