OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 } | 1658 } |
1659 | 1659 |
1660 TEST_F(HostResolverImplTest, DisallowNonCachedResponses) { | 1660 TEST_F(HostResolverImplTest, DisallowNonCachedResponses) { |
1661 AddressList addrlist; | 1661 AddressList addrlist; |
1662 const int kPortnum = 80; | 1662 const int kPortnum = 80; |
1663 | 1663 |
1664 scoped_refptr<RuleBasedHostResolverProc> resolver_proc( | 1664 scoped_refptr<RuleBasedHostResolverProc> resolver_proc( |
1665 new RuleBasedHostResolverProc(NULL)); | 1665 new RuleBasedHostResolverProc(NULL)); |
1666 resolver_proc->AddRule("just.testing", "192.168.1.42"); | 1666 resolver_proc->AddRule("just.testing", "192.168.1.42"); |
1667 | 1667 |
1668 scoped_ptr<HostResolver> host_resolver( | 1668 scoped_ptr<HostResolver> host_resolver( |
1669 CreateHostResolverImpl(resolver_proc)); | 1669 CreateHostResolverImpl(resolver_proc)); |
1670 | 1670 |
1671 // First hit will miss the cache. | 1671 // First hit will miss the cache. |
1672 HostResolver::RequestInfo info(HostPortPair("just.testing", kPortnum)); | 1672 HostResolver::RequestInfo info(HostPortPair("just.testing", kPortnum)); |
1673 info.set_only_use_cached_response(true); | 1673 info.set_only_use_cached_response(true); |
1674 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); | 1674 CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
1675 int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); | 1675 int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); |
1676 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, err); | 1676 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, err); |
1677 | 1677 |
1678 // This time, we fetch normally. | 1678 // This time, we fetch normally. |
1679 info.set_only_use_cached_response(false); | 1679 info.set_only_use_cached_response(false); |
1680 err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); | 1680 err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); |
1681 EXPECT_EQ(OK, err); | 1681 EXPECT_EQ(OK, err); |
(...skipping 10 matching lines...) Expand all Loading... |
1692 const struct sockaddr* sa = ainfo->ai_addr; | 1692 const struct sockaddr* sa = ainfo->ai_addr; |
1693 const struct sockaddr_in* sa_in = reinterpret_cast<const sockaddr_in*>(sa); | 1693 const struct sockaddr_in* sa_in = reinterpret_cast<const sockaddr_in*>(sa); |
1694 EXPECT_TRUE(htons(kPortnum) == sa_in->sin_port); | 1694 EXPECT_TRUE(htons(kPortnum) == sa_in->sin_port); |
1695 EXPECT_TRUE(htonl(0xc0a8012a) == sa_in->sin_addr.s_addr); | 1695 EXPECT_TRUE(htonl(0xc0a8012a) == sa_in->sin_addr.s_addr); |
1696 } | 1696 } |
1697 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 1697 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. |
1698 | 1698 |
1699 } // namespace | 1699 } // namespace |
1700 | 1700 |
1701 } // namespace net | 1701 } // namespace net |
OLD | NEW |