| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 bool CloseOneIdleSocket(); | 331 bool CloseOneIdleSocket(); |
| 332 | 332 |
| 333 // Checks higher layered pools to see if they can close an idle connection. | 333 // Checks higher layered pools to see if they can close an idle connection. |
| 334 bool CloseOneIdleConnectionInHigherLayeredPool(); | 334 bool CloseOneIdleConnectionInHigherLayeredPool(); |
| 335 | 335 |
| 336 // See ClientSocketPool::GetInfoAsValue for documentation on this function. | 336 // See ClientSocketPool::GetInfoAsValue for documentation on this function. |
| 337 std::unique_ptr<base::DictionaryValue> GetInfoAsValue( | 337 std::unique_ptr<base::DictionaryValue> GetInfoAsValue( |
| 338 const std::string& name, | 338 const std::string& name, |
| 339 const std::string& type) const; | 339 const std::string& type) const; |
| 340 | 340 |
| 341 void PopulateAllocatorDump( |
| 342 base::trace_event::MemoryAllocatorDump* dump) const; |
| 343 |
| 341 base::TimeDelta ConnectionTimeout() const { | 344 base::TimeDelta ConnectionTimeout() const { |
| 342 return connect_job_factory_->ConnectionTimeout(); | 345 return connect_job_factory_->ConnectionTimeout(); |
| 343 } | 346 } |
| 344 | 347 |
| 345 static bool connect_backup_jobs_enabled(); | 348 static bool connect_backup_jobs_enabled(); |
| 346 static bool set_connect_backup_jobs_enabled(bool enabled); | 349 static bool set_connect_backup_jobs_enabled(bool enabled); |
| 347 | 350 |
| 348 void EnableConnectBackupJobs(); | 351 void EnableConnectBackupJobs(); |
| 349 | 352 |
| 350 // ConnectJob::Delegate methods: | 353 // ConnectJob::Delegate methods: |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 794 |
| 792 int IdleSocketCountInGroup(const std::string& group_name) const { | 795 int IdleSocketCountInGroup(const std::string& group_name) const { |
| 793 return helper_.IdleSocketCountInGroup(group_name); | 796 return helper_.IdleSocketCountInGroup(group_name); |
| 794 } | 797 } |
| 795 | 798 |
| 796 LoadState GetLoadState(const std::string& group_name, | 799 LoadState GetLoadState(const std::string& group_name, |
| 797 const ClientSocketHandle* handle) const { | 800 const ClientSocketHandle* handle) const { |
| 798 return helper_.GetLoadState(group_name, handle); | 801 return helper_.GetLoadState(group_name, handle); |
| 799 } | 802 } |
| 800 | 803 |
| 804 void PopulateAllocatorDump( |
| 805 base::trace_event::MemoryAllocatorDump* dump) const { |
| 806 return helper_.PopulateAllocatorDump(dump); |
| 807 } |
| 808 |
| 801 virtual void OnConnectJobComplete(int result, ConnectJob* job) { | 809 virtual void OnConnectJobComplete(int result, ConnectJob* job) { |
| 802 return helper_.OnConnectJobComplete(result, job); | 810 return helper_.OnConnectJobComplete(result, job); |
| 803 } | 811 } |
| 804 | 812 |
| 805 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { | 813 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { |
| 806 return helper_.NumUnassignedConnectJobsInGroup(group_name); | 814 return helper_.NumUnassignedConnectJobsInGroup(group_name); |
| 807 } | 815 } |
| 808 | 816 |
| 809 int NumConnectJobsInGroup(const std::string& group_name) const { | 817 int NumConnectJobsInGroup(const std::string& group_name) const { |
| 810 return helper_.NumConnectJobsInGroup(group_name); | 818 return helper_.NumConnectJobsInGroup(group_name); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 }; | 881 }; |
| 874 | 882 |
| 875 internal::ClientSocketPoolBaseHelper helper_; | 883 internal::ClientSocketPoolBaseHelper helper_; |
| 876 | 884 |
| 877 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 885 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 878 }; | 886 }; |
| 879 | 887 |
| 880 } // namespace net | 888 } // namespace net |
| 881 | 889 |
| 882 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 890 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |