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

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

Issue 8762001: Isolates generic DnsClient from AsyncHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retrying to fix status of dns_session.h 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
25 bool ConvertStringsToIPAddressList( 11 bool ConvertStringsToIPAddressList(
26 const char* const ip_strings[], size_t size, IPAddressList* address_list) { 12 const char* const ip_strings[], size_t size, IPAddressList* address_list) {
27 DCHECK(address_list); 13 DCHECK(address_list);
28 IPAddressList ip_addresses; 14 IPAddressList ip_addresses;
29 for (size_t i = 0; i < size; ++i) { 15 for (size_t i = 0; i < size; ++i) {
30 IPAddressNumber ip; 16 IPAddressNumber ip;
31 if (!ParseIPLiteralToNumber(ip_strings[i], &ip)) 17 if (!ParseIPLiteralToNumber(ip_strings[i], &ip))
32 return false; 18 return false;
33 ip_addresses.push_back(ip); 19 ip_addresses.push_back(ip);
34 } 20 }
35 address_list->swap(ip_addresses); 21 address_list->swap(ip_addresses);
36 return true; 22 return true;
37 } 23 }
38 24
39 bool CreateDnsAddress( 25 bool CreateDnsAddress(
40 const char* ip_string, uint16 port, IPEndPoint* endpoint) { 26 const char* ip_string, uint16 port, IPEndPoint* endpoint) {
41 DCHECK(endpoint); 27 DCHECK(endpoint);
42 IPAddressNumber ip_address; 28 IPAddressNumber ip_address;
43 if (!ParseIPLiteralToNumber(ip_string, &ip_address)) 29 if (!ParseIPLiteralToNumber(ip_string, &ip_address))
44 return false; 30 return false;
45 *endpoint = IPEndPoint(ip_address, port); 31 *endpoint = IPEndPoint(ip_address, port);
46 return true; 32 return true;
47 } 33 }
48 34
49 } // namespace net 35 } // 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