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 // A ClientSocketPoolBase is used to restrict the number of sockets open at | 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at |
6 // a time. It also maintains a list of idle persistent sockets for reuse. | 6 // a time. It also maintains a list of idle persistent sockets for reuse. |
7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle | 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle |
8 // the core logic of (1) restricting the number of active (connected or | 8 // the core logic of (1) restricting the number of active (connected or |
9 // connecting) sockets per "group" (generally speaking, the hostname), (2) | 9 // connecting) sockets per "group" (generally speaking, the hostname), (2) |
10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) | 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 base::TimeDelta ConnectionTimeout() const { | 320 base::TimeDelta ConnectionTimeout() const { |
321 return connect_job_factory_->ConnectionTimeout(); | 321 return connect_job_factory_->ConnectionTimeout(); |
322 } | 322 } |
323 | 323 |
324 static bool connect_backup_jobs_enabled(); | 324 static bool connect_backup_jobs_enabled(); |
325 static bool set_connect_backup_jobs_enabled(bool enabled); | 325 static bool set_connect_backup_jobs_enabled(bool enabled); |
326 | 326 |
327 void EnableConnectBackupJobs(); | 327 void EnableConnectBackupJobs(); |
328 | 328 |
329 // ConnectJob::Delegate methods: | 329 // ConnectJob::Delegate methods: |
330 virtual void OnConnectJobComplete(int result, ConnectJob* job) OVERRIDE; | 330 virtual void OnConnectJobComplete(int result, ConnectJob* job) override; |
331 | 331 |
332 // NetworkChangeNotifier::IPAddressObserver methods: | 332 // NetworkChangeNotifier::IPAddressObserver methods: |
333 virtual void OnIPAddressChanged() OVERRIDE; | 333 virtual void OnIPAddressChanged() override; |
334 | 334 |
335 private: | 335 private: |
336 friend class base::RefCounted<ClientSocketPoolBaseHelper>; | 336 friend class base::RefCounted<ClientSocketPoolBaseHelper>; |
337 | 337 |
338 // Entry for a persistent socket which became idle at time |start_time|. | 338 // Entry for a persistent socket which became idle at time |start_time|. |
339 struct IdleSocket { | 339 struct IdleSocket { |
340 IdleSocket() : socket(NULL) {} | 340 IdleSocket() : socket(NULL) {} |
341 | 341 |
342 // An idle socket can't be used if it is disconnected or has been used | 342 // An idle socket can't be used if it is disconnected or has been used |
343 // before and has received data unexpectedly (hence no longer idle). The | 343 // before and has received data unexpectedly (hence no longer idle). The |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 typedef typename ClientSocketPoolBase<SocketParams>::ConnectJobFactory | 849 typedef typename ClientSocketPoolBase<SocketParams>::ConnectJobFactory |
850 ConnectJobFactory; | 850 ConnectJobFactory; |
851 | 851 |
852 explicit ConnectJobFactoryAdaptor(ConnectJobFactory* connect_job_factory) | 852 explicit ConnectJobFactoryAdaptor(ConnectJobFactory* connect_job_factory) |
853 : connect_job_factory_(connect_job_factory) {} | 853 : connect_job_factory_(connect_job_factory) {} |
854 virtual ~ConnectJobFactoryAdaptor() {} | 854 virtual ~ConnectJobFactoryAdaptor() {} |
855 | 855 |
856 virtual scoped_ptr<ConnectJob> NewConnectJob( | 856 virtual scoped_ptr<ConnectJob> NewConnectJob( |
857 const std::string& group_name, | 857 const std::string& group_name, |
858 const internal::ClientSocketPoolBaseHelper::Request& request, | 858 const internal::ClientSocketPoolBaseHelper::Request& request, |
859 ConnectJob::Delegate* delegate) const OVERRIDE { | 859 ConnectJob::Delegate* delegate) const override { |
860 const Request& casted_request = static_cast<const Request&>(request); | 860 const Request& casted_request = static_cast<const Request&>(request); |
861 return connect_job_factory_->NewConnectJob( | 861 return connect_job_factory_->NewConnectJob( |
862 group_name, casted_request, delegate); | 862 group_name, casted_request, delegate); |
863 } | 863 } |
864 | 864 |
865 virtual base::TimeDelta ConnectionTimeout() const { | 865 virtual base::TimeDelta ConnectionTimeout() const { |
866 return connect_job_factory_->ConnectionTimeout(); | 866 return connect_job_factory_->ConnectionTimeout(); |
867 } | 867 } |
868 | 868 |
869 const scoped_ptr<ConnectJobFactory> connect_job_factory_; | 869 const scoped_ptr<ConnectJobFactory> connect_job_factory_; |
870 }; | 870 }; |
871 | 871 |
872 // Histograms for the pool | 872 // Histograms for the pool |
873 ClientSocketPoolHistograms* const histograms_; | 873 ClientSocketPoolHistograms* const histograms_; |
874 internal::ClientSocketPoolBaseHelper helper_; | 874 internal::ClientSocketPoolBaseHelper helper_; |
875 | 875 |
876 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 876 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
877 }; | 877 }; |
878 | 878 |
879 } // namespace net | 879 } // namespace net |
880 | 880 |
881 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 881 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |