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

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

Issue 11573012: patch from issue 10878090 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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_session_unittest.cc ('k') | net/dns/dns_socket_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_DNS_DNS_SOCKET_POOL_H_
6 #define NET_DNS_DNS_SOCKET_POOL_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_export.h"
12
13 namespace net {
14
15 class ClientSocketFactory;
16 class DatagramClientSocket;
17 class IPEndPoint;
18 class NetLog;
19
20 // A DnsSocketPool is an abstraction layer around a ClientSocketFactory that
21 // allows preallocation, reuse, or other strategies to manage sockets connected
22 // to DNS servers.
23 class NET_EXPORT_PRIVATE DnsSocketPool {
24 public:
25 virtual ~DnsSocketPool() { }
26
27 // Creates a DnsSocketPool that implements the default strategy for managing
28 // sockets. (This varies by platform; see DnsSocketPoolImpl in
29 // dns_socket_pool.cc for details.)
30 static scoped_ptr<DnsSocketPool> CreateDefault(
31 ClientSocketFactory* factory);
32
33 // Creates a DnsSocketPool that implements a "null" strategy -- no sockets are
34 // preallocated, allocation requests are satisfied by calling the factory
35 // directly, and returned sockets are deleted immediately.
36 static scoped_ptr<DnsSocketPool> CreateNull(
37 ClientSocketFactory* factory);
38
39 // Initializes the DnsSocketPool. |nameservers| is the list of nameservers
40 // for which the DnsSocketPool will manage sockets; |net_log| is the NetLog
41 // used when constructing sockets with the factory.
42 //
43 // Initialize may not be called more than once, and must be called before
44 // calling AllocateSocket or FreeSocket.
45 virtual void Initialize(
46 const std::vector<IPEndPoint>* nameservers,
47 NetLog* net_log) = 0;
48
49 // Allocates a socket that is already connected to the nameserver referenced
50 // by |server_index|. May return a scoped_ptr to NULL if no sockets are
51 // available to reuse and the factory fails to produce a socket (or produces
52 // one on which Connect fails).
53 virtual scoped_ptr<DatagramClientSocket> AllocateSocket(
54 unsigned server_index) = 0;
55
56 // Frees a socket allocated by AllocateSocket. |server_index| must be the
57 // same index passed to AllocateSocket.
58 virtual void FreeSocket(
59 unsigned server_index,
60 scoped_ptr<DatagramClientSocket> socket) = 0;
61
62 protected:
63 DnsSocketPool(ClientSocketFactory* socket_factory);
64
65 void InitializeInternal(
66 const std::vector<IPEndPoint>* nameservers,
67 NetLog* net_log);
68
69 scoped_ptr<DatagramClientSocket> CreateConnectedSocket(
70 unsigned server_index);
71
72 private:
73 ClientSocketFactory* socket_factory_;
74 NetLog* net_log_;
75 const std::vector<IPEndPoint>* nameservers_;
76 bool initialized_;
77
78 DISALLOW_COPY_AND_ASSIGN(DnsSocketPool);
79 };
80
81 } // namespace net
82
83 #endif // NET_DNS_DNS_SOCKET_POOL_H_
OLDNEW
« no previous file with comments | « net/dns/dns_session_unittest.cc ('k') | net/dns/dns_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698