Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: net/socket/client_socket_pool_base.h

Issue 6990036: Deciding best connection to schedule requests on based on cwnd and idle time (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: addressing comments Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 static double SetSocketReusePolicy(int policy);
Mike Belshe 2011/06/12 22:10:35 Instead of an int, you could use a ClientSocketReu
Gagan 2011/06/13 03:52:47 was doing that initially, but ran into problems in
302
293 void EnableConnectBackupJobs(); 303 void EnableConnectBackupJobs();
294 304
295 // ConnectJob::Delegate methods: 305 // ConnectJob::Delegate methods:
296 virtual void OnConnectJobComplete(int result, ConnectJob* job); 306 virtual void OnConnectJobComplete(int result, ConnectJob* job);
297 307
298 // NetworkChangeNotifier::IPAddressObserver methods: 308 // NetworkChangeNotifier::IPAddressObserver methods:
299 virtual void OnIPAddressChanged(); 309 virtual void OnIPAddressChanged();
300 310
301 private: 311 private:
302 friend class base::RefCounted<ClientSocketPoolBaseHelper>; 312 friend class base::RefCounted<ClientSocketPoolBaseHelper>;
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 group_name, *casted_request, delegate); 746 group_name, *casted_request, delegate);
737 } 747 }
738 748
739 virtual base::TimeDelta ConnectionTimeout() const { 749 virtual base::TimeDelta ConnectionTimeout() const {
740 return connect_job_factory_->ConnectionTimeout(); 750 return connect_job_factory_->ConnectionTimeout();
741 } 751 }
742 752
743 const scoped_ptr<ConnectJobFactory> connect_job_factory_; 753 const scoped_ptr<ConnectJobFactory> connect_job_factory_;
744 }; 754 };
745 755
756 void ApplySocketReuseGroup(int warmest_socket_trial_group,
757 const int* socket_policy);
746 // Histograms for the pool 758 // Histograms for the pool
747 ClientSocketPoolHistograms* const histograms_; 759 ClientSocketPoolHistograms* const histograms_;
748 internal::ClientSocketPoolBaseHelper helper_; 760 internal::ClientSocketPoolBaseHelper helper_;
749 761
750 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 762 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
751 }; 763 };
752 764
753 } // namespace net 765 } // namespace net
754 766
755 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 767 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698