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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 2 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
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 virtual int Start(const CompletionCallback& callback) = 0; 90 virtual int Start(const CompletionCallback& callback) = 0;
91 91
92 // Returns the query of this attempt. 92 // Returns the query of this attempt.
93 virtual const DnsQuery* GetQuery() const = 0; 93 virtual const DnsQuery* GetQuery() const = 0;
94 94
95 // Returns the response or NULL if has not received a matching response from 95 // Returns the response or NULL if has not received a matching response from
96 // the server. 96 // the server.
97 virtual const DnsResponse* GetResponse() const = 0; 97 virtual const DnsResponse* GetResponse() const = 0;
98 98
99 // Returns the net log bound to the source of the socket. 99 // Returns the net log bound to the source of the socket.
100 virtual const BoundNetLog& GetSocketNetLog() const = 0; 100 virtual const NetLogWithSource& GetSocketNetLog() const = 0;
101 101
102 // Returns the index of the destination server within DnsConfig::nameservers. 102 // Returns the index of the destination server within DnsConfig::nameservers.
103 unsigned server_index() const { return server_index_; } 103 unsigned server_index() const { return server_index_; }
104 104
105 // Returns a Value representing the received response, along with a reference 105 // Returns a Value representing the received response, along with a reference
106 // to the NetLog source source of the UDP socket used. The request must have 106 // to the NetLog source source of the UDP socket used. The request must have
107 // completed before this is called. 107 // completed before this is called.
108 std::unique_ptr<base::Value> NetLogResponseCallback( 108 std::unique_ptr<base::Value> NetLogResponseCallback(
109 NetLogCaptureMode capture_mode) const { 109 NetLogCaptureMode capture_mode) const {
110 DCHECK(GetResponse()->IsValid()); 110 DCHECK(GetResponse()->IsValid());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return DoLoop(OK); 158 return DoLoop(OK);
159 } 159 }
160 160
161 const DnsQuery* GetQuery() const override { return query_.get(); } 161 const DnsQuery* GetQuery() const override { return query_.get(); }
162 162
163 const DnsResponse* GetResponse() const override { 163 const DnsResponse* GetResponse() const override {
164 const DnsResponse* resp = response_.get(); 164 const DnsResponse* resp = response_.get();
165 return (resp != NULL && resp->IsValid()) ? resp : NULL; 165 return (resp != NULL && resp->IsValid()) ? resp : NULL;
166 } 166 }
167 167
168 const BoundNetLog& GetSocketNetLog() const override { 168 const NetLogWithSource& GetSocketNetLog() const override {
169 return socket_lease_->socket()->NetLog(); 169 return socket_lease_->socket()->NetLog();
170 } 170 }
171 171
172 private: 172 private:
173 enum State { 173 enum State {
174 STATE_SEND_QUERY, 174 STATE_SEND_QUERY,
175 STATE_SEND_QUERY_COMPLETE, 175 STATE_SEND_QUERY_COMPLETE,
176 STATE_READ_RESPONSE, 176 STATE_READ_RESPONSE,
177 STATE_READ_RESPONSE_COMPLETE, 177 STATE_READ_RESPONSE_COMPLETE,
178 STATE_NONE, 178 STATE_NONE,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 return DoLoop(rv); 327 return DoLoop(rv);
328 } 328 }
329 329
330 const DnsQuery* GetQuery() const override { return query_.get(); } 330 const DnsQuery* GetQuery() const override { return query_.get(); }
331 331
332 const DnsResponse* GetResponse() const override { 332 const DnsResponse* GetResponse() const override {
333 const DnsResponse* resp = response_.get(); 333 const DnsResponse* resp = response_.get();
334 return (resp != NULL && resp->IsValid()) ? resp : NULL; 334 return (resp != NULL && resp->IsValid()) ? resp : NULL;
335 } 335 }
336 336
337 const BoundNetLog& GetSocketNetLog() const override { 337 const NetLogWithSource& GetSocketNetLog() const override {
338 return socket_->NetLog(); 338 return socket_->NetLog();
339 } 339 }
340 340
341 private: 341 private:
342 enum State { 342 enum State {
343 STATE_CONNECT_COMPLETE, 343 STATE_CONNECT_COMPLETE,
344 STATE_SEND_LENGTH, 344 STATE_SEND_LENGTH,
345 STATE_SEND_QUERY, 345 STATE_SEND_QUERY,
346 STATE_READ_LENGTH, 346 STATE_READ_LENGTH,
347 STATE_READ_LENGTH_COMPLETE, 347 STATE_READ_LENGTH_COMPLETE,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // DnsSession::NextFirstServerIndex, and the order is round-robin afterwards. 556 // DnsSession::NextFirstServerIndex, and the order is round-robin afterwards.
557 // Each server is attempted DnsConfig::attempts times. 557 // Each server is attempted DnsConfig::attempts times.
558 class DnsTransactionImpl : public DnsTransaction, 558 class DnsTransactionImpl : public DnsTransaction,
559 public base::NonThreadSafe, 559 public base::NonThreadSafe,
560 public base::SupportsWeakPtr<DnsTransactionImpl> { 560 public base::SupportsWeakPtr<DnsTransactionImpl> {
561 public: 561 public:
562 DnsTransactionImpl(DnsSession* session, 562 DnsTransactionImpl(DnsSession* session,
563 const std::string& hostname, 563 const std::string& hostname,
564 uint16_t qtype, 564 uint16_t qtype,
565 const DnsTransactionFactory::CallbackType& callback, 565 const DnsTransactionFactory::CallbackType& callback,
566 const BoundNetLog& net_log) 566 const NetLogWithSource& net_log)
567 : session_(session), 567 : session_(session),
568 hostname_(hostname), 568 hostname_(hostname),
569 qtype_(qtype), 569 qtype_(qtype),
570 callback_(callback), 570 callback_(callback),
571 net_log_(net_log), 571 net_log_(net_log),
572 qnames_initial_size_(0), 572 qnames_initial_size_(0),
573 attempts_count_(0), 573 attempts_count_(0),
574 had_tcp_attempt_(false), 574 had_tcp_attempt_(false),
575 first_server_index_(0) { 575 first_server_index_(0) {
576 DCHECK(session_.get()); 576 DCHECK(session_.get());
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 if (result.rv != ERR_IO_PENDING) 943 if (result.rv != ERR_IO_PENDING)
944 DoCallback(result); 944 DoCallback(result);
945 } 945 }
946 946
947 scoped_refptr<DnsSession> session_; 947 scoped_refptr<DnsSession> session_;
948 std::string hostname_; 948 std::string hostname_;
949 uint16_t qtype_; 949 uint16_t qtype_;
950 // Cleared in DoCallback. 950 // Cleared in DoCallback.
951 DnsTransactionFactory::CallbackType callback_; 951 DnsTransactionFactory::CallbackType callback_;
952 952
953 BoundNetLog net_log_; 953 NetLogWithSource net_log_;
954 954
955 // Search list of fully-qualified DNS names to query next (in DNS format). 955 // Search list of fully-qualified DNS names to query next (in DNS format).
956 std::deque<std::string> qnames_; 956 std::deque<std::string> qnames_;
957 size_t qnames_initial_size_; 957 size_t qnames_initial_size_;
958 958
959 // List of attempts for the current name. 959 // List of attempts for the current name.
960 std::vector<std::unique_ptr<DnsAttempt>> attempts_; 960 std::vector<std::unique_ptr<DnsAttempt>> attempts_;
961 // Count of attempts, not reset when |attempts_| vector is cleared. 961 // Count of attempts, not reset when |attempts_| vector is cleared.
962 int attempts_count_; 962 int attempts_count_;
963 bool had_tcp_attempt_; 963 bool had_tcp_attempt_;
(...skipping 13 matching lines...) Expand all
977 class DnsTransactionFactoryImpl : public DnsTransactionFactory { 977 class DnsTransactionFactoryImpl : public DnsTransactionFactory {
978 public: 978 public:
979 explicit DnsTransactionFactoryImpl(DnsSession* session) { 979 explicit DnsTransactionFactoryImpl(DnsSession* session) {
980 session_ = session; 980 session_ = session;
981 } 981 }
982 982
983 std::unique_ptr<DnsTransaction> CreateTransaction( 983 std::unique_ptr<DnsTransaction> CreateTransaction(
984 const std::string& hostname, 984 const std::string& hostname,
985 uint16_t qtype, 985 uint16_t qtype,
986 const CallbackType& callback, 986 const CallbackType& callback,
987 const BoundNetLog& net_log) override { 987 const NetLogWithSource& net_log) override {
988 return std::unique_ptr<DnsTransaction>(new DnsTransactionImpl( 988 return std::unique_ptr<DnsTransaction>(new DnsTransactionImpl(
989 session_.get(), hostname, qtype, callback, net_log)); 989 session_.get(), hostname, qtype, callback, net_log));
990 } 990 }
991 991
992 private: 992 private:
993 scoped_refptr<DnsSession> session_; 993 scoped_refptr<DnsSession> session_;
994 }; 994 };
995 995
996 } // namespace 996 } // namespace
997 997
998 // static 998 // static
999 std::unique_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory( 999 std::unique_ptr<DnsTransactionFactory> DnsTransactionFactory::CreateFactory(
1000 DnsSession* session) { 1000 DnsSession* session) {
1001 return std::unique_ptr<DnsTransactionFactory>( 1001 return std::unique_ptr<DnsTransactionFactory>(
1002 new DnsTransactionFactoryImpl(session)); 1002 new DnsTransactionFactoryImpl(session));
1003 } 1003 }
1004 1004
1005 } // namespace net 1005 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698