| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "net/base/network_change_notifier.h" | 49 #include "net/base/network_change_notifier.h" |
| 50 #include "net/base/priority_queue.h" | 50 #include "net/base/priority_queue.h" |
| 51 #include "net/base/request_priority.h" | 51 #include "net/base/request_priority.h" |
| 52 #include "net/log/net_log_with_source.h" | 52 #include "net/log/net_log_with_source.h" |
| 53 #include "net/socket/client_socket_handle.h" | 53 #include "net/socket/client_socket_handle.h" |
| 54 #include "net/socket/client_socket_pool.h" | 54 #include "net/socket/client_socket_pool.h" |
| 55 #include "net/socket/stream_socket.h" | 55 #include "net/socket/stream_socket.h" |
| 56 | 56 |
| 57 namespace base { | 57 namespace base { |
| 58 class DictionaryValue; | 58 class DictionaryValue; |
| 59 namespace trace_event { |
| 60 class MemoryAllocatorDump; |
| 61 } |
| 59 } | 62 } |
| 60 | 63 |
| 61 namespace net { | 64 namespace net { |
| 62 | 65 |
| 63 class ClientSocketHandle; | 66 class ClientSocketHandle; |
| 64 struct NetLogSource; | 67 struct NetLogSource; |
| 65 | 68 |
| 66 // ConnectJob provides an abstract interface for "connecting" a socket. | 69 // ConnectJob provides an abstract interface for "connecting" a socket. |
| 67 // The connection may involve host resolution, tcp connection, ssl connection, | 70 // The connection may involve host resolution, tcp connection, ssl connection, |
| 68 // etc. | 71 // etc. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 bool CloseOneIdleSocket(); | 334 bool CloseOneIdleSocket(); |
| 332 | 335 |
| 333 // Checks higher layered pools to see if they can close an idle connection. | 336 // Checks higher layered pools to see if they can close an idle connection. |
| 334 bool CloseOneIdleConnectionInHigherLayeredPool(); | 337 bool CloseOneIdleConnectionInHigherLayeredPool(); |
| 335 | 338 |
| 336 // See ClientSocketPool::GetInfoAsValue for documentation on this function. | 339 // See ClientSocketPool::GetInfoAsValue for documentation on this function. |
| 337 std::unique_ptr<base::DictionaryValue> GetInfoAsValue( | 340 std::unique_ptr<base::DictionaryValue> GetInfoAsValue( |
| 338 const std::string& name, | 341 const std::string& name, |
| 339 const std::string& type) const; | 342 const std::string& type) const; |
| 340 | 343 |
| 344 // Dumps memory allocation stats. |parent_dump| is the MemoryAllocatorDump of |
| 345 // the parent in the memory dump hierarchy. |
| 346 void DumpMemoryStats( |
| 347 base::trace_event::MemoryAllocatorDump* parent_dump) const; |
| 348 |
| 341 base::TimeDelta ConnectionTimeout() const { | 349 base::TimeDelta ConnectionTimeout() const { |
| 342 return connect_job_factory_->ConnectionTimeout(); | 350 return connect_job_factory_->ConnectionTimeout(); |
| 343 } | 351 } |
| 344 | 352 |
| 345 static bool connect_backup_jobs_enabled(); | 353 static bool connect_backup_jobs_enabled(); |
| 346 static bool set_connect_backup_jobs_enabled(bool enabled); | 354 static bool set_connect_backup_jobs_enabled(bool enabled); |
| 347 | 355 |
| 348 void EnableConnectBackupJobs(); | 356 void EnableConnectBackupJobs(); |
| 349 | 357 |
| 350 // ConnectJob::Delegate methods: | 358 // ConnectJob::Delegate methods: |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 | 794 |
| 787 int IdleSocketCountInGroup(const std::string& group_name) const { | 795 int IdleSocketCountInGroup(const std::string& group_name) const { |
| 788 return helper_.IdleSocketCountInGroup(group_name); | 796 return helper_.IdleSocketCountInGroup(group_name); |
| 789 } | 797 } |
| 790 | 798 |
| 791 LoadState GetLoadState(const std::string& group_name, | 799 LoadState GetLoadState(const std::string& group_name, |
| 792 const ClientSocketHandle* handle) const { | 800 const ClientSocketHandle* handle) const { |
| 793 return helper_.GetLoadState(group_name, handle); | 801 return helper_.GetLoadState(group_name, handle); |
| 794 } | 802 } |
| 795 | 803 |
| 804 void DumpMemoryStats(base::trace_event::MemoryAllocatorDump* dump) const { |
| 805 return helper_.DumpMemoryStats(dump); |
| 806 } |
| 807 |
| 796 virtual void OnConnectJobComplete(int result, ConnectJob* job) { | 808 virtual void OnConnectJobComplete(int result, ConnectJob* job) { |
| 797 return helper_.OnConnectJobComplete(result, job); | 809 return helper_.OnConnectJobComplete(result, job); |
| 798 } | 810 } |
| 799 | 811 |
| 800 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { | 812 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { |
| 801 return helper_.NumUnassignedConnectJobsInGroup(group_name); | 813 return helper_.NumUnassignedConnectJobsInGroup(group_name); |
| 802 } | 814 } |
| 803 | 815 |
| 804 int NumConnectJobsInGroup(const std::string& group_name) const { | 816 int NumConnectJobsInGroup(const std::string& group_name) const { |
| 805 return helper_.NumConnectJobsInGroup(group_name); | 817 return helper_.NumConnectJobsInGroup(group_name); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 }; | 880 }; |
| 869 | 881 |
| 870 internal::ClientSocketPoolBaseHelper helper_; | 882 internal::ClientSocketPoolBaseHelper helper_; |
| 871 | 883 |
| 872 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 884 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 873 }; | 885 }; |
| 874 | 886 |
| 875 } // namespace net | 887 } // namespace net |
| 876 | 888 |
| 877 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 889 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |