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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 }; | 212 }; |
213 | 213 |
214 ClientSocketPoolBaseHelper( | 214 ClientSocketPoolBaseHelper( |
215 HigherLayeredPool* pool, | 215 HigherLayeredPool* pool, |
216 int max_sockets, | 216 int max_sockets, |
217 int max_sockets_per_group, | 217 int max_sockets_per_group, |
218 base::TimeDelta unused_idle_socket_timeout, | 218 base::TimeDelta unused_idle_socket_timeout, |
219 base::TimeDelta used_idle_socket_timeout, | 219 base::TimeDelta used_idle_socket_timeout, |
220 ConnectJobFactory* connect_job_factory); | 220 ConnectJobFactory* connect_job_factory); |
221 | 221 |
222 virtual ~ClientSocketPoolBaseHelper(); | 222 ~ClientSocketPoolBaseHelper() override; |
223 | 223 |
224 // Adds a lower layered pool to |this|, and adds |this| as a higher layered | 224 // Adds a lower layered pool to |this|, and adds |this| as a higher layered |
225 // pool on top of |lower_pool|. | 225 // pool on top of |lower_pool|. |
226 void AddLowerLayeredPool(LowerLayeredPool* lower_pool); | 226 void AddLowerLayeredPool(LowerLayeredPool* lower_pool); |
227 | 227 |
228 // See LowerLayeredPool::IsStalled for documentation on this function. | 228 // See LowerLayeredPool::IsStalled for documentation on this function. |
229 bool IsStalled() const; | 229 bool IsStalled() const; |
230 | 230 |
231 // See LowerLayeredPool for documentation on these functions. It is expected | 231 // See LowerLayeredPool for documentation on these functions. It is expected |
232 // in the destructor that no higher layer pools remain. | 232 // in the destructor that no higher layer pools remain. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 base::TimeDelta ConnectionTimeout() const { | 320 base::TimeDelta ConnectionTimeout() const { |
321 return connect_job_factory_->ConnectionTimeout(); | 321 return connect_job_factory_->ConnectionTimeout(); |
322 } | 322 } |
323 | 323 |
324 static bool connect_backup_jobs_enabled(); | 324 static bool connect_backup_jobs_enabled(); |
325 static bool set_connect_backup_jobs_enabled(bool enabled); | 325 static bool set_connect_backup_jobs_enabled(bool enabled); |
326 | 326 |
327 void EnableConnectBackupJobs(); | 327 void EnableConnectBackupJobs(); |
328 | 328 |
329 // ConnectJob::Delegate methods: | 329 // ConnectJob::Delegate methods: |
330 virtual void OnConnectJobComplete(int result, ConnectJob* job) override; | 330 void OnConnectJobComplete(int result, ConnectJob* job) override; |
331 | 331 |
332 // NetworkChangeNotifier::IPAddressObserver methods: | 332 // NetworkChangeNotifier::IPAddressObserver methods: |
333 virtual void OnIPAddressChanged() override; | 333 void OnIPAddressChanged() override; |
334 | 334 |
335 private: | 335 private: |
336 friend class base::RefCounted<ClientSocketPoolBaseHelper>; | 336 friend class base::RefCounted<ClientSocketPoolBaseHelper>; |
337 | 337 |
338 // Entry for a persistent socket which became idle at time |start_time|. | 338 // Entry for a persistent socket which became idle at time |start_time|. |
339 struct IdleSocket { | 339 struct IdleSocket { |
340 IdleSocket() : socket(NULL) {} | 340 IdleSocket() : socket(NULL) {} |
341 | 341 |
342 // An idle socket can't be used if it is disconnected or has been used | 342 // An idle socket can't be used if it is disconnected or has been used |
343 // before and has received data unexpectedly (hence no longer idle). The | 343 // before and has received data unexpectedly (hence no longer idle). The |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 // Histograms for the pool | 869 // Histograms for the pool |
870 ClientSocketPoolHistograms* const histograms_; | 870 ClientSocketPoolHistograms* const histograms_; |
871 internal::ClientSocketPoolBaseHelper helper_; | 871 internal::ClientSocketPoolBaseHelper helper_; |
872 | 872 |
873 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 873 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
874 }; | 874 }; |
875 | 875 |
876 } // namespace net | 876 } // namespace net |
877 | 877 |
878 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 878 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |