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

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: respond to 2nd review 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
« no previous file with comments | « net/dns/dns_response.cc ('k') | net/dns/dns_session.cc » ('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 #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 // Creates a StreamSocket from the factory for a transaction over TCP. These
75 // sockets are not pooled.
76 scoped_ptr<StreamSocket> CreateTCPSocket(unsigned server_index,
77 const NetLog::Source& source);
78
71 private: 79 private:
72 friend class base::RefCounted<DnsSession>; 80 friend class base::RefCounted<DnsSession>;
73 ~DnsSession(); 81 ~DnsSession();
74 82
75 // Release a socket. 83 // Release a socket.
76 void FreeSocket(unsigned server_index, 84 void FreeSocket(unsigned server_index,
77 scoped_ptr<DatagramClientSocket> socket); 85 scoped_ptr<DatagramClientSocket> socket);
78 86
79 const DnsConfig config_; 87 const DnsConfig config_;
80 scoped_ptr<DnsSocketPool> socket_pool_; 88 scoped_ptr<DnsSocketPool> socket_pool_;
81 RandCallback rand_callback_; 89 RandCallback rand_callback_;
82 NetLog* net_log_; 90 NetLog* net_log_;
83 91
84 // Current index into |config_.nameservers| to begin resolution with. 92 // Current index into |config_.nameservers| to begin resolution with.
85 int server_index_; 93 int server_index_;
86 94
87 // TODO(szym): Add current RTT estimate. 95 // TODO(szym): Add current RTT estimate.
88 // TODO(szym): Add TCP connection pool to support DNS over TCP. 96 // TODO(szym): Add TCP connection pool to support DNS over TCP.
89 97
90 DISALLOW_COPY_AND_ASSIGN(DnsSession); 98 DISALLOW_COPY_AND_ASSIGN(DnsSession);
91 }; 99 };
92 100
93 } // namespace net 101 } // namespace net
94 102
95 #endif // NET_DNS_DNS_SESSION_H_ 103 #endif // NET_DNS_DNS_SESSION_H_
OLDNEW
« no previous file with comments | « net/dns/dns_response.cc ('k') | net/dns/dns_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698