summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorziadh@chromium.org <ziadh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-21 18:46:00 +0000
committerziadh@chromium.org <ziadh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-21 18:46:00 +0000
commit241c5c2c0e223f9bf3f5f38661d21c0a46bdfe59 (patch)
treeeb7b4d038bb311c094b3d882e4ac9ec52876bb5a /net
parent8974e04c6ef2c9fe849e17a4b2224d1b51f4001c (diff)
downloadchromium_src-241c5c2c0e223f9bf3f5f38661d21c0a46bdfe59.zip
chromium_src-241c5c2c0e223f9bf3f5f38661d21c0a46bdfe59.tar.gz
chromium_src-241c5c2c0e223f9bf3f5f38661d21c0a46bdfe59.tar.bz2
A/B test for determining a value for unused socket timeout. Currently the
timeout defaults to 10 seconds. Having this value set too low won't allow us to take advantage of idle sockets. Setting it to too high could possibly result in more ERR_CONNECT_RESETs, requiring one RTT to receive the RST packet and possibly another RTT to re-establish the connection. r=jar Review URL: http://codereview.chromium.org/2827016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50364 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/net.gyp1
-rw-r--r--net/socket/client_socket_pool.cc29
-rw-r--r--net/socket/client_socket_pool.h4
-rw-r--r--net/socket/client_socket_pool_base.h14
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc3
-rw-r--r--net/socket/socks_client_socket_pool.cc3
-rw-r--r--net/socket/tcp_client_socket_pool.cc3
7 files changed, 45 insertions, 12 deletions
diff --git a/net/net.gyp b/net/net.gyp
index a9c9455..e5914bb 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -440,6 +440,7 @@
'socket/client_socket_handle.cc',
'socket/client_socket_handle.h',
'socket/client_socket_pool.h',
+ 'socket/client_socket_pool.cc',
'socket/client_socket_pool_base.cc',
'socket/client_socket_pool_base.h',
'socket/client_socket_pool_histograms.cc',
diff --git a/net/socket/client_socket_pool.cc b/net/socket/client_socket_pool.cc
new file mode 100644
index 0000000..4cefe8d
--- /dev/null
+++ b/net/socket/client_socket_pool.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/socket/client_socket_pool.h"
+
+namespace {
+
+// The maximum duration, in seconds, to keep used idle persistent sockets
+// alive.
+// TODO(ziadh): Change this timeout after getting histogram data on how long it
+// should be.
+int g_unused_idle_socket_timeout = 10;
+
+} // namespace
+
+namespace net {
+
+// static
+int ClientSocketPool::unused_idle_socket_timeout() {
+ return g_unused_idle_socket_timeout;
+}
+
+// static
+void ClientSocketPool::set_unused_idle_socket_timeout(int timeout) {
+ g_unused_idle_socket_timeout = timeout;
+}
+
+} // namespace net
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h
index c5f6f16..807104e 100644
--- a/net/socket/client_socket_pool.h
+++ b/net/socket/client_socket_pool.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "base/time.h"
#include "base/template_util.h"
#include "net/base/completion_callback.h"
#include "net/base/host_resolver.h"
@@ -103,6 +104,9 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
// UMA_HISTOGRAM_* macros because they are callsite static.
virtual scoped_refptr<ClientSocketPoolHistograms> histograms() const = 0;
+ static int unused_idle_socket_timeout();
+ static void set_unused_idle_socket_timeout(int timeout);
+
protected:
ClientSocketPool() {}
virtual ~ClientSocketPool() {}
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 3e1de22..942142d 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -193,7 +193,7 @@ class ClientSocketPoolBaseHelper
// See ClientSocketPool::Flush for documentation on this function.
void Flush();
-
+
// See ClientSocketPool::CloseIdleSockets for documentation on this function.
void CloseIdleSockets();
@@ -450,11 +450,11 @@ class ClientSocketPoolBaseHelper
// selecting the highest priority request across *all* groups.
//
// |may_have_stalled_group_| is not conclusive, since when we cancel pending
- // requests, we may reach the situation where we have the maximum number of
+ // requests, we may reach the situation where we have the maximum number of
// sockets, but no request is stalled because of the global socket limit
// (although some requests may be blocked on the socket per group limit).
// We don't strictly maintain |may_have_stalled_group_|, since that would
- // require a linear search through all groups in |group_map_| to see if one
+ // require a linear search through all groups in |group_map_| to see if one
// of them is stalled.
bool may_have_stalled_group_;
@@ -476,11 +476,6 @@ class ClientSocketPoolBaseHelper
} // namespace internal
-// The maximum duration, in seconds, to keep unused idle persistent sockets
-// alive.
-// TODO(willchan): Change this timeout after getting histogram data on how
-// long it should be.
-static const int kUnusedIdleSocketTimeout = 10;
// The maximum duration, in seconds, to keep used idle persistent sockets alive.
static const int kUsedIdleSocketTimeout = 300; // 5 minutes
@@ -563,7 +558,8 @@ class ClientSocketPoolBase {
return helper_->CancelRequest(group_name, handle);
}
- void ReleaseSocket(const std::string& group_name, ClientSocket* socket, int id) {
+ void ReleaseSocket(const std::string& group_name, ClientSocket* socket,
+ int id) {
return helper_->ReleaseSocket(group_name, socket, id);
}
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 286949a..c9ad282 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -423,7 +423,8 @@ class ClientSocketPoolBaseTest : public ClientSocketPoolTest {
CreatePoolWithIdleTimeouts(
max_sockets,
max_sockets_per_group,
- base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout),
+ base::TimeDelta::FromSeconds(
+ ClientSocketPool::unused_idle_socket_timeout()),
base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout));
}
diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc
index ad924f8..455b671 100644
--- a/net/socket/socks_client_socket_pool.cc
+++ b/net/socket/socks_client_socket_pool.cc
@@ -166,7 +166,8 @@ SOCKSClientSocketPool::SOCKSClientSocketPool(
NetworkChangeNotifier* network_change_notifier,
NetLog* net_log)
: base_(max_sockets, max_sockets_per_group, histograms,
- base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout),
+ base::TimeDelta::FromSeconds(
+ ClientSocketPool::unused_idle_socket_timeout()),
base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout),
new SOCKSConnectJobFactory(tcp_pool, host_resolver, net_log),
network_change_notifier) {}
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index b798bc4..f2e9609 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -181,7 +181,8 @@ TCPClientSocketPool::TCPClientSocketPool(
NetworkChangeNotifier* network_change_notifier,
NetLog* net_log)
: base_(max_sockets, max_sockets_per_group, histograms,
- base::TimeDelta::FromSeconds(kUnusedIdleSocketTimeout),
+ base::TimeDelta::FromSeconds(
+ ClientSocketPool::unused_idle_socket_timeout()),
base::TimeDelta::FromSeconds(kUsedIdleSocketTimeout),
new TCPConnectJobFactory(client_socket_factory,
host_resolver, net_log),