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" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 RequestPriority priority, | 160 RequestPriority priority, |
161 const scoped_refptr<TransportSocketParams>& params, | 161 const scoped_refptr<TransportSocketParams>& params, |
162 base::TimeDelta timeout_duration, | 162 base::TimeDelta timeout_duration, |
163 ClientSocketFactory* client_socket_factory, | 163 ClientSocketFactory* client_socket_factory, |
164 HostResolver* host_resolver, | 164 HostResolver* host_resolver, |
165 Delegate* delegate, | 165 Delegate* delegate, |
166 NetLog* net_log); | 166 NetLog* net_log); |
167 virtual ~TransportConnectJob(); | 167 virtual ~TransportConnectJob(); |
168 | 168 |
169 // ConnectJob methods. | 169 // ConnectJob methods. |
170 virtual LoadState GetLoadState() const OVERRIDE; | 170 virtual LoadState GetLoadState() const override; |
171 | 171 |
172 // Rolls |addrlist| forward until the first IPv4 address, if any. | 172 // Rolls |addrlist| forward until the first IPv4 address, if any. |
173 // WARNING: this method should only be used to implement the prefer-IPv4 hack. | 173 // WARNING: this method should only be used to implement the prefer-IPv4 hack. |
174 static void MakeAddressListStartWithIPv4(AddressList* addrlist); | 174 static void MakeAddressListStartWithIPv4(AddressList* addrlist); |
175 | 175 |
176 private: | 176 private: |
177 enum ConnectInterval { | 177 enum ConnectInterval { |
178 CONNECT_INTERVAL_LE_10MS, | 178 CONNECT_INTERVAL_LE_10MS, |
179 CONNECT_INTERVAL_LE_20MS, | 179 CONNECT_INTERVAL_LE_20MS, |
180 CONNECT_INTERVAL_GT_20MS, | 180 CONNECT_INTERVAL_GT_20MS, |
181 }; | 181 }; |
182 | 182 |
183 friend class TransportConnectJobHelper; | 183 friend class TransportConnectJobHelper; |
184 | 184 |
185 int DoResolveHost(); | 185 int DoResolveHost(); |
186 int DoResolveHostComplete(int result); | 186 int DoResolveHostComplete(int result); |
187 int DoTransportConnect(); | 187 int DoTransportConnect(); |
188 int DoTransportConnectComplete(int result); | 188 int DoTransportConnectComplete(int result); |
189 | 189 |
190 // Not part of the state machine. | 190 // Not part of the state machine. |
191 void DoIPv6FallbackTransportConnect(); | 191 void DoIPv6FallbackTransportConnect(); |
192 void DoIPv6FallbackTransportConnectComplete(int result); | 192 void DoIPv6FallbackTransportConnectComplete(int result); |
193 | 193 |
194 // Begins the host resolution and the TCP connect. Returns OK on success | 194 // Begins the host resolution and the TCP connect. Returns OK on success |
195 // and ERR_IO_PENDING if it cannot immediately service the request. | 195 // and ERR_IO_PENDING if it cannot immediately service the request. |
196 // Otherwise, it returns a net error code. | 196 // Otherwise, it returns a net error code. |
197 virtual int ConnectInternal() OVERRIDE; | 197 virtual int ConnectInternal() override; |
198 | 198 |
199 TransportConnectJobHelper helper_; | 199 TransportConnectJobHelper helper_; |
200 | 200 |
201 scoped_ptr<StreamSocket> transport_socket_; | 201 scoped_ptr<StreamSocket> transport_socket_; |
202 | 202 |
203 scoped_ptr<StreamSocket> fallback_transport_socket_; | 203 scoped_ptr<StreamSocket> fallback_transport_socket_; |
204 scoped_ptr<AddressList> fallback_addresses_; | 204 scoped_ptr<AddressList> fallback_addresses_; |
205 base::TimeTicks fallback_connect_start_time_; | 205 base::TimeTicks fallback_connect_start_time_; |
206 base::OneShotTimer<TransportConnectJob> fallback_timer_; | 206 base::OneShotTimer<TransportConnectJob> fallback_timer_; |
207 | 207 |
(...skipping 16 matching lines...) Expand all Loading... |
224 NetLog* net_log); | 224 NetLog* net_log); |
225 | 225 |
226 virtual ~TransportClientSocketPool(); | 226 virtual ~TransportClientSocketPool(); |
227 | 227 |
228 // ClientSocketPool implementation. | 228 // ClientSocketPool implementation. |
229 virtual int RequestSocket(const std::string& group_name, | 229 virtual int RequestSocket(const std::string& group_name, |
230 const void* resolve_info, | 230 const void* resolve_info, |
231 RequestPriority priority, | 231 RequestPriority priority, |
232 ClientSocketHandle* handle, | 232 ClientSocketHandle* handle, |
233 const CompletionCallback& callback, | 233 const CompletionCallback& callback, |
234 const BoundNetLog& net_log) OVERRIDE; | 234 const BoundNetLog& net_log) override; |
235 virtual void RequestSockets(const std::string& group_name, | 235 virtual void RequestSockets(const std::string& group_name, |
236 const void* params, | 236 const void* params, |
237 int num_sockets, | 237 int num_sockets, |
238 const BoundNetLog& net_log) OVERRIDE; | 238 const BoundNetLog& net_log) override; |
239 virtual void CancelRequest(const std::string& group_name, | 239 virtual void CancelRequest(const std::string& group_name, |
240 ClientSocketHandle* handle) OVERRIDE; | 240 ClientSocketHandle* handle) override; |
241 virtual void ReleaseSocket(const std::string& group_name, | 241 virtual void ReleaseSocket(const std::string& group_name, |
242 scoped_ptr<StreamSocket> socket, | 242 scoped_ptr<StreamSocket> socket, |
243 int id) OVERRIDE; | 243 int id) override; |
244 virtual void FlushWithError(int error) OVERRIDE; | 244 virtual void FlushWithError(int error) override; |
245 virtual void CloseIdleSockets() OVERRIDE; | 245 virtual void CloseIdleSockets() override; |
246 virtual int IdleSocketCount() const OVERRIDE; | 246 virtual int IdleSocketCount() const override; |
247 virtual int IdleSocketCountInGroup( | 247 virtual int IdleSocketCountInGroup( |
248 const std::string& group_name) const OVERRIDE; | 248 const std::string& group_name) const override; |
249 virtual LoadState GetLoadState( | 249 virtual LoadState GetLoadState( |
250 const std::string& group_name, | 250 const std::string& group_name, |
251 const ClientSocketHandle* handle) const OVERRIDE; | 251 const ClientSocketHandle* handle) const override; |
252 virtual base::DictionaryValue* GetInfoAsValue( | 252 virtual base::DictionaryValue* GetInfoAsValue( |
253 const std::string& name, | 253 const std::string& name, |
254 const std::string& type, | 254 const std::string& type, |
255 bool include_nested_pools) const OVERRIDE; | 255 bool include_nested_pools) const override; |
256 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 256 virtual base::TimeDelta ConnectionTimeout() const override; |
257 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; | 257 virtual ClientSocketPoolHistograms* histograms() const override; |
258 | 258 |
259 // HigherLayeredPool implementation. | 259 // HigherLayeredPool implementation. |
260 virtual bool IsStalled() const OVERRIDE; | 260 virtual bool IsStalled() const override; |
261 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 261 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
262 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 262 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
263 | 263 |
264 protected: | 264 protected: |
265 // Methods shared with WebSocketTransportClientSocketPool | 265 // Methods shared with WebSocketTransportClientSocketPool |
266 void NetLogTcpClientSocketPoolRequestedSocket( | 266 void NetLogTcpClientSocketPoolRequestedSocket( |
267 const BoundNetLog& net_log, | 267 const BoundNetLog& net_log, |
268 const scoped_refptr<TransportSocketParams>* casted_params); | 268 const scoped_refptr<TransportSocketParams>* casted_params); |
269 | 269 |
270 private: | 270 private: |
271 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; | 271 typedef ClientSocketPoolBase<TransportSocketParams> PoolBase; |
272 | 272 |
273 class TransportConnectJobFactory | 273 class TransportConnectJobFactory |
274 : public PoolBase::ConnectJobFactory { | 274 : public PoolBase::ConnectJobFactory { |
275 public: | 275 public: |
276 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, | 276 TransportConnectJobFactory(ClientSocketFactory* client_socket_factory, |
277 HostResolver* host_resolver, | 277 HostResolver* host_resolver, |
278 NetLog* net_log) | 278 NetLog* net_log) |
279 : client_socket_factory_(client_socket_factory), | 279 : client_socket_factory_(client_socket_factory), |
280 host_resolver_(host_resolver), | 280 host_resolver_(host_resolver), |
281 net_log_(net_log) {} | 281 net_log_(net_log) {} |
282 | 282 |
283 virtual ~TransportConnectJobFactory() {} | 283 virtual ~TransportConnectJobFactory() {} |
284 | 284 |
285 // ClientSocketPoolBase::ConnectJobFactory methods. | 285 // ClientSocketPoolBase::ConnectJobFactory methods. |
286 | 286 |
287 virtual scoped_ptr<ConnectJob> NewConnectJob( | 287 virtual scoped_ptr<ConnectJob> NewConnectJob( |
288 const std::string& group_name, | 288 const std::string& group_name, |
289 const PoolBase::Request& request, | 289 const PoolBase::Request& request, |
290 ConnectJob::Delegate* delegate) const OVERRIDE; | 290 ConnectJob::Delegate* delegate) const override; |
291 | 291 |
292 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 292 virtual base::TimeDelta ConnectionTimeout() const override; |
293 | 293 |
294 private: | 294 private: |
295 ClientSocketFactory* const client_socket_factory_; | 295 ClientSocketFactory* const client_socket_factory_; |
296 HostResolver* const host_resolver_; | 296 HostResolver* const host_resolver_; |
297 NetLog* net_log_; | 297 NetLog* net_log_; |
298 | 298 |
299 DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory); | 299 DISALLOW_COPY_AND_ASSIGN(TransportConnectJobFactory); |
300 }; | 300 }; |
301 | 301 |
302 PoolBase base_; | 302 PoolBase base_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 break; | 355 break; |
356 } | 356 } |
357 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 357 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
358 | 358 |
359 return rv; | 359 return rv; |
360 } | 360 } |
361 | 361 |
362 } // namespace net | 362 } // namespace net |
363 | 363 |
364 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 364 #endif // NET_SOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |