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

Unified Diff: net/socket/client_socket_pool_base.h

Issue 8526006: Close idle sockets next time we are about to send data. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base.cc » ('j') | net/socket/client_socket_pool_base.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool_base.h
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 9e46e5eabd885c7f9c541b7b5b8b760ad2ddecf8..5934e23ea1d01bac9c2248cc3ff6e78aa36e2f43 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -316,6 +316,14 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
// NetworkChangeNotifier::IPAddressObserver methods:
virtual void OnIPAddressChanged();
+ // Called to enable/disable cleaning up idle sockets. When enabled,
+ // idle sockets that has been around for longer than a period
mmenke 2011/11/11 03:33:01 nit: Maybe 'idle sockets that have been around to
selim 2011/11/11 19:30:58 done
+ // are cleaned up using a timer. Otherwise they are closed next time
+ // client makes a request. This may reduce network activity and power
+ // consumption.
+ bool cleanup_timer_enabled();
mmenke 2011/11/11 03:33:01 Put these functions in the same location relative
mmenke 2011/11/11 03:33:01 nit: Use const whenever appropriate.
selim 2011/11/11 19:30:58 done
selim 2011/11/11 19:30:58 done
+ void set_cleanup_timer_enabled( bool enabled );
mmenke 2011/11/11 03:33:01 Since this is more than a simple setter, use SetCl
mmenke 2011/11/11 03:33:01 nit: Google style is "(bool enabled)". See http:
selim 2011/11/11 19:30:58 done
+
private:
friend class base::RefCounted<ClientSocketPoolBaseHelper>;
@@ -442,6 +450,9 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
void IncrementIdleCount();
void DecrementIdleCount();
+ // Start cleanup timer for idle sockets.
+ void startIdleSocketTimer();
mmenke 2011/11/11 03:33:01 nit: Google style is "StartIdleSocketTimer()". S
selim 2011/11/11 19:30:58 done
+
// Scans the group map for groups which have an available socket slot and
// at least one pending request. Returns true if any groups are stalled, and
// if so, fills |group| and |group_name| with data of the stalled group
@@ -552,6 +563,9 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
// The maximum number of sockets kept per group.
const int max_sockets_per_group_;
+ // Whether to use timer to cleanup idle sockets.
+ bool use_cleanup_timer_;
+
// The time to wait until closing idle sockets.
const base::TimeDelta unused_idle_socket_timeout_;
const base::TimeDelta used_idle_socket_timeout_;
@@ -705,6 +719,14 @@ class ClientSocketPoolBase {
return helper_.HasGroup(group_name);
}
+ bool cleanup_timer_enabled() {
mmenke 2011/11/11 03:33:01 nit: const
selim 2011/11/11 19:30:58 done
+ return helper_.cleanup_timer_enabled();
+ }
+
+ void set_cleanup_timer_enabled( bool enabled ) {
mmenke 2011/11/11 03:33:01 nit: Google style is "(bool enabled)"
selim 2011/11/11 19:30:58 done
+ return helper_.set_cleanup_timer_enabled( enabled );
mmenke 2011/11/11 03:33:01 nit: Google style is "(enabled)"
selim 2011/11/11 19:30:58 done
+ }
+
void CleanupIdleSockets(bool force) {
return helper_.CleanupIdleSockets(force);
}
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base.cc » ('j') | net/socket/client_socket_pool_base.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698