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 ProcessMemoryDump; |
| 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_absolute_name| is the name |
| 345 // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
| 346 void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 347 const std::string& parent_dump_absolute_name) 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::ProcessMemoryDump* pmd, |
| 805 const std::string& parent_dump_absolute_name) const { |
| 806 return helper_.DumpMemoryStats(pmd, parent_dump_absolute_name); |
| 807 } |
| 808 |
796 virtual void OnConnectJobComplete(int result, ConnectJob* job) { | 809 virtual void OnConnectJobComplete(int result, ConnectJob* job) { |
797 return helper_.OnConnectJobComplete(result, job); | 810 return helper_.OnConnectJobComplete(result, job); |
798 } | 811 } |
799 | 812 |
800 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { | 813 int NumUnassignedConnectJobsInGroup(const std::string& group_name) const { |
801 return helper_.NumUnassignedConnectJobsInGroup(group_name); | 814 return helper_.NumUnassignedConnectJobsInGroup(group_name); |
802 } | 815 } |
803 | 816 |
804 int NumConnectJobsInGroup(const std::string& group_name) const { | 817 int NumConnectJobsInGroup(const std::string& group_name) const { |
805 return helper_.NumConnectJobsInGroup(group_name); | 818 return helper_.NumConnectJobsInGroup(group_name); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 }; | 881 }; |
869 | 882 |
870 internal::ClientSocketPoolBaseHelper helper_; | 883 internal::ClientSocketPoolBaseHelper helper_; |
871 | 884 |
872 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 885 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
873 }; | 886 }; |
874 | 887 |
875 } // namespace net | 888 } // namespace net |
876 | 889 |
877 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 890 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |