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

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

Issue 9369045: [net] HostResolverImpl + DnsTransaction + DnsConfigService = Asynchronous DNS ready for experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for test-drive. Created 8 years, 10 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_transaction.h" 5 #include "net/dns/dns_transaction.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 class ResponseParameters : public NetLog::EventParameters { 72 class ResponseParameters : public NetLog::EventParameters {
73 public: 73 public:
74 ResponseParameters(int rcode, int answer_count, const NetLog::Source& source) 74 ResponseParameters(int rcode, int answer_count, const NetLog::Source& source)
75 : rcode_(rcode), answer_count_(answer_count), source_(source) {} 75 : rcode_(rcode), answer_count_(answer_count), source_(source) {}
76 76
77 virtual Value* ToValue() const OVERRIDE { 77 virtual Value* ToValue() const OVERRIDE {
78 DictionaryValue* dict = new DictionaryValue(); 78 DictionaryValue* dict = new DictionaryValue();
79 dict->SetInteger("rcode", rcode_); 79 dict->SetInteger("rcode", rcode_);
80 dict->SetInteger("answer_count", answer_count_); 80 dict->SetInteger("answer_count", answer_count_);
81 dict->Set("socket_source", source_.ToValue()); 81 dict->Set("source_dependency", source_.ToValue());
cbentzel 2012/02/10 19:51:08 Is this going to impact backwards compatibility of
szym 2012/02/10 21:49:36 These event parameters have been introduced recent
82 return dict; 82 return dict;
83 } 83 }
84 84
85 private: 85 private:
86 const int rcode_; 86 const int rcode_;
87 const int answer_count_; 87 const int answer_count_;
88 const NetLog::Source source_; 88 const NetLog::Source source_;
89 }; 89 };
90 90
91 // ---------------------------------------------------------------------------- 91 // ----------------------------------------------------------------------------
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 base::Bind(&DnsUDPAttempt::OnIOComplete, 204 base::Bind(&DnsUDPAttempt::OnIOComplete,
205 base::Unretained(this))); 205 base::Unretained(this)));
206 } 206 }
207 207
208 int DoReadResponseComplete(int rv) { 208 int DoReadResponseComplete(int rv) {
209 DCHECK_NE(ERR_IO_PENDING, rv); 209 DCHECK_NE(ERR_IO_PENDING, rv);
210 if (rv < 0) 210 if (rv < 0)
211 return rv; 211 return rv;
212 212
213 DCHECK(rv); 213 DCHECK(rv);
214 // TODO(szym): Consider making this check less aggressive.
215 // Other implementations simply ignore mismatched responses.
214 if (!response_->InitParse(rv, *query_)) 216 if (!response_->InitParse(rv, *query_))
215 return ERR_DNS_MALFORMED_RESPONSE; 217 return ERR_DNS_MALFORMED_RESPONSE;
216 if (response_->flags() & dns_protocol::kFlagTC) 218 if (response_->flags() & dns_protocol::kFlagTC)
217 return ERR_DNS_SERVER_REQUIRES_TCP; 219 return ERR_DNS_SERVER_REQUIRES_TCP;
218 if (response_->rcode() != dns_protocol::kRcodeNOERROR && 220 if (response_->rcode() != dns_protocol::kRcodeNOERROR &&
219 response_->rcode() != dns_protocol::kRcodeNXDOMAIN) { 221 response_->rcode() != dns_protocol::kRcodeNXDOMAIN) {
220 return ERR_DNS_SERVER_FAILED; 222 return ERR_DNS_SERVER_FAILED;
221 } 223 }
222 if (response_->answer_count() == 0) 224 if (response_->answer_count() == 0)
223 return ERR_NAME_NOT_RESOLVED; 225 return ERR_NAME_NOT_RESOLVED;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 382
381 uint16 id = session_->NextQueryId(); 383 uint16 id = session_->NextQueryId();
382 scoped_ptr<DnsQuery> query; 384 scoped_ptr<DnsQuery> query;
383 if (attempts_.empty()) { 385 if (attempts_.empty()) {
384 query.reset(new DnsQuery(id, qnames_.front(), qtype_)); 386 query.reset(new DnsQuery(id, qnames_.front(), qtype_));
385 } else { 387 } else {
386 query.reset(attempts_[0]->query()->CloneWithNewId(id)); 388 query.reset(attempts_[0]->query()->CloneWithNewId(id));
387 } 389 }
388 390
389 net_log_.AddEvent(NetLog::TYPE_DNS_TRANSACTION_ATTEMPT, make_scoped_refptr( 391 net_log_.AddEvent(NetLog::TYPE_DNS_TRANSACTION_ATTEMPT, make_scoped_refptr(
390 new NetLogSourceParameter("socket_source", socket->NetLog().source()))); 392 new NetLogSourceParameter("source_dependency",
393 socket->NetLog().source())));
391 394
392 const DnsConfig& config = session_->config(); 395 const DnsConfig& config = session_->config();
393 396
394 unsigned server_index = first_server_index_ + 397 unsigned server_index = first_server_index_ +
395 (attempt_number % config.nameservers.size()); 398 (attempt_number % config.nameservers.size());
396 399
397 DnsUDPAttempt* attempt = new DnsUDPAttempt( 400 DnsUDPAttempt* attempt = new DnsUDPAttempt(
398 socket.Pass(), 401 socket.Pass(),
399 config.nameservers[server_index], 402 config.nameservers[server_index],
400 query.Pass(), 403 query.Pass(),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 531
529 // static 532 // static
530 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( 533 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory(
531 DnsSession* session) { 534 DnsSession* session) {
532 return scoped_ptr<DnsTransactionFactory>( 535 return scoped_ptr<DnsTransactionFactory>(
533 new DnsTransactionFactoryImpl(session)); 536 new DnsTransactionFactoryImpl(session));
534 } 537 }
535 538
536 } // namespace net 539 } // namespace net
537 540
OLDNEW
« net/dns/dns_response_unittest.cc ('K') | « net/dns/dns_response_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698