| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // TODO(willchan): Consider a better algorithm for doing this. Perhaps we | 319 // TODO(willchan): Consider a better algorithm for doing this. Perhaps we |
| 320 // should keep an ordered list of idle sockets, and close them in order. | 320 // should keep an ordered list of idle sockets, and close them in order. |
| 321 // Requires maintaining more state. It's not clear if it's worth it since | 321 // Requires maintaining more state. It's not clear if it's worth it since |
| 322 // I'm not sure if we hit this situation often. | 322 // I'm not sure if we hit this situation often. |
| 323 bool CloseOneIdleSocket(); | 323 bool CloseOneIdleSocket(); |
| 324 | 324 |
| 325 // Checks higher layered pools to see if they can close an idle connection. | 325 // Checks higher layered pools to see if they can close an idle connection. |
| 326 bool CloseOneIdleConnectionInHigherLayeredPool(); | 326 bool CloseOneIdleConnectionInHigherLayeredPool(); |
| 327 | 327 |
| 328 // See ClientSocketPool::GetInfoAsValue for documentation on this function. | 328 // See ClientSocketPool::GetInfoAsValue for documentation on this function. |
| 329 base::DictionaryValue* GetInfoAsValue(const std::string& name, | 329 scoped_ptr<base::DictionaryValue> GetInfoAsValue( |
| 330 const std::string& type) const; | 330 const std::string& name, |
| 331 const std::string& type) const; |
| 331 | 332 |
| 332 base::TimeDelta ConnectionTimeout() const { | 333 base::TimeDelta ConnectionTimeout() const { |
| 333 return connect_job_factory_->ConnectionTimeout(); | 334 return connect_job_factory_->ConnectionTimeout(); |
| 334 } | 335 } |
| 335 | 336 |
| 336 static bool connect_backup_jobs_enabled(); | 337 static bool connect_backup_jobs_enabled(); |
| 337 static bool set_connect_backup_jobs_enabled(bool enabled); | 338 static bool set_connect_backup_jobs_enabled(bool enabled); |
| 338 | 339 |
| 339 void EnableConnectBackupJobs(); | 340 void EnableConnectBackupJobs(); |
| 340 | 341 |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 } | 821 } |
| 821 | 822 |
| 822 bool HasGroup(const std::string& group_name) const { | 823 bool HasGroup(const std::string& group_name) const { |
| 823 return helper_.HasGroup(group_name); | 824 return helper_.HasGroup(group_name); |
| 824 } | 825 } |
| 825 | 826 |
| 826 void CleanupIdleSockets(bool force) { | 827 void CleanupIdleSockets(bool force) { |
| 827 return helper_.CleanupIdleSockets(force); | 828 return helper_.CleanupIdleSockets(force); |
| 828 } | 829 } |
| 829 | 830 |
| 830 base::DictionaryValue* GetInfoAsValue(const std::string& name, | 831 scoped_ptr<base::DictionaryValue> GetInfoAsValue(const std::string& name, |
| 831 const std::string& type) const { | 832 const std::string& type) const { |
| 832 return helper_.GetInfoAsValue(name, type); | 833 return helper_.GetInfoAsValue(name, type); |
| 833 } | 834 } |
| 834 | 835 |
| 835 base::TimeDelta ConnectionTimeout() const { | 836 base::TimeDelta ConnectionTimeout() const { |
| 836 return helper_.ConnectionTimeout(); | 837 return helper_.ConnectionTimeout(); |
| 837 } | 838 } |
| 838 | 839 |
| 839 void EnableConnectBackupJobs() { helper_.EnableConnectBackupJobs(); } | 840 void EnableConnectBackupJobs() { helper_.EnableConnectBackupJobs(); } |
| 840 | 841 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 }; | 878 }; |
| 878 | 879 |
| 879 internal::ClientSocketPoolBaseHelper helper_; | 880 internal::ClientSocketPoolBaseHelper helper_; |
| 880 | 881 |
| 881 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 882 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 882 }; | 883 }; |
| 883 | 884 |
| 884 } // namespace net | 885 } // namespace net |
| 885 | 886 |
| 886 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 887 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |