| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 namespace internal { | 145 namespace internal { |
| 146 | 146 |
| 147 // ClientSocketPoolBaseHelper is an internal class that implements almost all | 147 // ClientSocketPoolBaseHelper is an internal class that implements almost all |
| 148 // the functionality from ClientSocketPoolBase without using templates. | 148 // the functionality from ClientSocketPoolBase without using templates. |
| 149 // ClientSocketPoolBase adds templated definitions built on top of | 149 // ClientSocketPoolBase adds templated definitions built on top of |
| 150 // ClientSocketPoolBaseHelper. This class is not for external use, please use | 150 // ClientSocketPoolBaseHelper. This class is not for external use, please use |
| 151 // ClientSocketPoolBase instead. | 151 // ClientSocketPoolBase instead. |
| 152 class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper | 152 class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper |
| 153 : public ConnectJob::Delegate, | 153 : public ConnectJob::Delegate, |
| 154 public NetworkChangeNotifier::IPAddressObserver { | 154 public NetworkChangeNotifier::NetworkChangeObserver { |
| 155 public: | 155 public: |
| 156 typedef uint32 Flags; | 156 typedef uint32 Flags; |
| 157 | 157 |
| 158 // Used to specify specific behavior for the ClientSocketPool. | 158 // Used to specify specific behavior for the ClientSocketPool. |
| 159 enum Flag { | 159 enum Flag { |
| 160 NORMAL = 0, // Normal behavior. | 160 NORMAL = 0, // Normal behavior. |
| 161 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 161 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 enum ClientSocketReusePolicy { | 164 enum ClientSocketReusePolicy { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 | 325 |
| 326 static bool connect_backup_jobs_enabled(); | 326 static bool connect_backup_jobs_enabled(); |
| 327 static bool set_connect_backup_jobs_enabled(bool enabled); | 327 static bool set_connect_backup_jobs_enabled(bool enabled); |
| 328 | 328 |
| 329 void EnableConnectBackupJobs(); | 329 void EnableConnectBackupJobs(); |
| 330 | 330 |
| 331 // ConnectJob::Delegate methods: | 331 // ConnectJob::Delegate methods: |
| 332 virtual void OnConnectJobComplete(int result, ConnectJob* job) OVERRIDE; | 332 virtual void OnConnectJobComplete(int result, ConnectJob* job) OVERRIDE; |
| 333 | 333 |
| 334 // NetworkChangeNotifier::IPAddressObserver methods: | 334 // NetworkChangeNotifier::NetworkChangeObserver methods: |
| 335 virtual void OnIPAddressChanged() OVERRIDE; | 335 virtual void OnNetworkChanged( |
| 336 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 336 | 337 |
| 337 private: | 338 private: |
| 338 friend class base::RefCounted<ClientSocketPoolBaseHelper>; | 339 friend class base::RefCounted<ClientSocketPoolBaseHelper>; |
| 339 | 340 |
| 340 // Entry for a persistent socket which became idle at time |start_time|. | 341 // Entry for a persistent socket which became idle at time |start_time|. |
| 341 struct IdleSocket { | 342 struct IdleSocket { |
| 342 IdleSocket() : socket(NULL) {} | 343 IdleSocket() : socket(NULL) {} |
| 343 | 344 |
| 344 // An idle socket should be removed if it can't be reused, or has been idle | 345 // An idle socket should be removed if it can't be reused, or has been idle |
| 345 // for too long. |now| is the current time value (TimeTicks::Now()). | 346 // for too long. |now| is the current time value (TimeTicks::Now()). |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 // Histograms for the pool | 815 // Histograms for the pool |
| 815 ClientSocketPoolHistograms* const histograms_; | 816 ClientSocketPoolHistograms* const histograms_; |
| 816 internal::ClientSocketPoolBaseHelper helper_; | 817 internal::ClientSocketPoolBaseHelper helper_; |
| 817 | 818 |
| 818 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 819 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 819 }; | 820 }; |
| 820 | 821 |
| 821 } // namespace net | 822 } // namespace net |
| 822 | 823 |
| 823 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 824 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |