OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_BASE_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_BASE_CLIENT_SOCKET_POOL_H_ |
6 #define NET_BASE_CLIENT_SOCKET_POOL_H_ | 6 #define NET_BASE_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/base/load_states.h" | 14 #include "net/base/load_states.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 class ClientSocket; | 18 class ClientSocket; |
19 class ClientSocketHandle; | 19 class ClientSocketHandle; |
| 20 class HostResolver; |
20 | 21 |
21 // A ClientSocketPool is used to restrict the number of sockets open at a time. | 22 // A ClientSocketPool is used to restrict the number of sockets open at a time. |
22 // It also maintains a list of idle persistent sockets. | 23 // It also maintains a list of idle persistent sockets. |
23 // | 24 // |
24 class ClientSocketPool : public base::RefCounted<ClientSocketPool> { | 25 class ClientSocketPool : public base::RefCounted<ClientSocketPool> { |
25 public: | 26 public: |
26 // Requests a connected socket for a group_name. | 27 // Requests a connected socket for a group_name. |
27 // | 28 // |
28 // There are four possible results from calling this function: | 29 // There are four possible results from calling this function: |
29 // 1) RequestSocket returns OK and initializes |handle| with a reused socket. | 30 // 1) RequestSocket returns OK and initializes |handle| with a reused socket. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Called to release a socket once the socket is no longer needed. If the | 63 // Called to release a socket once the socket is no longer needed. If the |
63 // socket still has an established connection, then it will be added to the | 64 // socket still has an established connection, then it will be added to the |
64 // set of idle sockets to be used to satisfy future RequestSocket calls. | 65 // set of idle sockets to be used to satisfy future RequestSocket calls. |
65 // Otherwise, the ClientSocket is destroyed. | 66 // Otherwise, the ClientSocket is destroyed. |
66 virtual void ReleaseSocket(const std::string& group_name, | 67 virtual void ReleaseSocket(const std::string& group_name, |
67 ClientSocket* socket) = 0; | 68 ClientSocket* socket) = 0; |
68 | 69 |
69 // Called to close any idle connections held by the connection manager. | 70 // Called to close any idle connections held by the connection manager. |
70 virtual void CloseIdleSockets() = 0; | 71 virtual void CloseIdleSockets() = 0; |
71 | 72 |
| 73 // Returns the HostResolver that will be used for host lookups. |
| 74 virtual HostResolver* GetHostResolver() const = 0; |
| 75 |
72 // The total number of idle sockets in the pool. | 76 // The total number of idle sockets in the pool. |
73 virtual int idle_socket_count() const = 0; | 77 virtual int idle_socket_count() const = 0; |
74 | 78 |
75 // The total number of idle sockets in a connection group. | 79 // The total number of idle sockets in a connection group. |
76 virtual int IdleSocketCountInGroup(const std::string& group_name) const = 0; | 80 virtual int IdleSocketCountInGroup(const std::string& group_name) const = 0; |
77 | 81 |
78 // Determine the LoadState of a connecting ClientSocketHandle. | 82 // Determine the LoadState of a connecting ClientSocketHandle. |
79 virtual LoadState GetLoadState(const std::string& group_name, | 83 virtual LoadState GetLoadState(const std::string& group_name, |
80 const ClientSocketHandle* handle) const = 0; | 84 const ClientSocketHandle* handle) const = 0; |
81 | 85 |
82 protected: | 86 protected: |
83 ClientSocketPool() {} | 87 ClientSocketPool() {} |
84 virtual ~ClientSocketPool() {} | 88 virtual ~ClientSocketPool() {} |
85 | 89 |
86 private: | 90 private: |
87 friend class base::RefCounted<ClientSocketPool>; | 91 friend class base::RefCounted<ClientSocketPool>; |
88 | 92 |
89 DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); | 93 DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); |
90 }; | 94 }; |
91 | 95 |
92 } // namespace net | 96 } // namespace net |
93 | 97 |
94 #endif // NET_BASE_CLIENT_SOCKET_POOL_H_ | 98 #endif // NET_BASE_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |