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

Side by Side Diff: net/dns/dns_test_util.cc

Issue 8835011: Revert 113282 - Isolates generic DnsClient from AsyncHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « net/dns/dns_test_util.h ('k') | net/dns/dns_transaction.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/dns/dns_test_util.h" 5 #include "net/dns/dns_test_util.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 TestPrng::TestPrng(const std::deque<int>& numbers) : numbers_(numbers) {
12 }
13
14 TestPrng::~TestPrng() {
15 }
16
17 int TestPrng::GetNext(int min, int max) {
18 DCHECK(!numbers_.empty());
19 int rv = numbers_.front();
20 numbers_.pop_front();
21 DCHECK(rv >= min && rv <= max);
22 return rv;
23 }
24
11 bool ConvertStringsToIPAddressList( 25 bool ConvertStringsToIPAddressList(
12 const char* const ip_strings[], size_t size, IPAddressList* address_list) { 26 const char* const ip_strings[], size_t size, IPAddressList* address_list) {
13 DCHECK(address_list); 27 DCHECK(address_list);
14 IPAddressList ip_addresses; 28 IPAddressList ip_addresses;
15 for (size_t i = 0; i < size; ++i) { 29 for (size_t i = 0; i < size; ++i) {
16 IPAddressNumber ip; 30 IPAddressNumber ip;
17 if (!ParseIPLiteralToNumber(ip_strings[i], &ip)) 31 if (!ParseIPLiteralToNumber(ip_strings[i], &ip))
18 return false; 32 return false;
19 ip_addresses.push_back(ip); 33 ip_addresses.push_back(ip);
20 } 34 }
21 address_list->swap(ip_addresses); 35 address_list->swap(ip_addresses);
22 return true; 36 return true;
23 } 37 }
24 38
25 bool CreateDnsAddress( 39 bool CreateDnsAddress(
26 const char* ip_string, uint16 port, IPEndPoint* endpoint) { 40 const char* ip_string, uint16 port, IPEndPoint* endpoint) {
27 DCHECK(endpoint); 41 DCHECK(endpoint);
28 IPAddressNumber ip_address; 42 IPAddressNumber ip_address;
29 if (!ParseIPLiteralToNumber(ip_string, &ip_address)) 43 if (!ParseIPLiteralToNumber(ip_string, &ip_address))
30 return false; 44 return false;
31 *endpoint = IPEndPoint(ip_address, port); 45 *endpoint = IPEndPoint(ip_address, port);
32 return true; 46 return true;
33 } 47 }
34 48
35 } // namespace net 49 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_test_util.h ('k') | net/dns/dns_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698