Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: net/proxy/proxy_list_unittest.cc

Issue 1212643009: Allow for an existing bad proxy to be given a new retry delay. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2403
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_list_unittest.cc
diff --git a/net/proxy/proxy_list_unittest.cc b/net/proxy/proxy_list_unittest.cc
index 0dbb53a2d03ff3537c623028ee2c98f9decfeecf..e98d9c519771f3b9f4b341bfb255d1932e498ca9 100644
--- a/net/proxy/proxy_list_unittest.cc
+++ b/net/proxy/proxy_list_unittest.cc
@@ -245,6 +245,66 @@ TEST(ProxyListTest, UpdateRetryInfoOnFallback) {
EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
}
+ // If the bad proxy is already on the retry list, and the old retry info would
+ // cause the proxy to be retried later than the newly specified retry info,
+ // then the old retry info should be kept.
+ {
+ ProxyList list;
+ ProxyRetryInfoMap retry_info_map;
+ BoundNetLog net_log;
+ list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
+
+ // First, mark the proxy as bad for 60 seconds.
+ list.UpdateRetryInfoOnFallback(
+ &retry_info_map, base::TimeDelta::FromSeconds(60), true,
+ std::vector<ProxyServer>(), ERR_PROXY_CONNECTION_FAILED, net_log);
+ // Next, mark the same proxy as bad for 1 second. This call should have no
+ // effect, since this would cause the bad proxy to be retried sooner than
+ // the existing retry info.
+ list.UpdateRetryInfoOnFallback(&retry_info_map,
+ base::TimeDelta::FromSeconds(1), false,
+ std::vector<ProxyServer>(), OK, net_log);
+ EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
+ EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
+ retry_info_map["foopy1:80"].net_error);
+ EXPECT_TRUE(retry_info_map["foopy1:80"].try_while_bad);
+ EXPECT_EQ(base::TimeDelta::FromSeconds(60),
+ retry_info_map["foopy1:80"].current_delay);
+ EXPECT_GT(retry_info_map["foopy1:80"].bad_until,
+ base::TimeTicks::Now() + base::TimeDelta::FromSeconds(30));
+ EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
+ EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
+ }
+ // If the bad proxy is already on the retry list, and the newly specified
+ // retry info would cause the proxy to be retried later than the old retry
+ // info, then the old retry info should be replaced with the new retry info.
+ {
+ ProxyList list;
+ ProxyRetryInfoMap retry_info_map;
+ BoundNetLog net_log;
+ list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
+
+ // First, mark the proxy as bad for 1 second.
+ list.UpdateRetryInfoOnFallback(&retry_info_map,
+ base::TimeDelta::FromSeconds(1), false,
+ std::vector<ProxyServer>(), OK, net_log);
+ // Next, mark the same proxy as bad for 60 seconds. This call should replace
+ // the existing retry info with the new 60 second retry info.
+ list.UpdateRetryInfoOnFallback(
+ &retry_info_map, base::TimeDelta::FromSeconds(60), true,
+ std::vector<ProxyServer>(), ERR_PROXY_CONNECTION_FAILED, net_log);
+
+ EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
+ EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
+ retry_info_map["foopy1:80"].net_error);
+ EXPECT_TRUE(retry_info_map["foopy1:80"].try_while_bad);
+ EXPECT_EQ(base::TimeDelta::FromSeconds(60),
+ retry_info_map["foopy1:80"].current_delay);
+ EXPECT_GT(retry_info_map["foopy1:80"].bad_until,
+ base::TimeTicks::Now() + base::TimeDelta::FromSeconds(30));
+ EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
+ EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
+ }
}
} // namesapce
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698