OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 namespace internal { | 150 namespace internal { |
151 | 151 |
152 // ClientSocketPoolBaseHelper is an internal class that implements almost all | 152 // ClientSocketPoolBaseHelper is an internal class that implements almost all |
153 // the functionality from ClientSocketPoolBase without using templates. | 153 // the functionality from ClientSocketPoolBase without using templates. |
154 // ClientSocketPoolBase adds templated definitions built on top of | 154 // ClientSocketPoolBase adds templated definitions built on top of |
155 // ClientSocketPoolBaseHelper. This class is not for external use, please use | 155 // ClientSocketPoolBaseHelper. This class is not for external use, please use |
156 // ClientSocketPoolBase instead. | 156 // ClientSocketPoolBase instead. |
157 class ClientSocketPoolBaseHelper | 157 class ClientSocketPoolBaseHelper |
158 : public ConnectJob::Delegate, | 158 : public ConnectJob::Delegate, |
159 public NetworkChangeNotifier::Observer { | 159 public NetworkChangeNotifier::IPAddressObserver { |
160 public: | 160 public: |
161 typedef uint32 Flags; | 161 typedef uint32 Flags; |
162 | 162 |
163 // Used to specify specific behavior for the ClientSocketPool. | 163 // Used to specify specific behavior for the ClientSocketPool. |
164 enum Flag { | 164 enum Flag { |
165 NORMAL = 0, // Normal behavior. | 165 NORMAL = 0, // Normal behavior. |
166 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 166 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
167 }; | 167 }; |
168 | 168 |
169 class Request { | 169 class Request { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 base::TimeDelta ConnectionTimeout() const { | 282 base::TimeDelta ConnectionTimeout() const { |
283 return connect_job_factory_->ConnectionTimeout(); | 283 return connect_job_factory_->ConnectionTimeout(); |
284 } | 284 } |
285 | 285 |
286 static void set_connect_backup_jobs_enabled(bool enabled); | 286 static void set_connect_backup_jobs_enabled(bool enabled); |
287 void EnableConnectBackupJobs(); | 287 void EnableConnectBackupJobs(); |
288 | 288 |
289 // ConnectJob::Delegate methods: | 289 // ConnectJob::Delegate methods: |
290 virtual void OnConnectJobComplete(int result, ConnectJob* job); | 290 virtual void OnConnectJobComplete(int result, ConnectJob* job); |
291 | 291 |
292 // NetworkChangeNotifier::Observer methods: | 292 // NetworkChangeNotifier::IPAddressObserver methods: |
293 virtual void OnIPAddressChanged(); | 293 virtual void OnIPAddressChanged(); |
294 | 294 |
295 private: | 295 private: |
296 friend class base::RefCounted<ClientSocketPoolBaseHelper>; | 296 friend class base::RefCounted<ClientSocketPoolBaseHelper>; |
297 | 297 |
298 // Entry for a persistent socket which became idle at time |start_time|. | 298 // Entry for a persistent socket which became idle at time |start_time|. |
299 struct IdleSocket { | 299 struct IdleSocket { |
300 IdleSocket() : socket(NULL) {} | 300 IdleSocket() : socket(NULL) {} |
301 | 301 |
302 // An idle socket should be removed if it can't be reused, or has been idle | 302 // An idle socket should be removed if it can't be reused, or has been idle |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 // Histograms for the pool | 737 // Histograms for the pool |
738 ClientSocketPoolHistograms* const histograms_; | 738 ClientSocketPoolHistograms* const histograms_; |
739 internal::ClientSocketPoolBaseHelper helper_; | 739 internal::ClientSocketPoolBaseHelper helper_; |
740 | 740 |
741 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 741 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
742 }; | 742 }; |
743 | 743 |
744 } // namespace net | 744 } // namespace net |
745 | 745 |
746 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 746 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |