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

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

Issue 1135373002: Updated NetLog::ParametersCallback & all related calbacks returning value as scoped_ptr<base::Value… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « net/dns/dns_config_service.cc ('k') | net/dns/host_resolver.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) 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 for (size_t i = 0; i < name.size() && name[i]; i += name[i] + 1) 51 for (size_t i = 0; i < name.size() && name[i]; i += name[i] + 1)
52 ++count; 52 ++count;
53 return count; 53 return count;
54 } 54 }
55 55
56 bool IsIPLiteral(const std::string& hostname) { 56 bool IsIPLiteral(const std::string& hostname) {
57 IPAddressNumber ip; 57 IPAddressNumber ip;
58 return ParseIPLiteralToNumber(hostname, &ip); 58 return ParseIPLiteralToNumber(hostname, &ip);
59 } 59 }
60 60
61 base::Value* NetLogStartCallback(const std::string* hostname, 61 scoped_ptr<base::Value> NetLogStartCallback(
62 uint16 qtype, 62 const std::string* hostname,
63 NetLogCaptureMode /* capture_mode */) { 63 uint16 qtype,
64 base::DictionaryValue* dict = new base::DictionaryValue(); 64 NetLogCaptureMode /* capture_mode */) {
65 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
65 dict->SetString("hostname", *hostname); 66 dict->SetString("hostname", *hostname);
66 dict->SetInteger("query_type", qtype); 67 dict->SetInteger("query_type", qtype);
67 return dict; 68 return dict.Pass();
68 }; 69 };
69 70
70 // ---------------------------------------------------------------------------- 71 // ----------------------------------------------------------------------------
71 72
72 // A single asynchronous DNS exchange, which consists of sending out a 73 // A single asynchronous DNS exchange, which consists of sending out a
73 // DNS query, waiting for a response, and returning the response that it 74 // DNS query, waiting for a response, and returning the response that it
74 // matches. Logging is done in the socket and in the outer DnsTransaction. 75 // matches. Logging is done in the socket and in the outer DnsTransaction.
75 class DnsAttempt { 76 class DnsAttempt {
76 public: 77 public:
77 explicit DnsAttempt(unsigned server_index) 78 explicit DnsAttempt(unsigned server_index)
(...skipping 13 matching lines...) Expand all
91 92
92 // Returns the net log bound to the source of the socket. 93 // Returns the net log bound to the source of the socket.
93 virtual const BoundNetLog& GetSocketNetLog() const = 0; 94 virtual const BoundNetLog& GetSocketNetLog() const = 0;
94 95
95 // Returns the index of the destination server within DnsConfig::nameservers. 96 // Returns the index of the destination server within DnsConfig::nameservers.
96 unsigned server_index() const { return server_index_; } 97 unsigned server_index() const { return server_index_; }
97 98
98 // Returns a Value representing the received response, along with a reference 99 // Returns a Value representing the received response, along with a reference
99 // to the NetLog source source of the UDP socket used. The request must have 100 // to the NetLog source source of the UDP socket used. The request must have
100 // completed before this is called. 101 // completed before this is called.
101 base::Value* NetLogResponseCallback(NetLogCaptureMode capture_mode) const { 102 scoped_ptr<base::Value> NetLogResponseCallback(
103 NetLogCaptureMode capture_mode) const {
102 DCHECK(GetResponse()->IsValid()); 104 DCHECK(GetResponse()->IsValid());
103 105
104 base::DictionaryValue* dict = new base::DictionaryValue(); 106 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
105 dict->SetInteger("rcode", GetResponse()->rcode()); 107 dict->SetInteger("rcode", GetResponse()->rcode());
106 dict->SetInteger("answer_count", GetResponse()->answer_count()); 108 dict->SetInteger("answer_count", GetResponse()->answer_count());
107 GetSocketNetLog().source().AddToEventParameters(dict); 109 GetSocketNetLog().source().AddToEventParameters(dict.get());
108 return dict; 110 return dict.Pass();
109 } 111 }
110 112
111 void set_result(int result) { 113 void set_result(int result) {
112 result_ = result; 114 result_ = result;
113 } 115 }
114 116
115 // True if current attempt is pending (waiting for server response). 117 // True if current attempt is pending (waiting for server response).
116 bool is_pending() const { 118 bool is_pending() const {
117 return result_ == ERR_IO_PENDING; 119 return result_ == ERR_IO_PENDING;
118 } 120 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 587
586 uint16 GetType() const override { 588 uint16 GetType() const override {
587 DCHECK(CalledOnValidThread()); 589 DCHECK(CalledOnValidThread());
588 return qtype_; 590 return qtype_;
589 } 591 }
590 592
591 void Start() override { 593 void Start() override {
592 DCHECK(!callback_.is_null()); 594 DCHECK(!callback_.is_null());
593 DCHECK(attempts_.empty()); 595 DCHECK(attempts_.empty());
594 net_log_.BeginEvent(NetLog::TYPE_DNS_TRANSACTION, 596 net_log_.BeginEvent(NetLog::TYPE_DNS_TRANSACTION,
595 base::Bind(&NetLogStartCallback, &hostname_, qtype_)); 597 base::Bind(NetLogStartCallback, &hostname_, qtype_));
596 AttemptResult result(PrepareSearch(), NULL); 598 AttemptResult result(PrepareSearch(), NULL);
597 if (result.rv == OK) { 599 if (result.rv == OK) {
598 qnames_initial_size_ = qnames_.size(); 600 qnames_initial_size_ = qnames_.size();
599 if (qtype_ == dns_protocol::kTypeA) 601 if (qtype_ == dns_protocol::kTypeA)
600 UMA_HISTOGRAM_COUNTS("AsyncDNS.SuffixSearchStart", qnames_.size()); 602 UMA_HISTOGRAM_COUNTS("AsyncDNS.SuffixSearchStart", qnames_.size());
601 result = ProcessAttemptResult(StartQuery()); 603 result = ProcessAttemptResult(StartQuery());
602 } 604 }
603 605
604 // Must always return result asynchronously, to avoid reentrancy. 606 // Must always return result asynchronously, to avoid reentrancy.
605 if (result.rv != ERR_IO_PENDING) { 607 if (result.rv != ERR_IO_PENDING) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 } // namespace 990 } // namespace
989 991
990 // static 992 // static
991 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( 993 scoped_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory(
992 DnsSession* session) { 994 DnsSession* session) {
993 return scoped_ptr<DnsTransactionFactory>( 995 return scoped_ptr<DnsTransactionFactory>(
994 new DnsTransactionFactoryImpl(session)); 996 new DnsTransactionFactoryImpl(session));
995 } 997 }
996 998
997 } // namespace net 999 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service.cc ('k') | net/dns/host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698