diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 13:19:10 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 13:19:10 +0000 |
commit | 19bdc0036b036f4b33c8d81536a9848c6a95c9f7 (patch) | |
tree | f9803f03723dd6b218ed4a6fe08f3edc12572d5d /net/dns/dns_test_util.h | |
parent | ccf637be7edd3bdb14dc4157e6370e78c619a8f6 (diff) | |
download | chromium_src-19bdc0036b036f4b33c8d81536a9848c6a95c9f7.zip chromium_src-19bdc0036b036f4b33c8d81536a9848c6a95c9f7.tar.gz chromium_src-19bdc0036b036f4b33c8d81536a9848c6a95c9f7.tar.bz2 |
Revert 113282 - Isolates generic DnsClient from AsyncHostResolver.
There were a few memory issues including access of unadressable memory.
DnsClient provides a generic DNS client that allows fetching resource records.
DnsClient is very lightweight and does not support aggregation, queuing or
prioritization of requests.
This is the first CL in a series to merge AsyncHostResolver into
HostResolverImpl.
Also introduces general-purpose BigEndianReader/Writer.
BUG=90881
TEST=./net_unittests
Review URL: http://codereview.chromium.org/8762001
TBR=szym@chromium.org
Review URL: http://codereview.chromium.org/8835011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/dns/dns_test_util.h')
-rw-r--r-- | net/dns/dns_test_util.h | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/net/dns/dns_test_util.h b/net/dns/dns_test_util.h index c59a58f..651cfcb 100644 --- a/net/dns/dns_test_util.h +++ b/net/dns/dns_test_util.h @@ -14,10 +14,26 @@ #include "net/base/host_resolver.h" #include "net/base/ip_endpoint.h" #include "net/base/net_util.h" -#include "net/dns/dns_protocol.h" namespace net { +// DNS related classes make use of PRNG for various tasks. This class is +// used as a PRNG for unit testing those tasks. It takes a deque of +// integers |numbers| which should be returned by calls to GetNext. +class TestPrng { + public: + explicit TestPrng(const std::deque<int>& numbers); + ~TestPrng(); + + // Pops and returns the next number from |numbers_| deque. + int GetNext(int min, int max); + + private: + std::deque<int> numbers_; + + DISALLOW_COPY_AND_ASSIGN(TestPrng); +}; + // A utility function for tests that given an array of IP literals, // converts it to an IPAddressList. bool ConvertStringsToIPAddressList( @@ -33,7 +49,7 @@ static const uint16 kDnsPort = 53; //----------------------------------------------------------------------------- // Query/response set for www.google.com, ID is fixed to 0. static const char kT0HostName[] = "www.google.com"; -static const uint16 kT0Qtype = dns_protocol::kTypeA; +static const uint16 kT0Qtype = kDNS_A; static const char kT0DnsName[] = { 0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', 'l', 'e', @@ -76,10 +92,10 @@ static const char* const kT0IpAddresses[] = { //----------------------------------------------------------------------------- // Query/response set for codereview.chromium.org, ID is fixed to 1. static const char kT1HostName[] = "codereview.chromium.org"; -static const uint16 kT1Qtype = dns_protocol::kTypeA; +static const uint16 kT1Qtype = kDNS_A; static const char kT1DnsName[] = { - 0x0a, 'c', 'o', 'd', 'e', 'r', 'e', 'v', 'i', 'e', 'w', - 0x08, 'c', 'h', 'r', 'o', 'm', 'i', 'u', 'm', + 0x12, 'c', 'o', 'd', 'e', 'r', 'e', 'v', 'i', 'e', 'w', + 0x10, 'c', 'h', 'r', 'o', 'm', 'i', 'u', 'm', 0x03, 'o', 'r', 'g', 0x00 }; @@ -114,10 +130,10 @@ static const char* const kT1IpAddresses[] = { //----------------------------------------------------------------------------- // Query/response set for www.ccs.neu.edu, ID is fixed to 2. static const char kT2HostName[] = "www.ccs.neu.edu"; -static const uint16 kT2Qtype = dns_protocol::kTypeA; +static const uint16 kT2Qtype = kDNS_A; static const char kT2DnsName[] = { 0x03, 'w', 'w', 'w', - 0x03, 'c', 'c', 's', + 0x03, 'c', 'c', 'c', 0x03, 'n', 'e', 'u', 0x03, 'e', 'd', 'u', 0x00 @@ -150,7 +166,7 @@ static const char* const kT2IpAddresses[] = { //----------------------------------------------------------------------------- // Query/response set for www.google.az, ID is fixed to 3. static const char kT3HostName[] = "www.google.az"; -static const uint16 kT3Qtype = dns_protocol::kTypeA; +static const uint16 kT3Qtype = kDNS_A; static const char kT3DnsName[] = { 0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |