| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 TransportConnectJob(const std::string& group_name, | 62 TransportConnectJob(const std::string& group_name, |
| 63 const scoped_refptr<TransportSocketParams>& params, | 63 const scoped_refptr<TransportSocketParams>& params, |
| 64 base::TimeDelta timeout_duration, | 64 base::TimeDelta timeout_duration, |
| 65 ClientSocketFactory* client_socket_factory, | 65 ClientSocketFactory* client_socket_factory, |
| 66 HostResolver* host_resolver, | 66 HostResolver* host_resolver, |
| 67 Delegate* delegate, | 67 Delegate* delegate, |
| 68 NetLog* net_log); | 68 NetLog* net_log); |
| 69 virtual ~TransportConnectJob(); | 69 virtual ~TransportConnectJob(); |
| 70 | 70 |
| 71 // ConnectJob methods. | 71 // ConnectJob methods. |
| 72 virtual LoadState GetLoadState() const; | 72 virtual LoadState GetLoadState() const OVERRIDE; |
| 73 | 73 |
| 74 // Makes |addrlist| start with an IPv4 address if |addrlist| contains any | 74 // Makes |addrlist| start with an IPv4 address if |addrlist| contains any |
| 75 // IPv4 address. | 75 // IPv4 address. |
| 76 // | 76 // |
| 77 // WARNING: this method should only be used to implement the prefer-IPv4 | 77 // WARNING: this method should only be used to implement the prefer-IPv4 |
| 78 // hack. It is a public method for the unit tests. | 78 // hack. It is a public method for the unit tests. |
| 79 static void MakeAddrListStartWithIPv4(AddressList* addrlist); | 79 static void MakeAddrListStartWithIPv4(AddressList* addrlist); |
| 80 | 80 |
| 81 static const int kIPv6FallbackTimerInMs; | 81 static const int kIPv6FallbackTimerInMs; |
| 82 | 82 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 99 int DoTransportConnect(); | 99 int DoTransportConnect(); |
| 100 int DoTransportConnectComplete(int result); | 100 int DoTransportConnectComplete(int result); |
| 101 | 101 |
| 102 // Not part of the state machine. | 102 // Not part of the state machine. |
| 103 void DoIPv6FallbackTransportConnect(); | 103 void DoIPv6FallbackTransportConnect(); |
| 104 void DoIPv6FallbackTransportConnectComplete(int result); | 104 void DoIPv6FallbackTransportConnectComplete(int result); |
| 105 | 105 |
| 106 // Begins the host resolution and the TCP connect. Returns OK on success | 106 // Begins the host resolution and the TCP connect. Returns OK on success |
| 107 // and ERR_IO_PENDING if it cannot immediately service the request. | 107 // and ERR_IO_PENDING if it cannot immediately service the request. |
| 108 // Otherwise, it returns a net error code. | 108 // Otherwise, it returns a net error code. |
| 109 virtual int ConnectInternal(); | 109 virtual int ConnectInternal() OVERRIDE; |
| 110 | 110 |
| 111 scoped_refptr<TransportSocketParams> params_; | 111 scoped_refptr<TransportSocketParams> params_; |
| 112 ClientSocketFactory* const client_socket_factory_; | 112 ClientSocketFactory* const client_socket_factory_; |
| 113 OldCompletionCallbackImpl<TransportConnectJob> callback_; | 113 OldCompletionCallbackImpl<TransportConnectJob> callback_; |
| 114 SingleRequestHostResolver resolver_; | 114 SingleRequestHostResolver resolver_; |
| 115 AddressList addresses_; | 115 AddressList addresses_; |
| 116 State next_state_; | 116 State next_state_; |
| 117 | 117 |
| 118 // The time Connect() was called. | 118 // The time Connect() was called. |
| 119 base::TimeTicks start_time_; | 119 base::TimeTicks start_time_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 144 | 144 |
| 145 virtual ~TransportClientSocketPool(); | 145 virtual ~TransportClientSocketPool(); |
| 146 | 146 |
| 147 // ClientSocketPool methods: | 147 // ClientSocketPool methods: |
| 148 | 148 |
| 149 virtual int RequestSocket(const std::string& group_name, | 149 virtual int RequestSocket(const std::string& group_name, |
| 150 const void* resolve_info, | 150 const void* resolve_info, |
| 151 RequestPriority priority, | 151 RequestPriority priority, |
| 152 ClientSocketHandle* handle, | 152 ClientSocketHandle* handle, |
| 153 OldCompletionCallback* callback, | 153 OldCompletionCallback* callback, |
| 154 const BoundNetLog& net_log); | 154 const BoundNetLog& net_log) OVERRIDE; |
| 155 | 155 |
| 156 virtual void RequestSockets(const std::string& group_name, | 156 virtual void RequestSockets(const std::string& group_name, |
| 157 const void* params, | 157 const void* params, |
| 158 int num_sockets, | 158 int num_sockets, |
| 159 const BoundNetLog& net_log); | 159 const BoundNetLog& net_log) OVERRIDE; |
| 160 | 160 |
| 161 virtual void CancelRequest(const std::string& group_name, | 161 virtual void CancelRequest(const std::string& group_name, |
| 162 ClientSocketHandle* handle); | 162 ClientSocketHandle* handle) OVERRIDE; |
| 163 | 163 |
| 164 virtual void ReleaseSocket(const std::string& group_name, | 164 virtual void ReleaseSocket(const std::string& group_name, |
| 165 StreamSocket* socket, | 165 StreamSocket* socket, |
| 166 int id); | 166 int id) OVERRIDE; |
| 167 | 167 |
| 168 virtual void Flush(); | 168 virtual void Flush() OVERRIDE; |
| 169 | 169 |
| 170 virtual void CloseIdleSockets(); | 170 virtual void CloseIdleSockets() OVERRIDE; |
| 171 | 171 |
| 172 virtual int IdleSocketCount() const; | 172 virtual int IdleSocketCount() const OVERRIDE; |
| 173 | 173 |
| 174 virtual int IdleSocketCountInGroup(const std::string& group_name) const; | 174 virtual int IdleSocketCountInGroup( |
| 175 const std::string& group_name) const OVERRIDE; |
| 175 | 176 |
| 176 virtual LoadState GetLoadState(const std::string& group_name, | 177 virtual LoadState GetLoadState( |
| 177 const ClientSocketHandle* handle) const; | 178 const std::string& group_name, |
| 179 const ClientSocketHandle* handle) const OVERRIDE; |
| 178 | 180 |
| 179 virtual base::DictionaryValue* GetInfoAsValue( | 181 virtual base::DictionaryValue* GetInfoAsValue( |
| 180 const std::string& name, | 182 const std::string& name, |
| 181 const std::string& type, | 183 const std::string& type, |
| 182 bool include_nested_pools) const; | 184 bool include_nested_pools) const OVERRIDE; |
| 183 | 185 |
| 184 virtual base::TimeDelta ConnectionTimeout() const; | 186 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; |
| 185 | 187 |
| 186 virtual ClientSocketPoolHistograms* histograms() const; | 188 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; |
| 187 | 189 |
| 188 private: | 190 private: |
| 189 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; | 191 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; |
| 190 | 192 |
| 191 class TransportConnectJobFactory | 193 class TransportConnectJobFactory |
| 192 : public PoolBase::ConnectJobFactory { | 194 : public PoolBase::ConnectJobFactory { |
| 193 public: | 195 public: |
| 194 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, | 196 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, |
| 195 HostResolver* host_resolver, | 197 HostResolver* host_resolver, |
| 196 NetLog* net_log) | 198 NetLog* net_log) |
| 197 : client_socket_factory_(client_socket_factory), | 199 : client_socket_factory_(client_socket_factory), |
| 198 host_resolver_(host_resolver), | 200 host_resolver_(host_resolver), |
| 199 net_log_(net_log) {} | 201 net_log_(net_log) {} |
| 200 | 202 |
| 201 virtual ~TransportConnectJobFactory() {} | 203 virtual ~TransportConnectJobFactory() {} |
| 202 | 204 |
| 203 // ClientSocketPoolBase::ConnectJobFactory methods. | 205 // ClientSocketPoolBase::ConnectJobFactory methods. |
| 204 | 206 |
| 205 virtual ConnectJob* NewConnectJob( | 207 virtual ConnectJob* NewConnectJob( |
| 206 const std::string& group_name, | 208 const std::string& group_name, |
| 207 const PoolBase::Request& request, | 209 const PoolBase::Request& request, |
| 208 ConnectJob::Delegate* delegate) const; | 210 ConnectJob::Delegate* delegate) const OVERRIDE; |
| 209 | 211 |
| 210 virtual base::TimeDelta ConnectionTimeout() const; | 212 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; |
| 211 | 213 |
| 212 private: | 214 private: |
| 213 ClientSocketFactory* const client_socket_factory_; | 215 ClientSocketFactory* const client_socket_factory_; |
| 214 HostResolver* const host_resolver_; | 216 HostResolver* const host_resolver_; |
| 215 NetLog* net_log_; | 217 NetLog* net_log_; |
| 216 | 218 |
| 217 DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory); | 219 DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory); |
| 218 }; | 220 }; |
| 219 | 221 |
| 220 PoolBase base_; | 222 PoolBase base_; |
| 221 | 223 |
| 222 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); | 224 DISALLOW_COPY_AND_ASSIGN(TransportClientSocketPool); |
| 223 }; | 225 }; |
| 224 | 226 |
| 225 REGISTER_SOCKET_PARAMS_FOR_POOL(TransportClientSocketPool, | 227 REGISTER_SOCKET_PARAMS_FOR_POOL(TransportClientSocketPool, |
| 226 TransportSocketParams); | 228 TransportSocketParams); |
| 227 | 229 |
| 228 } // namespace net | 230 } // namespace net |
| 229 | 231 |
| 230 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 232 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |