summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoragayev@chromium.org <agayev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-28 02:20:06 +0000
committeragayev@chromium.org <agayev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-28 02:20:06 +0000
commit10b71b546ae4ce616bd2a26c5fcadfdfcddf4e3f (patch)
treedcb6c2c826253b016e477c7466da3ca0d4982160
parent0be241219a6cecb753ae4fdfb049f75530353771 (diff)
downloadchromium_src-10b71b546ae4ce616bd2a26c5fcadfdfcddf4e3f.zip
chromium_src-10b71b546ae4ce616bd2a26c5fcadfdfcddf4e3f.tar.gz
chromium_src-10b71b546ae4ce616bd2a26c5fcadfdfcddf4e3f.tar.bz2
Revert 94412 - HostResolverImpl: don't interpret NULL callback argument as a request to do synchronous resolution.
BUG=90547,60149 TEST=net_unittests --gtest_filter="HostResolverImplTest*" Review URL: http://codereview.chromium.org/7465046 TBR=agayev@chromium.org Review URL: http://codereview.chromium.org/7524018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94417 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--jingle/notifier/communicator/xmpp_connection_generator_unittest.cc4
-rw-r--r--net/base/host_resolver.h9
-rw-r--r--net/base/host_resolver_impl.cc49
-rw-r--r--net/base/host_resolver_impl_unittest.cc111
-rw-r--r--net/base/host_resolver_proc.cc13
-rw-r--r--net/base/mapped_host_resolver_unittest.cc36
-rw-r--r--net/base/mock_host_resolver.cc10
-rw-r--r--net/http/http_network_transaction_unittest.cc31
-rw-r--r--net/proxy/proxy_resolver_js_bindings_unittest.cc5
-rw-r--r--net/socket/socks5_client_socket_unittest.cc5
-rw-r--r--net/socket/transport_client_socket_pool_unittest.cc1
-rw-r--r--net/socket/transport_client_socket_unittest.cc5
-rw-r--r--net/test/test_server.cc6
13 files changed, 158 insertions, 127 deletions
diff --git a/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc b/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc
index 04da3df..daa421f 100644
--- a/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc
+++ b/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc
@@ -65,8 +65,6 @@ TEST_F(XmppConnectionGeneratorTest, DnsFailure) {
}
TEST_F(XmppConnectionGeneratorTest, DnsFailureSynchronous) {
- MessageLoop message_loop;
-
EXPECT_CALL(delegate_, OnNewSettings(_)).Times(0);
EXPECT_CALL(delegate_, OnExhaustedSettings(_, _)).Times(1);
@@ -92,8 +90,6 @@ TEST_F(XmppConnectionGeneratorTest, ConnectionFailure) {
}
TEST_F(XmppConnectionGeneratorTest, ConnectionFailureSynchronous) {
- MessageLoop message_loop;
-
EXPECT_CALL(delegate_, OnNewSettings(_)).
Times(5).
WillRepeatedly(
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h
index 53a86da..77977c1 100644
--- a/net/base/host_resolver.h
+++ b/net/base/host_resolver.h
@@ -148,16 +148,13 @@ class NET_API HostResolver {
// the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if
// successful or an error code upon failure.
//
+ // When callback is null, the operation completes synchronously.
+ //
+ // When callback is non-null, the operation may be performed asynchronously.
// If the operation cannnot be completed synchronously, ERR_IO_PENDING will
// be returned and the real result code will be passed to the completion
// callback. Otherwise the result code is returned immediately from this
// call.
- //
- // When |callback| is null, there are two possibilities: either an IP
- // address literal is being resolved or lookup should be performed from
- // cache only, meaning info.only_use_cached_response() should be true; in
- // both cases operation should complete synchronously.
- //
// If |out_req| is non-NULL, then |*out_req| will be filled with a handle to
// the async request. This handle is not valid after the request has
// completed.
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index b317ca0..af7d0d3 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -44,10 +44,6 @@ namespace net {
namespace {
-// Limit the size of hostnames that will be resolved to combat issues in
-// some platform's resolvers.
-const size_t kMaxHostLength = 4096;
-
// Helper to mutate the linked list contained by AddressList to the given
// port. Note that in general this is dangerous since the AddressList's
// data might be shared (and you should use AddressList::SetPort).
@@ -1147,19 +1143,6 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
// Update the net log and notify registered observers.
OnStartRequest(source_net_log, request_net_log, request_id, info);
- // The result of |getaddrinfo| for empty hosts is inconsistent across systems.
- // On Windows it gives the default interface's address, whereas on Linux it
- // gives an error. We will make it fail on all platforms for consistency.
- if (info.hostname().empty() || info.hostname().size() > kMaxHostLength) {
- OnFinishRequest(source_net_log,
- request_net_log,
- request_id,
- info,
- ERR_NAME_NOT_RESOLVED,
- 0);
- return ERR_NAME_NOT_RESOLVED;
- }
-
// Build a key that identifies the request in the cache and in the
// outstanding jobs map.
Key key = GetEffectiveKeyForRequest(info);
@@ -1187,13 +1170,6 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
return net_error;
}
- // Sanity check -- it shouldn't be the case that allow_cached_response is
- // false while only_use_cached_response is true.
- DCHECK(info.allow_cached_response() || !info.only_use_cached_response());
-
- // If callback is NULL, we must be doing cache-only lookup.
- DCHECK(callback || info.only_use_cached_response());
-
// If we have an unexpired cache entry, use it.
if (info.allow_cached_response() && cache_.get()) {
const HostCache::Entry* cache_entry = cache_->Lookup(
@@ -1225,7 +1201,30 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
return ERR_NAME_NOT_RESOLVED;
}
- // Create a handle for this request, and pass it back to the user if they
+ // If no callback was specified, do a synchronous resolution.
+ if (!callback) {
+ AddressList addrlist;
+ int os_error = 0;
+ int error = ResolveAddrInfo(
+ effective_resolver_proc(), key.hostname, key.address_family,
+ key.host_resolver_flags, &addrlist, &os_error);
+ if (error == OK) {
+ MutableSetPort(info.port(), &addrlist);
+ *addresses = addrlist;
+ }
+
+ // Write to cache.
+ if (cache_.get())
+ cache_->Set(key, error, addrlist, base::TimeTicks::Now());
+
+ // Update the net log and notify registered observers.
+ OnFinishRequest(source_net_log, request_net_log, request_id, info, error,
+ os_error);
+
+ return error;
+ }
+
+ // Create a handle for this request, and pass it back to the user if they
// asked for it (out_req != NULL).
Request* req = new Request(source_net_log, request_net_log, request_id, info,
callback, addresses);
diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc
index e01f328..f89c38b 100644
--- a/net/base/host_resolver_impl_unittest.cc
+++ b/net/base/host_resolver_impl_unittest.cc
@@ -356,6 +356,41 @@ class HostResolverImplTest : public testing::Test {
}
};
+TEST_F(HostResolverImplTest, SynchronousLookup) {
+ AddressList addrlist;
+ const int kPortnum = 80;
+
+ scoped_refptr<RuleBasedHostResolverProc> resolver_proc(
+ new RuleBasedHostResolverProc(NULL));
+ resolver_proc->AddRule("just.testing", "192.168.1.42");
+
+ scoped_ptr<HostResolver> host_resolver(
+ CreateHostResolverImpl(resolver_proc));
+
+ HostResolver::RequestInfo info(HostPortPair("just.testing", kPortnum));
+ CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
+ int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound());
+ EXPECT_EQ(OK, err);
+
+ CapturingNetLog::EntryList entries;
+ log.GetEntries(&entries);
+
+ EXPECT_EQ(2u, entries.size());
+ EXPECT_TRUE(LogContainsBeginEvent(
+ entries, 0, NetLog::TYPE_HOST_RESOLVER_IMPL));
+ EXPECT_TRUE(LogContainsEndEvent(
+ entries, 1, NetLog::TYPE_HOST_RESOLVER_IMPL));
+
+ const struct addrinfo* ainfo = addrlist.head();
+ EXPECT_EQ(static_cast<addrinfo*>(NULL), ainfo->ai_next);
+ EXPECT_EQ(sizeof(struct sockaddr_in), ainfo->ai_addrlen);
+
+ const struct sockaddr* sa = ainfo->ai_addr;
+ const struct sockaddr_in* sa_in = (const struct sockaddr_in*) sa;
+ EXPECT_TRUE(htons(kPortnum) == sa_in->sin_port);
+ EXPECT_TRUE(htonl(0xc0a8012a) == sa_in->sin_addr.s_addr);
+}
+
TEST_F(HostResolverImplTest, AsynchronousLookup) {
AddressList addrlist;
const int kPortnum = 80;
@@ -535,8 +570,7 @@ TEST_F(HostResolverImplTest, EmptyHost) {
AddressList addrlist;
const int kPortnum = 5555;
HostResolver::RequestInfo info(HostPortPair("", kPortnum));
- int err = host_resolver->Resolve(info, &addrlist, NULL, NULL,
- BoundNetLog());
+ int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, BoundNetLog());
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, err);
}
@@ -956,11 +990,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host1".
HostResolver::RequestInfo info1(HostPortPair("host1", 70));
CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
- TestCompletionCallback callback;
- int rv = host_resolver->Resolve(info1, &addrlist, &callback, NULL,
- log.bound());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ int rv = host_resolver->Resolve(info1, &addrlist, NULL, NULL, log.bound());
EXPECT_EQ(OK, rv);
CapturingNetLog::EntryList entries;
@@ -982,6 +1012,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host1" again -- this time it will be served from cache, but it
// should still notify of completion.
+ TestCompletionCallback callback;
rv = host_resolver->Resolve(info1, &addrlist, &callback, NULL, BoundNetLog());
ASSERT_EQ(OK, rv); // Should complete synchronously.
@@ -996,9 +1027,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host2", setting referrer to "http://foobar.com"
HostResolver::RequestInfo info2(HostPortPair("host2", 70));
info2.set_referrer(GURL("http://foobar.com"));
- rv = host_resolver->Resolve(info2, &addrlist, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ rv = host_resolver->Resolve(info2, &addrlist, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ(3U, observer.start_log.size());
@@ -1014,7 +1043,7 @@ TEST_F(HostResolverImplTest, Observers) {
// Resolve "host3"
HostResolver::RequestInfo info3(HostPortPair("host3", 70));
- host_resolver->Resolve(info3, &addrlist, &callback, NULL, BoundNetLog());
+ host_resolver->Resolve(info3, &addrlist, NULL, NULL, BoundNetLog());
// No effect this time, since observer was removed.
EXPECT_EQ(3U, observer.start_log.size());
@@ -1619,6 +1648,61 @@ TEST_F(HostResolverImplTest, SetDefaultAddressFamily_IPv6) {
EXPECT_EQ("192.2.104.1", NetAddressToString(addrlist[2].head()));
}
+// This tests that the default address family is respected for synchronous
+// resolutions.
+TEST_F(HostResolverImplTest, SetDefaultAddressFamily_Synchronous) {
+ scoped_refptr<CapturingHostResolverProc> resolver_proc(
+ new CapturingHostResolverProc(new EchoingHostResolverProc));
+
+ scoped_ptr<HostResolverImpl> host_resolver(new HostResolverImpl(
+ resolver_proc, HostCache::CreateDefaultCache(), kMaxJobs,
+ kMaxRetryAttempts, NULL));
+
+ host_resolver->SetDefaultAddressFamily(ADDRESS_FAMILY_IPV4);
+
+ // Unblock the resolver thread so the requests can run.
+ resolver_proc->Signal();
+
+ HostResolver::RequestInfo req[] = {
+ CreateResolverRequestForAddressFamily("b", MEDIUM,
+ ADDRESS_FAMILY_UNSPECIFIED),
+ CreateResolverRequestForAddressFamily("b", MEDIUM, ADDRESS_FAMILY_IPV6),
+ CreateResolverRequestForAddressFamily("b", MEDIUM,
+ ADDRESS_FAMILY_UNSPECIFIED),
+ CreateResolverRequestForAddressFamily("b", MEDIUM, ADDRESS_FAMILY_IPV4),
+ };
+ AddressList addrlist[arraysize(req)];
+
+ // Start and run all of the requests synchronously.
+ for (size_t i = 0; i < arraysize(req); ++i) {
+ int rv = host_resolver->Resolve(req[i], &addrlist[i],
+ NULL, NULL, BoundNetLog());
+ EXPECT_EQ(OK, rv) << i;
+ }
+
+ // We should have sent 2 requests to the resolver --
+ // one for (b, IPv4), and one for (b, IPv6).
+ CapturingHostResolverProc::CaptureList capture_list =
+ resolver_proc->GetCaptureList();
+ ASSERT_EQ(2u, capture_list.size());
+
+ EXPECT_EQ("b", capture_list[0].hostname);
+ EXPECT_EQ(ADDRESS_FAMILY_IPV4, capture_list[0].address_family);
+
+ EXPECT_EQ("b", capture_list[1].hostname);
+ EXPECT_EQ(ADDRESS_FAMILY_IPV6, capture_list[1].address_family);
+
+ // Now check that the correct resolved IP addresses were returned.
+ // Addresses take the form: 192.x.y.z
+ // x = length of hostname
+ // y = ASCII value of hostname[0]
+ // z = value of address family
+ EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[0].head()));
+ EXPECT_EQ("192.1.98.2", NetAddressToString(addrlist[1].head()));
+ EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[2].head()));
+ EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[3].head()));
+}
+
TEST_F(HostResolverImplTest, DisallowNonCachedResponses) {
AddressList addrlist;
const int kPortnum = 80;
@@ -1639,10 +1723,7 @@ TEST_F(HostResolverImplTest, DisallowNonCachedResponses) {
// This time, we fetch normally.
info.set_only_use_cached_response(false);
- TestCompletionCallback callback;
- err = host_resolver->Resolve(info, &addrlist, &callback, NULL, log.bound());
- EXPECT_EQ(ERR_IO_PENDING, err);
- err = callback.WaitForResult();
+ err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound());
EXPECT_EQ(OK, err);
// Now we should be able to fetch from the cache.
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc
index 755f119..88e0ba1 100644
--- a/net/base/host_resolver_proc.cc
+++ b/net/base/host_resolver_proc.cc
@@ -122,9 +122,22 @@ int SystemHostResolverProc(const std::string& host,
HostResolverFlags host_resolver_flags,
AddressList* addrlist,
int* os_error) {
+ static const size_t kMaxHostLength = 4096;
+
if (os_error)
*os_error = 0;
+ // The result of |getaddrinfo| for empty hosts is inconsistent across systems.
+ // On Windows it gives the default interface's address, whereas on Linux it
+ // gives an error. We will make it fail on all platforms for consistency.
+ if (host.empty())
+ return ERR_NAME_NOT_RESOLVED;
+
+ // Limit the size of hostnames that will be resolved to combat issues in some
+ // platform's resolvers.
+ if (host.size() > kMaxHostLength)
+ return ERR_NAME_NOT_RESOLVED;
+
struct addrinfo* ai = NULL;
struct addrinfo hints = {0};
diff --git a/net/base/mapped_host_resolver_unittest.cc b/net/base/mapped_host_resolver_unittest.cc
index 2a03287..3531003 100644
--- a/net/base/mapped_host_resolver_unittest.cc
+++ b/net/base/mapped_host_resolver_unittest.cc
@@ -8,7 +8,6 @@
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
-#include "net/base/test_completion_callback.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -32,12 +31,9 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "www.google.com:80". There are no mappings yet, so this
// hits |resolver_impl| and fails.
- TestCompletionCallback callback;
rv = resolver->Resolve(HostResolver::RequestInfo(
HostPortPair("www.google.com", 80)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv);
// Remap *.google.com to baz.com.
@@ -46,9 +42,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "www.google.com:80". Should be remapped to "baz.com:80".
rv = resolver->Resolve(HostResolver::RequestInfo(
HostPortPair("www.google.com", 80)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.5", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
@@ -56,9 +50,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "foo.com:77". This will NOT be remapped, so result
// is "foo.com:77".
rv = resolver->Resolve(HostResolver::RequestInfo(HostPortPair("foo.com", 77)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.8", NetAddressToString(address_list.head()));
EXPECT_EQ(77, address_list.GetPort());
@@ -69,9 +61,7 @@ TEST(MappedHostResolverTest, Inclusion) {
// Try resolving "chromium.org:61". Should be remapped to "proxy:99".
rv = resolver->Resolve(HostResolver::RequestInfo
(HostPortPair("chromium.org", 61)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.11", NetAddressToString(address_list.head()));
EXPECT_EQ(99, address_list.GetPort());
@@ -90,7 +80,6 @@ TEST(MappedHostResolverTest, Exclusion) {
int rv;
AddressList address_list;
- TestCompletionCallback callback;
// Remap "*.com" to "baz".
EXPECT_TRUE(resolver->AddRuleFromString("map *.com baz"));
@@ -101,9 +90,7 @@ TEST(MappedHostResolverTest, Exclusion) {
// Try resolving "www.google.com". Should not be remapped due to exclusion).
rv = resolver->Resolve(HostResolver::RequestInfo(
HostPortPair("www.google.com", 80)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.3", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
@@ -111,9 +98,7 @@ TEST(MappedHostResolverTest, Exclusion) {
// Try resolving "chrome.com:80". Should be remapped to "baz:80".
rv = resolver->Resolve(HostResolver::RequestInfo(
HostPortPair("chrome.com", 80)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.5", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
@@ -131,7 +116,6 @@ TEST(MappedHostResolverTest, SetRulesFromString) {
int rv;
AddressList address_list;
- TestCompletionCallback callback;
// Remap "*.com" to "baz", and *.net to "bar:60".
resolver->SetRulesFromString("map *.com baz , map *.net bar:60");
@@ -139,9 +123,7 @@ TEST(MappedHostResolverTest, SetRulesFromString) {
// Try resolving "www.google.com". Should be remapped to "baz".
rv = resolver->Resolve(HostResolver::RequestInfo(
HostPortPair("www.google.com", 80)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.7", NetAddressToString(address_list.head()));
EXPECT_EQ(80, address_list.GetPort());
@@ -149,9 +131,7 @@ TEST(MappedHostResolverTest, SetRulesFromString) {
// Try resolving "chrome.net:80". Should be remapped to "bar:60".
rv = resolver->Resolve(HostResolver::RequestInfo(
HostPortPair("chrome.net", 80)),
- &address_list, &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ &address_list, NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
EXPECT_EQ("192.168.1.9", NetAddressToString(address_list.head()));
EXPECT_EQ(60, address_list.GetPort());
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index f822bde..3cc4a82 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -11,7 +11,6 @@
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
-#include "net/base/test_completion_callback.h"
namespace net {
@@ -101,13 +100,8 @@ int MockHostResolverBase::Resolve(const RequestInfo& info,
RequestHandle* out_req,
const BoundNetLog& net_log) {
if (synchronous_mode_) {
- TestCompletionCallback sync_callback;
- int rv = impl_->Resolve(info, addresses, &sync_callback, out_req, net_log);
- if (rv == ERR_IO_PENDING) {
- MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
- return sync_callback.WaitForResult();
- }
- return rv;
+ callback = NULL;
+ out_req = NULL;
}
return impl_->Resolve(info, addresses, callback, out_req, net_log);
}
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 9679667..2a942dc 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -5833,21 +5833,20 @@ void BypassHostCacheOnRefreshHelper(int load_flags) {
scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
CreateSession(&session_deps)));
- // Warm up the host cache so it has an entry for "www.google.com".
+ // Warm up the host cache so it has an entry for "www.google.com" (by doing
+ // a synchronous lookup.)
AddressList addrlist;
- TestCompletionCallback callback;
int rv = session_deps.host_resolver->Resolve(
HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), &addrlist,
- &callback, NULL, BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ NULL, NULL, BoundNetLog());
EXPECT_EQ(OK, rv);
// Verify that it was added to host cache, by doing a subsequent async lookup
// and confirming it completes synchronously.
+ TestCompletionCallback resolve_callback;
rv = session_deps.host_resolver->Resolve(
HostResolver::RequestInfo(HostPortPair("www.google.com", 80)), &addrlist,
- &callback, NULL, BoundNetLog());
+ &resolve_callback, NULL, BoundNetLog());
ASSERT_EQ(OK, rv);
// Inject a failure the next time that "www.google.com" is resolved. This way
@@ -5862,6 +5861,7 @@ void BypassHostCacheOnRefreshHelper(int load_flags) {
session_deps.socket_factory.AddSocketDataProvider(&data);
// Run the request.
+ TestCompletionCallback callback;
rv = trans->Start(&request, &callback, BoundNetLog());
ASSERT_EQ(ERR_IO_PENDING, rv);
rv = callback.WaitForResult();
@@ -8721,12 +8721,7 @@ void IPPoolingAddAlias(MockCachingHostResolver* host_resolver,
// Resolve the host and port.
AddressList addresses;
HostResolver::RequestInfo info(host_port_pair);
- TestCompletionCallback callback;
- int rv = host_resolver->Resolve(info, &addresses, &callback, NULL,
- BoundNetLog());
- if (rv == ERR_IO_PENDING)
- rv = callback.WaitForResult();
- DCHECK_EQ(OK, rv);
+ host_resolver->Resolve(info, &addresses, NULL, NULL, BoundNetLog());
// Add the first address as an alias. It would have been better to call
// MockClientSocket::GetPeerAddress but that returns 192.0.2.33 whereas
@@ -8813,11 +8808,7 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) {
HostPortPair host_port("www.gmail.com", 443);
HostResolver::RequestInfo resolve_info(host_port);
AddressList ignored;
- rv = host_resolver.Resolve(resolve_info, &ignored, &callback, NULL,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
- EXPECT_EQ(OK, rv);
+ host_resolver.Resolve(resolve_info, &ignored, NULL, NULL, BoundNetLog());
// MockHostResolver returns 127.0.0.1, port 443 for https://www.google.com/
// and https://www.gmail.com/. Add 127.0.0.1 as alias for host_port_pair:
@@ -8969,11 +8960,7 @@ TEST_F(HttpNetworkTransactionTest,
// Preload cache entries into HostCache.
HostResolver::RequestInfo resolve_info(HostPortPair("www.gmail.com", 443));
AddressList ignored;
- rv = host_resolver.Resolve(resolve_info, &ignored, &callback, NULL,
- BoundNetLog());
- EXPECT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
- EXPECT_EQ(OK, rv);
+ host_resolver.Resolve(resolve_info, &ignored, NULL, NULL, BoundNetLog());
HttpRequestInfo request2;
request2.method = "GET";
diff --git a/net/proxy/proxy_resolver_js_bindings_unittest.cc b/net/proxy/proxy_resolver_js_bindings_unittest.cc
index 1c580b9..2942978 100644
--- a/net/proxy/proxy_resolver_js_bindings_unittest.cc
+++ b/net/proxy/proxy_resolver_js_bindings_unittest.cc
@@ -14,7 +14,6 @@
#include "net/base/net_log_unittest.h"
#include "net/base/net_util.h"
#include "net/base/sys_addrinfo.h"
-#include "net/base/test_completion_callback.h"
#include "net/proxy/proxy_resolver_request_context.h"
#include "net/proxy/sync_host_resolver.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -92,10 +91,6 @@ class MockFailingHostResolver : public SyncHostResolver {
class MockSyncHostResolver : public SyncHostResolver {
public:
- MockSyncHostResolver() {
- resolver_.set_synchronous_mode(true);
- }
-
virtual int Resolve(const HostResolver::RequestInfo& info,
AddressList* addresses) OVERRIDE {
return resolver_.Resolve(info, addresses, NULL, NULL, BoundNetLog());
diff --git a/net/socket/socks5_client_socket_unittest.cc b/net/socket/socks5_client_socket_unittest.cc
index 68125de..4f99d5d 100644
--- a/net/socket/socks5_client_socket_unittest.cc
+++ b/net/socket/socks5_client_socket_unittest.cc
@@ -67,11 +67,8 @@ void SOCKS5ClientSocketTest::SetUp() {
// Resolve the "localhost" AddressList used by the TCP connection to connect.
HostResolver::RequestInfo info(HostPortPair("www.socks-proxy.com", 1080));
- TestCompletionCallback callback;
- int rv = host_resolver_->Resolve(info, &address_list_, &callback, NULL,
+ int rv = host_resolver_->Resolve(info, &address_list_, NULL, NULL,
BoundNetLog());
- ASSERT_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
ASSERT_EQ(OK, rv);
}
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index d57eed6..1692cf3 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -1055,7 +1055,6 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) {
};
client_socket_factory_.set_client_socket_types(case_types, 2);
- client_socket_factory_.set_delay_ms(5000);
EXPECT_EQ(0, pool_.IdleSocketCount());
diff --git a/net/socket/transport_client_socket_unittest.cc b/net/socket/transport_client_socket_unittest.cc
index 1379f4a..8f377e5 100644
--- a/net/socket/transport_client_socket_unittest.cc
+++ b/net/socket/transport_client_socket_unittest.cc
@@ -122,10 +122,7 @@ void TransportClientSocketTest::SetUp() {
HostResolver::kDefaultRetryAttempts,
NULL));
HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_));
- TestCompletionCallback callback;
- int rv = resolver->Resolve(info, &addr, &callback, NULL, BoundNetLog());
- CHECK_EQ(ERR_IO_PENDING, rv);
- rv = callback.WaitForResult();
+ int rv = resolver->Resolve(info, &addr, NULL, NULL, BoundNetLog());
CHECK_EQ(rv, OK);
sock_.reset(
socket_factory_->CreateTransportClientSocket(addr,
diff --git a/net/test/test_server.cc b/net/test/test_server.cc
index 8723215..dd36bce 100644
--- a/net/test/test_server.cc
+++ b/net/test/test_server.cc
@@ -200,11 +200,7 @@ bool TestServer::GetAddressList(AddressList* address_list) const {
HostResolver::kDefaultRetryAttempts,
NULL));
HostResolver::RequestInfo info(host_port_pair_);
- TestCompletionCallback callback;
- int rv = resolver->Resolve(info, address_list, &callback, NULL,
- BoundNetLog());
- if (rv == ERR_IO_PENDING)
- rv = callback.WaitForResult();
+ int rv = resolver->Resolve(info, address_list, NULL, NULL, BoundNetLog());
if (rv != net::OK) {
LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host();
return false;