| 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 <memory> |
| 10 #include <set> | 11 #include <set> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.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/log/net_log.h" | 20 #include "net/log/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 { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // and ERR_IO_PENDING if it cannot immediately service the request. | 91 // and ERR_IO_PENDING if it cannot immediately service the request. |
| 92 // Otherwise, it returns a net error code. | 92 // Otherwise, it returns a net error code. |
| 93 int ConnectInternal() override; | 93 int ConnectInternal() override; |
| 94 | 94 |
| 95 TransportConnectJobHelper helper_; | 95 TransportConnectJobHelper helper_; |
| 96 | 96 |
| 97 // The addresses are divided into IPv4 and IPv6, which are performed partially | 97 // The addresses are divided into IPv4 and IPv6, which are performed partially |
| 98 // in parallel. If the list of IPv6 addresses is non-empty, then the IPv6 jobs | 98 // in parallel. If the list of IPv6 addresses is non-empty, then the IPv6 jobs |
| 99 // go first, followed after |kIPv6FallbackTimerInMs| by the IPv4 | 99 // go first, followed after |kIPv6FallbackTimerInMs| by the IPv4 |
| 100 // addresses. First sub-job to establish a connection wins. | 100 // addresses. First sub-job to establish a connection wins. |
| 101 scoped_ptr<WebSocketTransportConnectSubJob> ipv4_job_; | 101 std::unique_ptr<WebSocketTransportConnectSubJob> ipv4_job_; |
| 102 scoped_ptr<WebSocketTransportConnectSubJob> ipv6_job_; | 102 std::unique_ptr<WebSocketTransportConnectSubJob> ipv6_job_; |
| 103 | 103 |
| 104 base::OneShotTimer fallback_timer_; | 104 base::OneShotTimer fallback_timer_; |
| 105 TransportConnectJobHelper::ConnectionLatencyHistogram race_result_; | 105 TransportConnectJobHelper::ConnectionLatencyHistogram race_result_; |
| 106 ClientSocketHandle* const handle_; | 106 ClientSocketHandle* const handle_; |
| 107 CompletionCallback callback_; | 107 CompletionCallback callback_; |
| 108 BoundNetLog request_net_log_; | 108 BoundNetLog request_net_log_; |
| 109 | 109 |
| 110 bool had_ipv4_; | 110 bool had_ipv4_; |
| 111 bool had_ipv6_; | 111 bool had_ipv6_; |
| 112 | 112 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 139 ClientSocketHandle* handle, | 139 ClientSocketHandle* handle, |
| 140 const CompletionCallback& callback, | 140 const CompletionCallback& callback, |
| 141 const BoundNetLog& net_log) override; | 141 const BoundNetLog& net_log) override; |
| 142 void RequestSockets(const std::string& group_name, | 142 void RequestSockets(const std::string& group_name, |
| 143 const void* params, | 143 const void* params, |
| 144 int num_sockets, | 144 int num_sockets, |
| 145 const BoundNetLog& net_log) override; | 145 const BoundNetLog& net_log) override; |
| 146 void CancelRequest(const std::string& group_name, | 146 void CancelRequest(const std::string& group_name, |
| 147 ClientSocketHandle* handle) override; | 147 ClientSocketHandle* handle) override; |
| 148 void ReleaseSocket(const std::string& group_name, | 148 void ReleaseSocket(const std::string& group_name, |
| 149 scoped_ptr<StreamSocket> socket, | 149 std::unique_ptr<StreamSocket> socket, |
| 150 int id) override; | 150 int id) override; |
| 151 void FlushWithError(int error) override; | 151 void FlushWithError(int error) override; |
| 152 void CloseIdleSockets() override; | 152 void CloseIdleSockets() override; |
| 153 int IdleSocketCount() const override; | 153 int IdleSocketCount() const override; |
| 154 int IdleSocketCountInGroup(const std::string& group_name) const override; | 154 int IdleSocketCountInGroup(const std::string& group_name) const override; |
| 155 LoadState GetLoadState(const std::string& group_name, | 155 LoadState GetLoadState(const std::string& group_name, |
| 156 const ClientSocketHandle* handle) const override; | 156 const ClientSocketHandle* handle) const override; |
| 157 scoped_ptr<base::DictionaryValue> GetInfoAsValue( | 157 std::unique_ptr<base::DictionaryValue> GetInfoAsValue( |
| 158 const std::string& name, | 158 const std::string& name, |
| 159 const std::string& type, | 159 const std::string& type, |
| 160 bool include_nested_pools) const override; | 160 bool include_nested_pools) const override; |
| 161 base::TimeDelta ConnectionTimeout() const override; | 161 base::TimeDelta ConnectionTimeout() const override; |
| 162 | 162 |
| 163 // HigherLayeredPool implementation. | 163 // HigherLayeredPool implementation. |
| 164 bool IsStalled() const override; | 164 bool IsStalled() const override; |
| 165 | 165 |
| 166 private: | 166 private: |
| 167 class ConnectJobDelegate : public ConnectJob::Delegate { | 167 class ConnectJobDelegate : public ConnectJob::Delegate { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 StalledRequestMap; | 204 StalledRequestMap; |
| 205 | 205 |
| 206 void OnConnectJobComplete(int result, WebSocketTransportConnectJob* job); | 206 void OnConnectJobComplete(int result, WebSocketTransportConnectJob* job); |
| 207 void InvokeUserCallbackLater(ClientSocketHandle* handle, | 207 void InvokeUserCallbackLater(ClientSocketHandle* handle, |
| 208 const CompletionCallback& callback, | 208 const CompletionCallback& callback, |
| 209 int rv); | 209 int rv); |
| 210 void InvokeUserCallback(ClientSocketHandle* handle, | 210 void InvokeUserCallback(ClientSocketHandle* handle, |
| 211 const CompletionCallback& callback, | 211 const CompletionCallback& callback, |
| 212 int rv); | 212 int rv); |
| 213 bool ReachedMaxSocketsLimit() const; | 213 bool ReachedMaxSocketsLimit() const; |
| 214 void HandOutSocket(scoped_ptr<StreamSocket> socket, | 214 void HandOutSocket(std::unique_ptr<StreamSocket> socket, |
| 215 const LoadTimingInfo::ConnectTiming& connect_timing, | 215 const LoadTimingInfo::ConnectTiming& connect_timing, |
| 216 ClientSocketHandle* handle, | 216 ClientSocketHandle* handle, |
| 217 const BoundNetLog& net_log); | 217 const BoundNetLog& net_log); |
| 218 void AddJob(ClientSocketHandle* handle, | 218 void AddJob(ClientSocketHandle* handle, |
| 219 scoped_ptr<WebSocketTransportConnectJob> connect_job); | 219 std::unique_ptr<WebSocketTransportConnectJob> connect_job); |
| 220 bool DeleteJob(ClientSocketHandle* handle); | 220 bool DeleteJob(ClientSocketHandle* handle); |
| 221 const WebSocketTransportConnectJob* LookupConnectJob( | 221 const WebSocketTransportConnectJob* LookupConnectJob( |
| 222 const ClientSocketHandle* handle) const; | 222 const ClientSocketHandle* handle) const; |
| 223 void ActivateStalledRequest(); | 223 void ActivateStalledRequest(); |
| 224 bool DeleteStalledRequest(ClientSocketHandle* handle); | 224 bool DeleteStalledRequest(ClientSocketHandle* handle); |
| 225 | 225 |
| 226 ConnectJobDelegate connect_job_delegate_; | 226 ConnectJobDelegate connect_job_delegate_; |
| 227 std::set<const ClientSocketHandle*> pending_callbacks_; | 227 std::set<const ClientSocketHandle*> pending_callbacks_; |
| 228 PendingConnectsMap pending_connects_; | 228 PendingConnectsMap pending_connects_; |
| 229 StalledRequestQueue stalled_request_queue_; | 229 StalledRequestQueue stalled_request_queue_; |
| 230 StalledRequestMap stalled_request_map_; | 230 StalledRequestMap stalled_request_map_; |
| 231 NetLog* const pool_net_log_; | 231 NetLog* const pool_net_log_; |
| 232 ClientSocketFactory* const client_socket_factory_; | 232 ClientSocketFactory* const client_socket_factory_; |
| 233 HostResolver* const host_resolver_; | 233 HostResolver* const host_resolver_; |
| 234 const int max_sockets_; | 234 const int max_sockets_; |
| 235 int handed_out_socket_count_; | 235 int handed_out_socket_count_; |
| 236 bool flushing_; | 236 bool flushing_; |
| 237 | 237 |
| 238 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; | 238 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; |
| 239 | 239 |
| 240 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); | 240 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 } // namespace net | 243 } // namespace net |
| 244 | 244 |
| 245 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 245 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |