OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
19 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
20 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
21 #include "net/socket/client_socket_pool.h" | 21 #include "net/socket/client_socket_pool.h" |
22 #include "net/socket/client_socket_pool_base.h" | 22 #include "net/socket/client_socket_pool_base.h" |
23 #include "net/socket/transport_client_socket_pool.h" | 23 #include "net/socket/transport_client_socket_pool.h" |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 class ClientSocketFactory; | 27 class ClientSocketFactory; |
28 class ClientSocketPoolHistograms; | |
29 class HostResolver; | 28 class HostResolver; |
30 class NetLog; | 29 class NetLog; |
31 class WebSocketEndpointLockManager; | 30 class WebSocketEndpointLockManager; |
32 class WebSocketTransportConnectSubJob; | 31 class WebSocketTransportConnectSubJob; |
33 | 32 |
34 // WebSocketTransportConnectJob handles the host resolution necessary for socket | 33 // WebSocketTransportConnectJob handles the host resolution necessary for socket |
35 // creation and the TCP connect. WebSocketTransportConnectJob also has fallback | 34 // creation and the TCP connect. WebSocketTransportConnectJob also has fallback |
36 // logic for IPv6 connect() timeouts (which may happen due to networks / routers | 35 // logic for IPv6 connect() timeouts (which may happen due to networks / routers |
37 // with broken IPv6 support). Those timeouts take 20s, so rather than make the | 36 // with broken IPv6 support). Those timeouts take 20s, so rather than make the |
38 // user wait 20s for the timeout to fire, we use a fallback timer | 37 // user wait 20s for the timeout to fire, we use a fallback timer |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 bool had_ipv6_; | 110 bool had_ipv6_; |
112 | 111 |
113 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportConnectJob); | 112 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportConnectJob); |
114 }; | 113 }; |
115 | 114 |
116 class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool | 115 class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool |
117 : public TransportClientSocketPool { | 116 : public TransportClientSocketPool { |
118 public: | 117 public: |
119 WebSocketTransportClientSocketPool(int max_sockets, | 118 WebSocketTransportClientSocketPool(int max_sockets, |
120 int max_sockets_per_group, | 119 int max_sockets_per_group, |
121 ClientSocketPoolHistograms* histograms, | |
122 HostResolver* host_resolver, | 120 HostResolver* host_resolver, |
123 ClientSocketFactory* client_socket_factory, | 121 ClientSocketFactory* client_socket_factory, |
124 NetLog* net_log); | 122 NetLog* net_log); |
125 | 123 |
126 ~WebSocketTransportClientSocketPool() override; | 124 ~WebSocketTransportClientSocketPool() override; |
127 | 125 |
128 // Allow another connection to be started to the IPEndPoint that this |handle| | 126 // Allow another connection to be started to the IPEndPoint that this |handle| |
129 // is connected to. Used when the WebSocket handshake completes successfully. | 127 // is connected to. Used when the WebSocket handshake completes successfully. |
130 // This only works if the socket is connected, however the caller does not | 128 // This only works if the socket is connected, however the caller does not |
131 // need to explicitly check for this. Instead, ensure that dead sockets are | 129 // need to explicitly check for this. Instead, ensure that dead sockets are |
(...skipping 20 matching lines...) Expand all Loading... |
152 void CloseIdleSockets() override; | 150 void CloseIdleSockets() override; |
153 int IdleSocketCount() const override; | 151 int IdleSocketCount() const override; |
154 int IdleSocketCountInGroup(const std::string& group_name) const override; | 152 int IdleSocketCountInGroup(const std::string& group_name) const override; |
155 LoadState GetLoadState(const std::string& group_name, | 153 LoadState GetLoadState(const std::string& group_name, |
156 const ClientSocketHandle* handle) const override; | 154 const ClientSocketHandle* handle) const override; |
157 base::DictionaryValue* GetInfoAsValue( | 155 base::DictionaryValue* GetInfoAsValue( |
158 const std::string& name, | 156 const std::string& name, |
159 const std::string& type, | 157 const std::string& type, |
160 bool include_nested_pools) const override; | 158 bool include_nested_pools) const override; |
161 base::TimeDelta ConnectionTimeout() const override; | 159 base::TimeDelta ConnectionTimeout() const override; |
162 ClientSocketPoolHistograms* histograms() const override; | |
163 | 160 |
164 // HigherLayeredPool implementation. | 161 // HigherLayeredPool implementation. |
165 bool IsStalled() const override; | 162 bool IsStalled() const override; |
166 | 163 |
167 private: | 164 private: |
168 class ConnectJobDelegate : public ConnectJob::Delegate { | 165 class ConnectJobDelegate : public ConnectJob::Delegate { |
169 public: | 166 public: |
170 explicit ConnectJobDelegate(WebSocketTransportClientSocketPool* owner); | 167 explicit ConnectJobDelegate(WebSocketTransportClientSocketPool* owner); |
171 ~ConnectJobDelegate() override; | 168 ~ConnectJobDelegate() override; |
172 | 169 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 const WebSocketTransportConnectJob* LookupConnectJob( | 218 const WebSocketTransportConnectJob* LookupConnectJob( |
222 const ClientSocketHandle* handle) const; | 219 const ClientSocketHandle* handle) const; |
223 void ActivateStalledRequest(); | 220 void ActivateStalledRequest(); |
224 bool DeleteStalledRequest(ClientSocketHandle* handle); | 221 bool DeleteStalledRequest(ClientSocketHandle* handle); |
225 | 222 |
226 ConnectJobDelegate connect_job_delegate_; | 223 ConnectJobDelegate connect_job_delegate_; |
227 std::set<const ClientSocketHandle*> pending_callbacks_; | 224 std::set<const ClientSocketHandle*> pending_callbacks_; |
228 PendingConnectsMap pending_connects_; | 225 PendingConnectsMap pending_connects_; |
229 StalledRequestQueue stalled_request_queue_; | 226 StalledRequestQueue stalled_request_queue_; |
230 StalledRequestMap stalled_request_map_; | 227 StalledRequestMap stalled_request_map_; |
231 ClientSocketPoolHistograms* const histograms_; | |
232 NetLog* const pool_net_log_; | 228 NetLog* const pool_net_log_; |
233 ClientSocketFactory* const client_socket_factory_; | 229 ClientSocketFactory* const client_socket_factory_; |
234 HostResolver* const host_resolver_; | 230 HostResolver* const host_resolver_; |
235 const int max_sockets_; | 231 const int max_sockets_; |
236 int handed_out_socket_count_; | 232 int handed_out_socket_count_; |
237 bool flushing_; | 233 bool flushing_; |
238 | 234 |
239 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; | 235 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; |
240 | 236 |
241 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); | 237 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); |
242 }; | 238 }; |
243 | 239 |
244 } // namespace net | 240 } // namespace net |
245 | 241 |
246 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 242 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |