| 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> |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Unlike normal socket pools, the WebSocketTransportClientPool uses | 58 // Unlike normal socket pools, the WebSocketTransportClientPool uses |
| 59 // early-binding of sockets. | 59 // early-binding of sockets. |
| 60 ClientSocketHandle* handle() const { return handle_; } | 60 ClientSocketHandle* handle() const { return handle_; } |
| 61 | 61 |
| 62 // Stash the callback from RequestSocket() here for convenience. | 62 // Stash the callback from RequestSocket() here for convenience. |
| 63 const CompletionCallback& callback() const { return callback_; } | 63 const CompletionCallback& callback() const { return callback_; } |
| 64 | 64 |
| 65 const BoundNetLog& request_net_log() const { return request_net_log_; } | 65 const BoundNetLog& request_net_log() const { return request_net_log_; } |
| 66 | 66 |
| 67 // ConnectJob methods. | 67 // ConnectJob methods. |
| 68 virtual LoadState GetLoadState() const OVERRIDE; | 68 virtual LoadState GetLoadState() const override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 friend class WebSocketTransportConnectSubJob; | 71 friend class WebSocketTransportConnectSubJob; |
| 72 friend class TransportConnectJobHelper; | 72 friend class TransportConnectJobHelper; |
| 73 friend class WebSocketEndpointLockManager; | 73 friend class WebSocketEndpointLockManager; |
| 74 | 74 |
| 75 // Although it is not strictly necessary, it makes the code simpler if each | 75 // Although it is not strictly necessary, it makes the code simpler if each |
| 76 // subjob knows what type it is. | 76 // subjob knows what type it is. |
| 77 enum SubJobType { SUB_JOB_IPV4, SUB_JOB_IPV6 }; | 77 enum SubJobType { SUB_JOB_IPV4, SUB_JOB_IPV6 }; |
| 78 | 78 |
| 79 int DoResolveHost(); | 79 int DoResolveHost(); |
| 80 int DoResolveHostComplete(int result); | 80 int DoResolveHostComplete(int result); |
| 81 int DoTransportConnect(); | 81 int DoTransportConnect(); |
| 82 int DoTransportConnectComplete(int result); | 82 int DoTransportConnectComplete(int result); |
| 83 | 83 |
| 84 // Called back from a SubJob when it completes. | 84 // Called back from a SubJob when it completes. |
| 85 void OnSubJobComplete(int result, WebSocketTransportConnectSubJob* job); | 85 void OnSubJobComplete(int result, WebSocketTransportConnectSubJob* job); |
| 86 | 86 |
| 87 // Called from |fallback_timer_|. | 87 // Called from |fallback_timer_|. |
| 88 void StartIPv4JobAsync(); | 88 void StartIPv4JobAsync(); |
| 89 | 89 |
| 90 // Begins the host resolution and the TCP connect. Returns OK on success | 90 // Begins the host resolution and the TCP connect. Returns OK on success |
| 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 virtual int ConnectInternal() OVERRIDE; | 93 virtual 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 scoped_ptr<WebSocketTransportConnectSubJob> ipv4_job_; |
| 102 scoped_ptr<WebSocketTransportConnectSubJob> ipv6_job_; | 102 scoped_ptr<WebSocketTransportConnectSubJob> ipv6_job_; |
| 103 | 103 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 131 // need to explicitly check for this. Instead, ensure that dead sockets are | 131 // need to explicitly check for this. Instead, ensure that dead sockets are |
| 132 // returned to ReleaseSocket() in a timely fashion. | 132 // returned to ReleaseSocket() in a timely fashion. |
| 133 static void UnlockEndpoint(ClientSocketHandle* handle); | 133 static void UnlockEndpoint(ClientSocketHandle* handle); |
| 134 | 134 |
| 135 // ClientSocketPool implementation. | 135 // ClientSocketPool implementation. |
| 136 virtual int RequestSocket(const std::string& group_name, | 136 virtual int RequestSocket(const std::string& group_name, |
| 137 const void* resolve_info, | 137 const void* resolve_info, |
| 138 RequestPriority priority, | 138 RequestPriority priority, |
| 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 virtual void RequestSockets(const std::string& group_name, | 142 virtual 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 virtual void CancelRequest(const std::string& group_name, | 146 virtual void CancelRequest(const std::string& group_name, |
| 147 ClientSocketHandle* handle) OVERRIDE; | 147 ClientSocketHandle* handle) override; |
| 148 virtual void ReleaseSocket(const std::string& group_name, | 148 virtual void ReleaseSocket(const std::string& group_name, |
| 149 scoped_ptr<StreamSocket> socket, | 149 scoped_ptr<StreamSocket> socket, |
| 150 int id) OVERRIDE; | 150 int id) override; |
| 151 virtual void FlushWithError(int error) OVERRIDE; | 151 virtual void FlushWithError(int error) override; |
| 152 virtual void CloseIdleSockets() OVERRIDE; | 152 virtual void CloseIdleSockets() override; |
| 153 virtual int IdleSocketCount() const OVERRIDE; | 153 virtual int IdleSocketCount() const override; |
| 154 virtual int IdleSocketCountInGroup( | 154 virtual int IdleSocketCountInGroup( |
| 155 const std::string& group_name) const OVERRIDE; | 155 const std::string& group_name) const override; |
| 156 virtual LoadState GetLoadState( | 156 virtual LoadState GetLoadState( |
| 157 const std::string& group_name, | 157 const std::string& group_name, |
| 158 const ClientSocketHandle* handle) const OVERRIDE; | 158 const ClientSocketHandle* handle) const override; |
| 159 virtual base::DictionaryValue* GetInfoAsValue( | 159 virtual base::DictionaryValue* GetInfoAsValue( |
| 160 const std::string& name, | 160 const std::string& name, |
| 161 const std::string& type, | 161 const std::string& type, |
| 162 bool include_nested_pools) const OVERRIDE; | 162 bool include_nested_pools) const override; |
| 163 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 163 virtual base::TimeDelta ConnectionTimeout() const override; |
| 164 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; | 164 virtual ClientSocketPoolHistograms* histograms() const override; |
| 165 | 165 |
| 166 // HigherLayeredPool implementation. | 166 // HigherLayeredPool implementation. |
| 167 virtual bool IsStalled() const OVERRIDE; | 167 virtual bool IsStalled() const override; |
| 168 | 168 |
| 169 private: | 169 private: |
| 170 class ConnectJobDelegate : public ConnectJob::Delegate { | 170 class ConnectJobDelegate : public ConnectJob::Delegate { |
| 171 public: | 171 public: |
| 172 explicit ConnectJobDelegate(WebSocketTransportClientSocketPool* owner); | 172 explicit ConnectJobDelegate(WebSocketTransportClientSocketPool* owner); |
| 173 virtual ~ConnectJobDelegate(); | 173 virtual ~ConnectJobDelegate(); |
| 174 | 174 |
| 175 virtual void OnConnectJobComplete(int result, ConnectJob* job) OVERRIDE; | 175 virtual void OnConnectJobComplete(int result, ConnectJob* job) override; |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 WebSocketTransportClientSocketPool* owner_; | 178 WebSocketTransportClientSocketPool* owner_; |
| 179 | 179 |
| 180 DISALLOW_COPY_AND_ASSIGN(ConnectJobDelegate); | 180 DISALLOW_COPY_AND_ASSIGN(ConnectJobDelegate); |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 // Store the arguments from a call to RequestSocket() that has stalled so we | 183 // Store the arguments from a call to RequestSocket() that has stalled so we |
| 184 // can replay it when there are available socket slots. | 184 // can replay it when there are available socket slots. |
| 185 struct StalledRequest { | 185 struct StalledRequest { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 bool flushing_; | 239 bool flushing_; |
| 240 | 240 |
| 241 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; | 241 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; |
| 242 | 242 |
| 243 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); | 243 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 } // namespace net | 246 } // namespace net |
| 247 | 247 |
| 248 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 248 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |