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

Side by Side 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, 5 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 unified diff | Download patch
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <vector> 7 #include <vector>
8 8
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/log/net_log.h" 10 #include "net/log/net_log.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 ProxyServer::SCHEME_HTTP); 238 ProxyServer::SCHEME_HTTP);
239 std::vector<ProxyServer> bad_proxies; 239 std::vector<ProxyServer> bad_proxies;
240 bad_proxies.push_back(proxy_server); 240 bad_proxies.push_back(proxy_server);
241 list.SetFromPacString("DIRECT;PROXY foopy2:80;PROXY foopy3:80"); 241 list.SetFromPacString("DIRECT;PROXY foopy2:80;PROXY foopy3:80");
242 list.UpdateRetryInfoOnFallback(&retry_info_map, 242 list.UpdateRetryInfoOnFallback(&retry_info_map,
243 base::TimeDelta::FromSeconds(60), true, 243 base::TimeDelta::FromSeconds(60), true,
244 bad_proxies, OK, net_log); 244 bad_proxies, OK, net_log);
245 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80")); 245 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
246 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80")); 246 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
247 } 247 }
248 // If the bad proxy is already on the retry list, and the old retry info would
249 // cause the proxy to be retried later than the newly specified retry info,
250 // then the old retry info should be kept.
251 {
252 ProxyList list;
253 ProxyRetryInfoMap retry_info_map;
254 BoundNetLog net_log;
255 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
256
257 // First, mark the proxy as bad for 60 seconds.
258 list.UpdateRetryInfoOnFallback(
259 &retry_info_map, base::TimeDelta::FromSeconds(60), true,
260 std::vector<ProxyServer>(), ERR_PROXY_CONNECTION_FAILED, net_log);
261 // Next, mark the same proxy as bad for 1 second. This call should have no
262 // effect, since this would cause the bad proxy to be retried sooner than
263 // the existing retry info.
264 list.UpdateRetryInfoOnFallback(&retry_info_map,
265 base::TimeDelta::FromSeconds(1), false,
266 std::vector<ProxyServer>(), OK, net_log);
267 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
268 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
269 retry_info_map["foopy1:80"].net_error);
270 EXPECT_TRUE(retry_info_map["foopy1:80"].try_while_bad);
271 EXPECT_EQ(base::TimeDelta::FromSeconds(60),
272 retry_info_map["foopy1:80"].current_delay);
273 EXPECT_GT(retry_info_map["foopy1:80"].bad_until,
274 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(30));
275 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
276 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
277 }
278 // If the bad proxy is already on the retry list, and the newly specified
279 // retry info would cause the proxy to be retried later than the old retry
280 // info, then the old retry info should be replaced with the new retry info.
281 {
282 ProxyList list;
283 ProxyRetryInfoMap retry_info_map;
284 BoundNetLog net_log;
285 list.SetFromPacString("PROXY foopy1:80;PROXY foopy2:80;PROXY foopy3:80");
286
287 // First, mark the proxy as bad for 1 second.
288 list.UpdateRetryInfoOnFallback(&retry_info_map,
289 base::TimeDelta::FromSeconds(1), false,
290 std::vector<ProxyServer>(), OK, net_log);
291 // Next, mark the same proxy as bad for 60 seconds. This call should replace
292 // the existing retry info with the new 60 second retry info.
293 list.UpdateRetryInfoOnFallback(
294 &retry_info_map, base::TimeDelta::FromSeconds(60), true,
295 std::vector<ProxyServer>(), ERR_PROXY_CONNECTION_FAILED, net_log);
296
297 EXPECT_TRUE(retry_info_map.end() != retry_info_map.find("foopy1:80"));
298 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED,
299 retry_info_map["foopy1:80"].net_error);
300 EXPECT_TRUE(retry_info_map["foopy1:80"].try_while_bad);
301 EXPECT_EQ(base::TimeDelta::FromSeconds(60),
302 retry_info_map["foopy1:80"].current_delay);
303 EXPECT_GT(retry_info_map["foopy1:80"].bad_until,
304 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(30));
305 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy2:80"));
306 EXPECT_TRUE(retry_info_map.end() == retry_info_map.find("foopy3:80"));
307 }
248 } 308 }
249 309
250 } // namesapce 310 } // namesapce
251 311
252 } // namespace net 312 } // namespace net
OLDNEW
« 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