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

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

Issue 10442098: [net/dns] Resolve AF_UNSPEC on dual-stacked systems. Sort addresses according to RFC3484. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working AddressSorterWin + measurements. Created 8 years, 6 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/sys_byteorder.h" 12 #include "base/sys_byteorder.h"
13 #include "net/base/big_endian.h" 13 #include "net/base/big_endian.h"
14 #include "net/base/dns_util.h" 14 #include "net/base/dns_util.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/dns/address_sorter.h"
17 #include "net/dns/dns_client.h" 18 #include "net/dns/dns_client.h"
18 #include "net/dns/dns_config_service.h" 19 #include "net/dns/dns_config_service.h"
19 #include "net/dns/dns_protocol.h" 20 #include "net/dns/dns_protocol.h"
20 #include "net/dns/dns_query.h" 21 #include "net/dns/dns_query.h"
21 #include "net/dns/dns_response.h" 22 #include "net/dns/dns_response.h"
22 #include "net/dns/dns_transaction.h" 23 #include "net/dns/dns_transaction.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace net { 26 namespace net {
26 namespace { 27 namespace {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 virtual scoped_ptr<DnsTransaction> CreateTransaction( 127 virtual scoped_ptr<DnsTransaction> CreateTransaction(
127 const std::string& hostname, 128 const std::string& hostname,
128 uint16 qtype, 129 uint16 qtype,
129 const DnsTransactionFactory::CallbackType& callback, 130 const DnsTransactionFactory::CallbackType& callback,
130 const BoundNetLog&) OVERRIDE { 131 const BoundNetLog&) OVERRIDE {
131 return scoped_ptr<DnsTransaction>( 132 return scoped_ptr<DnsTransaction>(
132 new MockTransaction(hostname, qtype, callback)); 133 new MockTransaction(hostname, qtype, callback));
133 } 134 }
134 }; 135 };
135 136
137 class MockAddressSorter : public AddressSorter {
138 public:
139 virtual ~MockAddressSorter() {}
140 virtual bool Sort(AddressList* list) const OVERRIDE {
141 // Do nothing.
142 return true;
143 }
144 };
145
136 // MockDnsClient provides MockTransactionFactory. 146 // MockDnsClient provides MockTransactionFactory.
137 class MockDnsClient : public DnsClient { 147 class MockDnsClient : public DnsClient {
138 public: 148 public:
139 explicit MockDnsClient(const DnsConfig& config) : config_(config) {} 149 explicit MockDnsClient(const DnsConfig& config) : config_(config) {}
140 virtual ~MockDnsClient() {} 150 virtual ~MockDnsClient() {}
141 151
142 virtual void SetConfig(const DnsConfig& config) OVERRIDE { 152 virtual void SetConfig(const DnsConfig& config) OVERRIDE {
143 config_ = config; 153 config_ = config;
144 } 154 }
145 155
146 virtual const DnsConfig* GetConfig() const OVERRIDE { 156 virtual const DnsConfig* GetConfig() const OVERRIDE {
147 return config_.IsValid() ? &config_ : NULL; 157 return config_.IsValid() ? &config_ : NULL;
148 } 158 }
149 159
150 virtual DnsTransactionFactory* GetTransactionFactory() OVERRIDE { 160 virtual DnsTransactionFactory* GetTransactionFactory() OVERRIDE {
151 return config_.IsValid() ? &factory_ : NULL; 161 return config_.IsValid() ? &factory_ : NULL;
152 } 162 }
153 163
164 virtual AddressSorter* GetAddressSorter() OVERRIDE {
165 return &address_sorter_;
166 }
167
154 private: 168 private:
155 DnsConfig config_; 169 DnsConfig config_;
156 MockTransactionFactory factory_; 170 MockTransactionFactory factory_;
171 MockAddressSorter address_sorter_;
157 }; 172 };
158 173
159 } // namespace 174 } // namespace
160 175
161 // static 176 // static
162 scoped_ptr<DnsClient> CreateMockDnsClient(const DnsConfig& config) { 177 scoped_ptr<DnsClient> CreateMockDnsClient(const DnsConfig& config) {
163 return scoped_ptr<DnsClient>(new MockDnsClient(config)); 178 return scoped_ptr<DnsClient>(new MockDnsClient(config));
164 } 179 }
165 180
166 MockDnsConfigService::~MockDnsConfigService() { 181 MockDnsConfigService::~MockDnsConfigService() {
167 } 182 }
168 183
169 void MockDnsConfigService::OnDNSChanged(unsigned detail) { 184 void MockDnsConfigService::OnDNSChanged(unsigned detail) {
170 } 185 }
171 186
172 void MockDnsConfigService::ChangeConfig(const DnsConfig& config) { 187 void MockDnsConfigService::ChangeConfig(const DnsConfig& config) {
173 DnsConfigService::OnConfigRead(config); 188 DnsConfigService::OnConfigRead(config);
174 } 189 }
175 190
176 void MockDnsConfigService::ChangeHosts(const DnsHosts& hosts) { 191 void MockDnsConfigService::ChangeHosts(const DnsHosts& hosts) {
177 DnsConfigService::OnHostsRead(hosts); 192 DnsConfigService::OnHostsRead(hosts);
178 } 193 }
179 194
180 } // namespace net 195 } // namespace net
OLDNEW
« net/dns/address_sorter_win.cc ('K') | « net/dns/dns_response.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698