OLD | NEW |
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_SOCKET_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
6 #define NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
16 #include "net/base/load_states.h" | 16 #include "net/base/load_states.h" |
17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
18 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
19 #include "net/dns/host_resolver.h" | 19 #include "net/dns/host_resolver.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class DictionaryValue; | 22 class DictionaryValue; |
23 } | 23 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ClientSocketHandle* handle) = 0; | 132 ClientSocketHandle* handle) = 0; |
133 | 133 |
134 // Called to release a socket once the socket is no longer needed. If the | 134 // Called to release a socket once the socket is no longer needed. If the |
135 // socket still has an established connection, then it will be added to the | 135 // socket still has an established connection, then it will be added to the |
136 // set of idle sockets to be used to satisfy future RequestSocket calls. | 136 // set of idle sockets to be used to satisfy future RequestSocket calls. |
137 // Otherwise, the StreamSocket is destroyed. |id| is used to differentiate | 137 // Otherwise, the StreamSocket is destroyed. |id| is used to differentiate |
138 // between updated versions of the same pool instance. The pool's id will | 138 // between updated versions of the same pool instance. The pool's id will |
139 // change when it flushes, so it can use this |id| to discard sockets with | 139 // change when it flushes, so it can use this |id| to discard sockets with |
140 // mismatched ids. | 140 // mismatched ids. |
141 virtual void ReleaseSocket(const std::string& group_name, | 141 virtual void ReleaseSocket(const std::string& group_name, |
142 scoped_ptr<StreamSocket> socket, | 142 std::unique_ptr<StreamSocket> socket, |
143 int id) = 0; | 143 int id) = 0; |
144 | 144 |
145 // This flushes all state from the ClientSocketPool. This means that all | 145 // This flushes all state from the ClientSocketPool. This means that all |
146 // idle and connecting sockets are discarded with the given |error|. | 146 // idle and connecting sockets are discarded with the given |error|. |
147 // Active sockets being held by ClientSocketPool clients will be discarded | 147 // Active sockets being held by ClientSocketPool clients will be discarded |
148 // when released back to the pool. | 148 // when released back to the pool. |
149 // Does not flush any pools wrapped by |this|. | 149 // Does not flush any pools wrapped by |this|. |
150 virtual void FlushWithError(int error) = 0; | 150 virtual void FlushWithError(int error) = 0; |
151 | 151 |
152 // Called to close any idle connections held by the connection manager. | 152 // Called to close any idle connections held by the connection manager. |
153 virtual void CloseIdleSockets() = 0; | 153 virtual void CloseIdleSockets() = 0; |
154 | 154 |
155 // The total number of idle sockets in the pool. | 155 // The total number of idle sockets in the pool. |
156 virtual int IdleSocketCount() const = 0; | 156 virtual int IdleSocketCount() const = 0; |
157 | 157 |
158 // The total number of idle sockets in a connection group. | 158 // The total number of idle sockets in a connection group. |
159 virtual int IdleSocketCountInGroup(const std::string& group_name) const = 0; | 159 virtual int IdleSocketCountInGroup(const std::string& group_name) const = 0; |
160 | 160 |
161 // Determine the LoadState of a connecting ClientSocketHandle. | 161 // Determine the LoadState of a connecting ClientSocketHandle. |
162 virtual LoadState GetLoadState(const std::string& group_name, | 162 virtual LoadState GetLoadState(const std::string& group_name, |
163 const ClientSocketHandle* handle) const = 0; | 163 const ClientSocketHandle* handle) const = 0; |
164 | 164 |
165 // Retrieves information on the current state of the pool as a | 165 // Retrieves information on the current state of the pool as a |
166 // DictionaryValue. | 166 // DictionaryValue. |
167 // If |include_nested_pools| is true, the states of any nested | 167 // If |include_nested_pools| is true, the states of any nested |
168 // ClientSocketPools will be included. | 168 // ClientSocketPools will be included. |
169 virtual scoped_ptr<base::DictionaryValue> GetInfoAsValue( | 169 virtual std::unique_ptr<base::DictionaryValue> GetInfoAsValue( |
170 const std::string& name, | 170 const std::string& name, |
171 const std::string& type, | 171 const std::string& type, |
172 bool include_nested_pools) const = 0; | 172 bool include_nested_pools) const = 0; |
173 | 173 |
174 // Returns the maximum amount of time to wait before retrying a connect. | 174 // Returns the maximum amount of time to wait before retrying a connect. |
175 static const int kMaxConnectRetryIntervalMs = 250; | 175 static const int kMaxConnectRetryIntervalMs = 250; |
176 | 176 |
177 static base::TimeDelta unused_idle_socket_timeout(); | 177 static base::TimeDelta unused_idle_socket_timeout(); |
178 static void set_unused_idle_socket_timeout(base::TimeDelta timeout); | 178 static void set_unused_idle_socket_timeout(base::TimeDelta timeout); |
179 | 179 |
(...skipping 17 matching lines...) Expand all Loading... |
197 const std::string& group_name, | 197 const std::string& group_name, |
198 const scoped_refptr<typename PoolType::SocketParams>& params, | 198 const scoped_refptr<typename PoolType::SocketParams>& params, |
199 int num_sockets, | 199 int num_sockets, |
200 const BoundNetLog& net_log) { | 200 const BoundNetLog& net_log) { |
201 pool->RequestSockets(group_name, ¶ms, num_sockets, net_log); | 201 pool->RequestSockets(group_name, ¶ms, num_sockets, net_log); |
202 } | 202 } |
203 | 203 |
204 } // namespace net | 204 } // namespace net |
205 | 205 |
206 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 206 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |