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_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
6 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
16 #include "net/dns/host_resolver.h" | 16 #include "net/dns/host_resolver.h" |
17 #include "net/dns/single_request_host_resolver.h" | 17 #include "net/dns/single_request_host_resolver.h" |
18 #include "net/socket/client_socket_pool.h" | 18 #include "net/socket/client_socket_pool.h" |
19 #include "net/socket/client_socket_pool_base.h" | 19 #include "net/socket/client_socket_pool_base.h" |
20 #include "net/socket/client_socket_pool_histograms.h" | 20 #include "net/socket/client_socket_pool_histograms.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 class ClientSocketFactory; | 24 class ClientSocketFactory; |
25 | 25 |
26 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)> | 26 typedef base::Callback<int(const AddressList&, const BoundNetLog& net_log)> |
27 OnHostResolutionCallback; | 27 OnHostResolutionCallback; |
28 | 28 |
29 class NET_EXPORT_PRIVATE TransportSocketParams | 29 class NET_EXPORT_PRIVATE TransportSocketParams |
30 : public base::RefCounted<TransportSocketParams> { | 30 : public base::RefCounted<TransportSocketParams> { |
31 public: | 31 public: |
32 // |host_resolution_callback| will be invoked after the the hostname is | 32 // |host_resolution_callback| will be invoked after the the hostname is |
33 // resolved. If |host_resolution_callback| does not return OK, then the | 33 // resolved. If |host_resolution_callback| does not return OK, then the |
34 // connection will be aborted with that value. | 34 // connection will be aborted with that value. |
35 TransportSocketParams( | 35 TransportSocketParams( |
36 const HostPortPair& host_port_pair, | 36 const HostPortPair& host_port_pair, |
37 bool disable_resolver_cache, | 37 bool disable_resolver_cache, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // Track the interval between this connect and previous connect. | 134 // Track the interval between this connect and previous connect. |
135 ConnectInterval interval_between_connects_; | 135 ConnectInterval interval_between_connects_; |
136 | 136 |
137 DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); | 137 DISALLOW_COPY_AND_ASSIGN(TransportConnectJob); |
138 }; | 138 }; |
139 | 139 |
140 class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { | 140 class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool { |
141 public: | 141 public: |
142 typedef TransportSocketParams SocketParams; | 142 typedef TransportSocketParams SocketParams; |
143 | 143 |
144 TransportClientSocketPool( | 144 TransportClientSocketPool(int max_sockets, |
145 int max_sockets, | 145 int max_sockets_per_group, |
146 int max_sockets_per_group, | 146 ClientSocketPoolHistograms* histograms, |
147 ClientSocketPoolHistograms* histograms, | 147 HostResolver* host_resolver, |
148 HostResolver* host_resolver, | 148 ClientSocketFactory* client_socket_factory, |
149 ClientSocketFactory* client_socket_factory, | 149 NetLog* net_log); |
150 NetLog* net_log); | |
151 | 150 |
152 virtual ~TransportClientSocketPool(); | 151 virtual ~TransportClientSocketPool(); |
153 | 152 |
154 // ClientSocketPool implementation. | 153 // ClientSocketPool implementation. |
155 virtual int RequestSocket(const std::string& group_name, | 154 virtual int RequestSocket(const std::string& group_name, |
156 const void* resolve_info, | 155 const void* resolve_info, |
157 RequestPriority priority, | 156 RequestPriority priority, |
158 ClientSocketHandle* handle, | 157 ClientSocketHandle* handle, |
159 const CompletionCallback& callback, | 158 const CompletionCallback& callback, |
160 const BoundNetLog& net_log) OVERRIDE; | 159 const BoundNetLog& net_log) OVERRIDE; |
(...skipping 22 matching lines...) Expand all Loading... |
183 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; | 182 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; |
184 | 183 |
185 // HigherLayeredPool implementation. | 184 // HigherLayeredPool implementation. |
186 virtual bool IsStalled() const OVERRIDE; | 185 virtual bool IsStalled() const OVERRIDE; |
187 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 186 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; |
188 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 187 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; |
189 | 188 |
190 private: | 189 private: |
191 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; | 190 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; |
192 | 191 |
193 class TransportConnectJobFactory | 192 class TransportConnectJobFactory : public PoolBase::ConnectJobFactory { |
194 : public PoolBase::ConnectJobFactory { | |
195 public: | 193 public: |
196 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, | 194 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, |
197 HostResolver* host_resolver, | 195 HostResolver* host_resolver, |
198 NetLog* net_log) | 196 NetLog* net_log) |
199 : client_socket_factory_(client_socket_factory), | 197 : client_socket_factory_(client_socket_factory), |
200 host_resolver_(host_resolver), | 198 host_resolver_(host_resolver), |
201 net_log_(net_log) {} | 199 net_log_(net_log) {} |
202 | 200 |
203 virtual ~TransportConnectJobFactory() {} | 201 virtual ~TransportConnectJobFactory() {} |
204 | 202 |
205 // ClientSocketPoolBase::ConnectJobFactory methods. | 203 // ClientSocketPoolBase::ConnectJobFactory methods. |
206 | 204 |
207 virtual scoped_ptr<ConnectJob> NewConnectJob( | 205 virtual scoped_ptr<ConnectJob> NewConnectJob( |
208 const std::string& group_name, | 206 const std::string& group_name, |
(...skipping 11 matching lines...) Expand all Loading... |
220 }; | 218 }; |
221 | 219 |
222 PoolBase base_; | 220 PoolBase base_; |
223 | 221 |
224 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); | 222 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); |
225 }; | 223 }; |
226 | 224 |
227 } // namespace net | 225 } // namespace net |
228 | 226 |
229 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 227 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |