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

Side by Side Diff: net/dns/dns_session.h

Issue 11567031: [net/dns] Handle TC bit on DNS response in DnsTransaction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test for timeout and fix timeout logic Created 8 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
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 #ifndef NET_DNS_DNS_SESSION_H_ 5 #ifndef NET_DNS_DNS_SESSION_H_
6 #define NET_DNS_DNS_SESSION_H_ 6 #define NET_DNS_DNS_SESSION_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 #include "net/base/rand_callback.h" 14 #include "net/base/rand_callback.h"
15 #include "net/dns/dns_config_service.h" 15 #include "net/dns/dns_config_service.h"
16 #include "net/dns/dns_socket_pool.h" 16 #include "net/dns/dns_socket_pool.h"
17 #include "net/udp/datagram_client_socket.h"
18 17
19 namespace net { 18 namespace net {
20 19
21 class ClientSocketFactory; 20 class ClientSocketFactory;
21 class DatagramClientSocket;
22 class NetLog; 22 class NetLog;
23 class StreamSocket;
23 24
24 // Session parameters and state shared between DNS transactions. 25 // Session parameters and state shared between DNS transactions.
25 // Ref-counted so that DnsClient::Request can keep working in absence of 26 // Ref-counted so that DnsClient::Request can keep working in absence of
26 // DnsClient. A DnsSession must be recreated when DnsConfig changes. 27 // DnsClient. A DnsSession must be recreated when DnsConfig changes.
27 class NET_EXPORT_PRIVATE DnsSession 28 class NET_EXPORT_PRIVATE DnsSession
28 : NON_EXPORTED_BASE(public base::RefCounted<DnsSession>) { 29 : NON_EXPORTED_BASE(public base::RefCounted<DnsSession>) {
29 public: 30 public:
30 typedef base::Callback<int()> RandCallback; 31 typedef base::Callback<int()> RandCallback;
31 32
32 class NET_EXPORT_PRIVATE SocketLease { 33 class NET_EXPORT_PRIVATE SocketLease {
33 public: 34 public:
34 SocketLease(scoped_refptr<DnsSession> session, 35 SocketLease(scoped_refptr<DnsSession> session,
35 unsigned server_index, 36 unsigned server_index,
36 scoped_ptr<DatagramClientSocket> socket); 37 scoped_ptr<DatagramClientSocket> socket);
37 ~SocketLease(); 38 ~SocketLease();
38 39
40 unsigned server_index() const { return server_index_; }
41
39 DatagramClientSocket* socket() { return socket_.get(); } 42 DatagramClientSocket* socket() { return socket_.get(); }
40 43
41 private: 44 private:
42 scoped_refptr<DnsSession> session_; 45 scoped_refptr<DnsSession> session_;
43 unsigned server_index_; 46 unsigned server_index_;
44 scoped_ptr<DatagramClientSocket> socket_; 47 scoped_ptr<DatagramClientSocket> socket_;
45 48
46 DISALLOW_COPY_AND_ASSIGN(SocketLease); 49 DISALLOW_COPY_AND_ASSIGN(SocketLease);
47 }; 50 };
48 51
(...skipping 12 matching lines...) Expand all
61 int NextFirstServerIndex(); 64 int NextFirstServerIndex();
62 65
63 // Return the timeout for the next query. 66 // Return the timeout for the next query.
64 base::TimeDelta NextTimeout(int attempt); 67 base::TimeDelta NextTimeout(int attempt);
65 68
66 // Allocate a socket, already connected to the server address. 69 // Allocate a socket, already connected to the server address.
67 // When the SocketLease is destroyed, the socket will be freed. 70 // When the SocketLease is destroyed, the socket will be freed.
68 scoped_ptr<SocketLease> AllocateSocket(unsigned server_index, 71 scoped_ptr<SocketLease> AllocateSocket(unsigned server_index,
69 const NetLog::Source& source); 72 const NetLog::Source& source);
70 73
74 scoped_ptr<StreamSocket> AllocateTCPSocket(unsigned server_index,
75 const NetLog::Source& source);
76
71 private: 77 private:
72 friend class base::RefCounted<DnsSession>; 78 friend class base::RefCounted<DnsSession>;
73 ~DnsSession(); 79 ~DnsSession();
74 80
75 // Release a socket. 81 // Release a socket.
76 void FreeSocket(unsigned server_index, 82 void FreeSocket(unsigned server_index,
77 scoped_ptr<DatagramClientSocket> socket); 83 scoped_ptr<DatagramClientSocket> socket);
78 84
79 const DnsConfig config_; 85 const DnsConfig config_;
80 scoped_ptr<DnsSocketPool> socket_pool_; 86 scoped_ptr<DnsSocketPool> socket_pool_;
81 RandCallback rand_callback_; 87 RandCallback rand_callback_;
82 NetLog* net_log_; 88 NetLog* net_log_;
83 89
84 // Current index into |config_.nameservers| to begin resolution with. 90 // Current index into |config_.nameservers| to begin resolution with.
85 int server_index_; 91 int server_index_;
86 92
87 // TODO(szym): Add current RTT estimate. 93 // TODO(szym): Add current RTT estimate.
88 // TODO(szym): Add TCP connection pool to support DNS over TCP. 94 // TODO(szym): Add TCP connection pool to support DNS over TCP.
89 95
90 DISALLOW_COPY_AND_ASSIGN(DnsSession); 96 DISALLOW_COPY_AND_ASSIGN(DnsSession);
91 }; 97 };
92 98
93 } // namespace net 99 } // namespace net
94 100
95 #endif // NET_DNS_DNS_SESSION_H_ 101 #endif // NET_DNS_DNS_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698