OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 public NetworkChangeNotifier::IPAddressObserver { | 160 public NetworkChangeNotifier::IPAddressObserver { |
161 public: | 161 public: |
162 typedef uint32 Flags; | 162 typedef uint32 Flags; |
163 | 163 |
164 // Used to specify specific behavior for the ClientSocketPool. | 164 // Used to specify specific behavior for the ClientSocketPool. |
165 enum Flag { | 165 enum Flag { |
166 NORMAL = 0, // Normal behavior. | 166 NORMAL = 0, // Normal behavior. |
167 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 167 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
168 }; | 168 }; |
169 | 169 |
| 170 enum ClientSocketReusePolicy { |
| 171 USE_WARMEST_SOCKET = 0, |
| 172 USE_WARM_SOCKET = 1, |
| 173 USE_LAST_ACCESSED_SOCKET = 2, |
| 174 }; |
| 175 |
170 class NET_TEST Request { | 176 class NET_TEST Request { |
171 public: | 177 public: |
172 Request(ClientSocketHandle* handle, | 178 Request(ClientSocketHandle* handle, |
173 CompletionCallback* callback, | 179 CompletionCallback* callback, |
174 RequestPriority priority, | 180 RequestPriority priority, |
175 bool ignore_limits, | 181 bool ignore_limits, |
176 Flags flags, | 182 Flags flags, |
177 const BoundNetLog& net_log); | 183 const BoundNetLog& net_log); |
178 | 184 |
179 virtual ~Request(); | 185 virtual ~Request(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 DictionaryValue* GetInfoAsValue(const std::string& name, | 289 DictionaryValue* GetInfoAsValue(const std::string& name, |
284 const std::string& type) const; | 290 const std::string& type) const; |
285 | 291 |
286 base::TimeDelta ConnectionTimeout() const { | 292 base::TimeDelta ConnectionTimeout() const { |
287 return connect_job_factory_->ConnectionTimeout(); | 293 return connect_job_factory_->ConnectionTimeout(); |
288 } | 294 } |
289 | 295 |
290 static bool connect_backup_jobs_enabled(); | 296 static bool connect_backup_jobs_enabled(); |
291 static bool set_connect_backup_jobs_enabled(bool enabled); | 297 static bool set_connect_backup_jobs_enabled(bool enabled); |
292 | 298 |
| 299 // Sets the client socket reuse policy (using warmest socket vs. last accessed |
| 300 // socket). |
| 301 // NOTE: 'policy' should be a valid ClientSocketReusePolicy enum value. |
| 302 static double SetSocketReusePolicy(int policy); |
| 303 |
293 void EnableConnectBackupJobs(); | 304 void EnableConnectBackupJobs(); |
294 | 305 |
295 // ConnectJob::Delegate methods: | 306 // ConnectJob::Delegate methods: |
296 virtual void OnConnectJobComplete(int result, ConnectJob* job); | 307 virtual void OnConnectJobComplete(int result, ConnectJob* job); |
297 | 308 |
298 // NetworkChangeNotifier::IPAddressObserver methods: | 309 // NetworkChangeNotifier::IPAddressObserver methods: |
299 virtual void OnIPAddressChanged(); | 310 virtual void OnIPAddressChanged(); |
300 | 311 |
301 private: | 312 private: |
302 friend class base::RefCounted<ClientSocketPoolBaseHelper>; | 313 friend class base::RefCounted<ClientSocketPoolBaseHelper>; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 // Histograms for the pool | 757 // Histograms for the pool |
747 ClientSocketPoolHistograms* const histograms_; | 758 ClientSocketPoolHistograms* const histograms_; |
748 internal::ClientSocketPoolBaseHelper helper_; | 759 internal::ClientSocketPoolBaseHelper helper_; |
749 | 760 |
750 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 761 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
751 }; | 762 }; |
752 | 763 |
753 } // namespace net | 764 } // namespace net |
754 | 765 |
755 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 766 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |