From 96e1933fd50fb512c5e678169d0d2c59841a7d1a Mon Sep 17 00:00:00 2001 From: "asanka@chromium.org" Date: Mon, 29 Aug 2011 16:39:00 +0000 Subject: Only mark a proxy as bad if we have confirmation that another proxy succeeded for the same request. BUG=87336 TEST=net_unittests --gtest_filter=ProxyServiceTest.ProxyFallback:HttpStreamFactoryTest.JobNotifiesProxy Review URL: http://codereview.chromium.org/7532011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98643 0039d316-1c4b-4281-b951-d872f2087c98 --- net/proxy/proxy_service_unittest.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'net/proxy/proxy_service_unittest.cc') diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index d41f48c..b2345d5 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc @@ -541,6 +541,9 @@ TEST(ProxyServiceTest, ProxyFallback) { // The second proxy should be specified. EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI()); + // Report back that the second proxy worked. This will globally mark the + // first proxy as bad. + service.ReportSuccess(info); TestCompletionCallback callback3; rv = service.ResolveProxy(url, &info, &callback3, NULL, BoundNetLog()); @@ -584,6 +587,25 @@ TEST(ProxyServiceTest, ProxyFallback) { EXPECT_FALSE(info.is_direct()); EXPECT_TRUE(info.is_empty()); + // Look up proxies again + TestCompletionCallback callback7; + rv = service.ResolveProxy(url, &info, &callback7, NULL, BoundNetLog()); + EXPECT_EQ(ERR_IO_PENDING, rv); + + ASSERT_EQ(1u, resolver->pending_requests().size()); + EXPECT_EQ(url, resolver->pending_requests()[0]->url()); + + // This time, the first 3 results have been found to be bad, but only the + // first proxy has been confirmed ... + resolver->pending_requests()[0]->results()->UseNamedProxy( + "foopy1:8080;foopy3:7070;foopy2:9090;foopy4:9091"); + resolver->pending_requests()[0]->CompleteNow(OK); + + // ... therefore, we should see the second proxy first. + EXPECT_EQ(OK, callback7.WaitForResult()); + EXPECT_FALSE(info.is_direct()); + EXPECT_EQ("foopy3:7070", info.proxy_server().ToURI()); + // TODO(nsylvain): Test that the proxy can be retried after the delay. } -- cgit v1.1