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 // 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return group_map_.find(group_name)->second->active_socket_count(); | 291 return group_map_.find(group_name)->second->active_socket_count(); |
292 } | 292 } |
293 | 293 |
294 bool HasGroup(const std::string& group_name) const; | 294 bool HasGroup(const std::string& group_name) const; |
295 | 295 |
296 // Closes all idle sockets if |force| is true. Else, only closes idle | 296 // Closes all idle sockets if |force| is true. Else, only closes idle |
297 // sockets that timed out or can't be reused. Made public for testing. | 297 // sockets that timed out or can't be reused. Made public for testing. |
298 void CleanupIdleSockets(bool force); | 298 void CleanupIdleSockets(bool force); |
299 | 299 |
300 // See ClientSocketPool::GetInfoAsValue for documentation on this function. | 300 // See ClientSocketPool::GetInfoAsValue for documentation on this function. |
301 DictionaryValue* GetInfoAsValue(const std::string& name, | 301 base::DictionaryValue* GetInfoAsValue(const std::string& name, |
302 const std::string& type) const; | 302 const std::string& type) const; |
303 | 303 |
304 base::TimeDelta ConnectionTimeout() const { | 304 base::TimeDelta ConnectionTimeout() const { |
305 return connect_job_factory_->ConnectionTimeout(); | 305 return connect_job_factory_->ConnectionTimeout(); |
306 } | 306 } |
307 | 307 |
308 static bool connect_backup_jobs_enabled(); | 308 static bool connect_backup_jobs_enabled(); |
309 static bool set_connect_backup_jobs_enabled(bool enabled); | 309 static bool set_connect_backup_jobs_enabled(bool enabled); |
310 | 310 |
311 void EnableConnectBackupJobs(); | 311 void EnableConnectBackupJobs(); |
312 | 312 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 705 } |
706 | 706 |
707 bool HasGroup(const std::string& group_name) const { | 707 bool HasGroup(const std::string& group_name) const { |
708 return helper_.HasGroup(group_name); | 708 return helper_.HasGroup(group_name); |
709 } | 709 } |
710 | 710 |
711 void CleanupIdleSockets(bool force) { | 711 void CleanupIdleSockets(bool force) { |
712 return helper_.CleanupIdleSockets(force); | 712 return helper_.CleanupIdleSockets(force); |
713 } | 713 } |
714 | 714 |
715 DictionaryValue* GetInfoAsValue(const std::string& name, | 715 base::DictionaryValue* GetInfoAsValue(const std::string& name, |
716 const std::string& type) const { | 716 const std::string& type) const { |
717 return helper_.GetInfoAsValue(name, type); | 717 return helper_.GetInfoAsValue(name, type); |
718 } | 718 } |
719 | 719 |
720 base::TimeDelta ConnectionTimeout() const { | 720 base::TimeDelta ConnectionTimeout() const { |
721 return helper_.ConnectionTimeout(); | 721 return helper_.ConnectionTimeout(); |
722 } | 722 } |
723 | 723 |
724 ClientSocketPoolHistograms* histograms() const { | 724 ClientSocketPoolHistograms* histograms() const { |
725 return histograms_; | 725 return histograms_; |
726 } | 726 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 // Histograms for the pool | 764 // Histograms for the pool |
765 ClientSocketPoolHistograms* const histograms_; | 765 ClientSocketPoolHistograms* const histograms_; |
766 internal::ClientSocketPoolBaseHelper helper_; | 766 internal::ClientSocketPoolBaseHelper helper_; |
767 | 767 |
768 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 768 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
769 }; | 769 }; |
770 | 770 |
771 } // namespace net | 771 } // namespace net |
772 | 772 |
773 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 773 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |