| 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_SSL_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 HttpProxyClientSocketPool* http_proxy_pool, | 190 HttpProxyClientSocketPool* http_proxy_pool, |
| 191 ClientSocketFactory* client_socket_factory, | 191 ClientSocketFactory* client_socket_factory, |
| 192 HostResolver* host_resolver, | 192 HostResolver* host_resolver, |
| 193 const SSLClientSocketContext& context, | 193 const SSLClientSocketContext& context, |
| 194 const GetMessengerCallback& get_messenger_callback, | 194 const GetMessengerCallback& get_messenger_callback, |
| 195 Delegate* delegate, | 195 Delegate* delegate, |
| 196 NetLog* net_log); | 196 NetLog* net_log); |
| 197 virtual ~SSLConnectJob(); | 197 virtual ~SSLConnectJob(); |
| 198 | 198 |
| 199 // ConnectJob methods. | 199 // ConnectJob methods. |
| 200 virtual LoadState GetLoadState() const OVERRIDE; | 200 virtual LoadState GetLoadState() const override; |
| 201 | 201 |
| 202 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) OVERRIDE; | 202 virtual void GetAdditionalErrorState(ClientSocketHandle * handle) override; |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 enum State { | 205 enum State { |
| 206 STATE_TRANSPORT_CONNECT, | 206 STATE_TRANSPORT_CONNECT, |
| 207 STATE_TRANSPORT_CONNECT_COMPLETE, | 207 STATE_TRANSPORT_CONNECT_COMPLETE, |
| 208 STATE_SOCKS_CONNECT, | 208 STATE_SOCKS_CONNECT, |
| 209 STATE_SOCKS_CONNECT_COMPLETE, | 209 STATE_SOCKS_CONNECT_COMPLETE, |
| 210 STATE_TUNNEL_CONNECT, | 210 STATE_TUNNEL_CONNECT, |
| 211 STATE_TUNNEL_CONNECT_COMPLETE, | 211 STATE_TUNNEL_CONNECT_COMPLETE, |
| 212 STATE_CREATE_SSL_SOCKET, | 212 STATE_CREATE_SSL_SOCKET, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 235 // Tells a waiting SSLConnectJob to resume its SSL connection. | 235 // Tells a waiting SSLConnectJob to resume its SSL connection. |
| 236 void ResumeSSLConnection(); | 236 void ResumeSSLConnection(); |
| 237 | 237 |
| 238 // Returns the initial state for the state machine based on the | 238 // Returns the initial state for the state machine based on the |
| 239 // |connection_type|. | 239 // |connection_type|. |
| 240 static State GetInitialState(SSLSocketParams::ConnectionType connection_type); | 240 static State GetInitialState(SSLSocketParams::ConnectionType connection_type); |
| 241 | 241 |
| 242 // Starts the SSL connection process. Returns OK on success and | 242 // Starts the SSL connection process. Returns OK on success and |
| 243 // ERR_IO_PENDING if it cannot immediately service the request. | 243 // ERR_IO_PENDING if it cannot immediately service the request. |
| 244 // Otherwise, it returns a net error code. | 244 // Otherwise, it returns a net error code. |
| 245 virtual int ConnectInternal() OVERRIDE; | 245 virtual int ConnectInternal() override; |
| 246 | 246 |
| 247 scoped_refptr<SSLSocketParams> params_; | 247 scoped_refptr<SSLSocketParams> params_; |
| 248 TransportClientSocketPool* const transport_pool_; | 248 TransportClientSocketPool* const transport_pool_; |
| 249 SOCKSClientSocketPool* const socks_pool_; | 249 SOCKSClientSocketPool* const socks_pool_; |
| 250 HttpProxyClientSocketPool* const http_proxy_pool_; | 250 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 251 ClientSocketFactory* const client_socket_factory_; | 251 ClientSocketFactory* const client_socket_factory_; |
| 252 HostResolver* const host_resolver_; | 252 HostResolver* const host_resolver_; |
| 253 | 253 |
| 254 const SSLClientSocketContext context_; | 254 const SSLClientSocketContext context_; |
| 255 | 255 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 NetLog* net_log); | 295 NetLog* net_log); |
| 296 | 296 |
| 297 virtual ~SSLClientSocketPool(); | 297 virtual ~SSLClientSocketPool(); |
| 298 | 298 |
| 299 // ClientSocketPool implementation. | 299 // ClientSocketPool implementation. |
| 300 virtual int RequestSocket(const std::string& group_name, | 300 virtual int RequestSocket(const std::string& group_name, |
| 301 const void* connect_params, | 301 const void* connect_params, |
| 302 RequestPriority priority, | 302 RequestPriority priority, |
| 303 ClientSocketHandle* handle, | 303 ClientSocketHandle* handle, |
| 304 const CompletionCallback& callback, | 304 const CompletionCallback& callback, |
| 305 const BoundNetLog& net_log) OVERRIDE; | 305 const BoundNetLog& net_log) override; |
| 306 | 306 |
| 307 virtual void RequestSockets(const std::string& group_name, | 307 virtual void RequestSockets(const std::string& group_name, |
| 308 const void* params, | 308 const void* params, |
| 309 int num_sockets, | 309 int num_sockets, |
| 310 const BoundNetLog& net_log) OVERRIDE; | 310 const BoundNetLog& net_log) override; |
| 311 | 311 |
| 312 virtual void CancelRequest(const std::string& group_name, | 312 virtual void CancelRequest(const std::string& group_name, |
| 313 ClientSocketHandle* handle) OVERRIDE; | 313 ClientSocketHandle* handle) override; |
| 314 | 314 |
| 315 virtual void ReleaseSocket(const std::string& group_name, | 315 virtual void ReleaseSocket(const std::string& group_name, |
| 316 scoped_ptr<StreamSocket> socket, | 316 scoped_ptr<StreamSocket> socket, |
| 317 int id) OVERRIDE; | 317 int id) override; |
| 318 | 318 |
| 319 virtual void FlushWithError(int error) OVERRIDE; | 319 virtual void FlushWithError(int error) override; |
| 320 | 320 |
| 321 virtual void CloseIdleSockets() OVERRIDE; | 321 virtual void CloseIdleSockets() override; |
| 322 | 322 |
| 323 virtual int IdleSocketCount() const OVERRIDE; | 323 virtual int IdleSocketCount() const override; |
| 324 | 324 |
| 325 virtual int IdleSocketCountInGroup( | 325 virtual int IdleSocketCountInGroup( |
| 326 const std::string& group_name) const OVERRIDE; | 326 const std::string& group_name) const override; |
| 327 | 327 |
| 328 virtual LoadState GetLoadState( | 328 virtual LoadState GetLoadState( |
| 329 const std::string& group_name, | 329 const std::string& group_name, |
| 330 const ClientSocketHandle* handle) const OVERRIDE; | 330 const ClientSocketHandle* handle) const override; |
| 331 | 331 |
| 332 virtual base::DictionaryValue* GetInfoAsValue( | 332 virtual base::DictionaryValue* GetInfoAsValue( |
| 333 const std::string& name, | 333 const std::string& name, |
| 334 const std::string& type, | 334 const std::string& type, |
| 335 bool include_nested_pools) const OVERRIDE; | 335 bool include_nested_pools) const override; |
| 336 | 336 |
| 337 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 337 virtual base::TimeDelta ConnectionTimeout() const override; |
| 338 | 338 |
| 339 virtual ClientSocketPoolHistograms* histograms() const OVERRIDE; | 339 virtual ClientSocketPoolHistograms* histograms() const override; |
| 340 | 340 |
| 341 // LowerLayeredPool implementation. | 341 // LowerLayeredPool implementation. |
| 342 virtual bool IsStalled() const OVERRIDE; | 342 virtual bool IsStalled() const override; |
| 343 | 343 |
| 344 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 344 virtual void AddHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
| 345 | 345 |
| 346 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) OVERRIDE; | 346 virtual void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) override; |
| 347 | 347 |
| 348 // HigherLayeredPool implementation. | 348 // HigherLayeredPool implementation. |
| 349 virtual bool CloseOneIdleConnection() OVERRIDE; | 349 virtual bool CloseOneIdleConnection() override; |
| 350 | 350 |
| 351 // Gets the SSLConnectJobMessenger for the given ssl session |cache_key|. If | 351 // Gets the SSLConnectJobMessenger for the given ssl session |cache_key|. If |
| 352 // none exits, it creates one and stores it in |messenger_map_|. | 352 // none exits, it creates one and stores it in |messenger_map_|. |
| 353 SSLConnectJobMessenger* GetOrCreateSSLConnectJobMessenger( | 353 SSLConnectJobMessenger* GetOrCreateSSLConnectJobMessenger( |
| 354 const std::string& cache_key); | 354 const std::string& cache_key); |
| 355 void DeleteSSLConnectJobMessenger(const std::string& cache_key); | 355 void DeleteSSLConnectJobMessenger(const std::string& cache_key); |
| 356 | 356 |
| 357 private: | 357 private: |
| 358 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; | 358 typedef ClientSocketPoolBase<SSLSocketParams> PoolBase; |
| 359 // Maps SSLConnectJob cache keys to SSLConnectJobMessenger objects. | 359 // Maps SSLConnectJob cache keys to SSLConnectJobMessenger objects. |
| 360 typedef std::map<std::string, SSLConnectJobMessenger*> MessengerMap; | 360 typedef std::map<std::string, SSLConnectJobMessenger*> MessengerMap; |
| 361 | 361 |
| 362 // SSLConfigService::Observer implementation. | 362 // SSLConfigService::Observer implementation. |
| 363 | 363 |
| 364 // When the user changes the SSL config, we flush all idle sockets so they | 364 // When the user changes the SSL config, we flush all idle sockets so they |
| 365 // won't get re-used. | 365 // won't get re-used. |
| 366 virtual void OnSSLConfigChanged() OVERRIDE; | 366 virtual void OnSSLConfigChanged() override; |
| 367 | 367 |
| 368 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { | 368 class SSLConnectJobFactory : public PoolBase::ConnectJobFactory { |
| 369 public: | 369 public: |
| 370 SSLConnectJobFactory( | 370 SSLConnectJobFactory( |
| 371 TransportClientSocketPool* transport_pool, | 371 TransportClientSocketPool* transport_pool, |
| 372 SOCKSClientSocketPool* socks_pool, | 372 SOCKSClientSocketPool* socks_pool, |
| 373 HttpProxyClientSocketPool* http_proxy_pool, | 373 HttpProxyClientSocketPool* http_proxy_pool, |
| 374 ClientSocketFactory* client_socket_factory, | 374 ClientSocketFactory* client_socket_factory, |
| 375 HostResolver* host_resolver, | 375 HostResolver* host_resolver, |
| 376 const SSLClientSocketContext& context, | 376 const SSLClientSocketContext& context, |
| 377 const SSLConnectJob::GetMessengerCallback& get_messenger_callback, | 377 const SSLConnectJob::GetMessengerCallback& get_messenger_callback, |
| 378 NetLog* net_log); | 378 NetLog* net_log); |
| 379 | 379 |
| 380 virtual ~SSLConnectJobFactory(); | 380 virtual ~SSLConnectJobFactory(); |
| 381 | 381 |
| 382 // ClientSocketPoolBase::ConnectJobFactory methods. | 382 // ClientSocketPoolBase::ConnectJobFactory methods. |
| 383 virtual scoped_ptr<ConnectJob> NewConnectJob( | 383 virtual scoped_ptr<ConnectJob> NewConnectJob( |
| 384 const std::string& group_name, | 384 const std::string& group_name, |
| 385 const PoolBase::Request& request, | 385 const PoolBase::Request& request, |
| 386 ConnectJob::Delegate* delegate) const OVERRIDE; | 386 ConnectJob::Delegate* delegate) const override; |
| 387 | 387 |
| 388 virtual base::TimeDelta ConnectionTimeout() const OVERRIDE; | 388 virtual base::TimeDelta ConnectionTimeout() const override; |
| 389 | 389 |
| 390 private: | 390 private: |
| 391 TransportClientSocketPool* const transport_pool_; | 391 TransportClientSocketPool* const transport_pool_; |
| 392 SOCKSClientSocketPool* const socks_pool_; | 392 SOCKSClientSocketPool* const socks_pool_; |
| 393 HttpProxyClientSocketPool* const http_proxy_pool_; | 393 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 394 ClientSocketFactory* const client_socket_factory_; | 394 ClientSocketFactory* const client_socket_factory_; |
| 395 HostResolver* const host_resolver_; | 395 HostResolver* const host_resolver_; |
| 396 const SSLClientSocketContext context_; | 396 const SSLClientSocketContext context_; |
| 397 base::TimeDelta timeout_; | 397 base::TimeDelta timeout_; |
| 398 SSLConnectJob::GetMessengerCallback get_messenger_callback_; | 398 SSLConnectJob::GetMessengerCallback get_messenger_callback_; |
| 399 NetLog* net_log_; | 399 NetLog* net_log_; |
| 400 | 400 |
| 401 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); | 401 DISALLOW_COPY_AND_ASSIGN(SSLConnectJobFactory); |
| 402 }; | 402 }; |
| 403 | 403 |
| 404 TransportClientSocketPool* const transport_pool_; | 404 TransportClientSocketPool* const transport_pool_; |
| 405 SOCKSClientSocketPool* const socks_pool_; | 405 SOCKSClientSocketPool* const socks_pool_; |
| 406 HttpProxyClientSocketPool* const http_proxy_pool_; | 406 HttpProxyClientSocketPool* const http_proxy_pool_; |
| 407 PoolBase base_; | 407 PoolBase base_; |
| 408 const scoped_refptr<SSLConfigService> ssl_config_service_; | 408 const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 409 MessengerMap messenger_map_; | 409 MessengerMap messenger_map_; |
| 410 bool enable_ssl_connect_job_waiting_; | 410 bool enable_ssl_connect_job_waiting_; |
| 411 | 411 |
| 412 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); | 412 DISALLOW_COPY_AND_ASSIGN(SSLClientSocketPool); |
| 413 }; | 413 }; |
| 414 | 414 |
| 415 } // namespace net | 415 } // namespace net |
| 416 | 416 |
| 417 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ | 417 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |