summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_list.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-12 22:10:25 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-12 22:10:25 +0000
commit02cf5a4cb28d86669bcc4c3934f51437795b05ac (patch)
treeebf581c062a8f469bd0dbaa18df1e37b2ad8e0b1 /net/proxy/proxy_list.cc
parentd6fc4854834e9764dadeaf9fa826c06776d9a96e (diff)
downloadchromium_src-02cf5a4cb28d86669bcc4c3934f51437795b05ac.zip
chromium_src-02cf5a4cb28d86669bcc4c3934f51437795b05ac.tar.gz
chromium_src-02cf5a4cb28d86669bcc4c3934f51437795b05ac.tar.bz2
Retry proxies which were cached as bad before giving up.
This morphs ProxyList::RemoveBadProxies() into ProxyList::DeprioritizeBadProxies(), such that "bad proxies" are moved to the end of the fallback list rather than removed alltogether. BUG=31983 TEST=ProxyListTest.DeprioritizeBadProxies Review URL: http://codereview.chromium.org/542029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_list.cc')
-rw-r--r--net/proxy/proxy_list.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/net/proxy/proxy_list.cc b/net/proxy/proxy_list.cc
index 924fd15..b119b13 100644
--- a/net/proxy/proxy_list.cc
+++ b/net/proxy/proxy_list.cc
@@ -31,8 +31,14 @@ void ProxyList::SetSingleProxyServer(const ProxyServer& proxy_server) {
proxies_.push_back(proxy_server);
}
-void ProxyList::RemoveBadProxies(const ProxyRetryInfoMap& proxy_retry_info) {
- std::vector<ProxyServer> new_proxy_list;
+void ProxyList::DeprioritizeBadProxies(
+ const ProxyRetryInfoMap& proxy_retry_info) {
+ // Partition the proxy list in two:
+ // (1) the known bad proxies
+ // (2) everything else
+ std::vector<ProxyServer> good_proxies;
+ std::vector<ProxyServer> bad_proxies;
+
std::vector<ProxyServer>::const_iterator iter = proxies_.begin();
for (; iter != proxies_.end(); ++iter) {
ProxyRetryInfoMap::const_iterator bad_proxy =
@@ -41,13 +47,16 @@ void ProxyList::RemoveBadProxies(const ProxyRetryInfoMap& proxy_retry_info) {
// This proxy is bad. Check if it's time to retry.
if (bad_proxy->second.bad_until >= TimeTicks::Now()) {
// still invalid.
+ bad_proxies.push_back(*iter);
continue;
}
}
- new_proxy_list.push_back(*iter);
+ good_proxies.push_back(*iter);
}
- proxies_ = new_proxy_list;
+ // "proxies_ = good_proxies + bad_proxies"
+ proxies_.swap(good_proxies);
+ proxies_.insert(proxies_.end(), bad_proxies.begin(), bad_proxies.end());
}
void ProxyList::RemoveProxiesWithoutScheme(int scheme_bit_field) {