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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // typesafe ClientSocketPoolBase::ConnectJobFactory, rather than having to | 839 // typesafe ClientSocketPoolBase::ConnectJobFactory, rather than having to |
840 // static_cast themselves. | 840 // static_cast themselves. |
841 class ConnectJobFactoryAdaptor | 841 class ConnectJobFactoryAdaptor |
842 : public internal::ClientSocketPoolBaseHelper::ConnectJobFactory { | 842 : public internal::ClientSocketPoolBaseHelper::ConnectJobFactory { |
843 public: | 843 public: |
844 typedef typename ClientSocketPoolBase<SocketParams>::ConnectJobFactory | 844 typedef typename ClientSocketPoolBase<SocketParams>::ConnectJobFactory |
845 ConnectJobFactory; | 845 ConnectJobFactory; |
846 | 846 |
847 explicit ConnectJobFactoryAdaptor(ConnectJobFactory* connect_job_factory) | 847 explicit ConnectJobFactoryAdaptor(ConnectJobFactory* connect_job_factory) |
848 : connect_job_factory_(connect_job_factory) {} | 848 : connect_job_factory_(connect_job_factory) {} |
849 virtual ~ConnectJobFactoryAdaptor() {} | 849 ~ConnectJobFactoryAdaptor() override {} |
850 | 850 |
851 virtual scoped_ptr<ConnectJob> NewConnectJob( | 851 scoped_ptr<ConnectJob> NewConnectJob( |
852 const std::string& group_name, | 852 const std::string& group_name, |
853 const internal::ClientSocketPoolBaseHelper::Request& request, | 853 const internal::ClientSocketPoolBaseHelper::Request& request, |
854 ConnectJob::Delegate* delegate) const override { | 854 ConnectJob::Delegate* delegate) const override { |
855 const Request& casted_request = static_cast<const Request&>(request); | 855 const Request& casted_request = static_cast<const Request&>(request); |
856 return connect_job_factory_->NewConnectJob( | 856 return connect_job_factory_->NewConnectJob( |
857 group_name, casted_request, delegate); | 857 group_name, casted_request, delegate); |
858 } | 858 } |
859 | 859 |
860 base::TimeDelta ConnectionTimeout() const override { | 860 base::TimeDelta ConnectionTimeout() const override { |
861 return connect_job_factory_->ConnectionTimeout(); | 861 return connect_job_factory_->ConnectionTimeout(); |
862 } | 862 } |
863 | 863 |
864 const scoped_ptr<ConnectJobFactory> connect_job_factory_; | 864 const scoped_ptr<ConnectJobFactory> connect_job_factory_; |
865 }; | 865 }; |
866 | 866 |
867 internal::ClientSocketPoolBaseHelper helper_; | 867 internal::ClientSocketPoolBaseHelper helper_; |
868 | 868 |
869 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 869 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
870 }; | 870 }; |
871 | 871 |
872 } // namespace net | 872 } // namespace net |
873 | 873 |
874 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 874 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |