summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 16:44:27 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 16:44:27 +0000
commit59d7a5ac32804bb1b12a2d5b8d21dede3f7be233 (patch)
tree25e69facf864a46c61a5466b7c9fa061a4417abe /net
parentb9a3dc3b7b9c1cb60a7aa05f38a568612e5224cb (diff)
downloadchromium_src-59d7a5ac32804bb1b12a2d5b8d21dede3f7be233.zip
chromium_src-59d7a5ac32804bb1b12a2d5b8d21dede3f7be233.tar.gz
chromium_src-59d7a5ac32804bb1b12a2d5b8d21dede3f7be233.tar.bz2
Sockets page on net-internals now displays some information about the current socket pool state. Table padding slightly increased for legibility.
TEST=manual BUG=39756 Review URL: http://codereview.chromium.org/3267002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_network_session.cc30
-rw-r--r--net/http/http_network_session.h4
-rw-r--r--net/http/http_proxy_client_socket_pool.h5
-rw-r--r--net/socket/client_socket_pool.h7
-rw-r--r--net/socket/client_socket_pool_base.cc42
-rw-r--r--net/socket/client_socket_pool_base.h8
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc5
-rw-r--r--net/socket/socks_client_socket_pool.h5
-rw-r--r--net/socket/ssl_client_socket_pool.h5
-rw-r--r--net/socket/tcp_client_socket_pool.h5
10 files changed, 116 insertions, 0 deletions
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index 93340ef..718d2cd 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -30,6 +30,18 @@ int g_max_sockets_per_group = 6;
// http://crbug.com/44501 for details about proxy server connection limits.
int g_max_sockets_per_proxy_server = 32;
+// Appends information about all |socket_pools| to the end of |list|.
+template <class MapType>
+static void AddSocketPoolsToList(ListValue* list,
+ const MapType& socket_pools,
+ const std::string& type) {
+ typename MapType::const_iterator socket_pool_it = socket_pools.begin();
+ for (typename MapType::const_iterator it = socket_pools.begin();
+ it != socket_pools.end(); it++) {
+ list->Append(it->second->GetInfoAsValue(it->first.ToString(), type));
+ }
+}
+
} // namespace
// TODO(mbelshe): Move the socket factories into HttpStreamFactory.
@@ -153,6 +165,24 @@ HttpNetworkSession::GetSocketPoolForSSLWithProxy(
return ret.first->second;
}
+Value* HttpNetworkSession::SocketPoolInfoToValue() const {
+ ListValue* list = new ListValue();
+ list->Append(tcp_socket_pool_->GetInfoAsValue("tcp_socket_pool",
+ "tcp_socket_pool"));
+ list->Append(ssl_socket_pool_->GetInfoAsValue("ssl_socket_pool",
+ "ssl_socket_pool"));
+ AddSocketPoolsToList(list,
+ http_proxy_socket_pools_,
+ "http_proxy_socket_pool");
+ AddSocketPoolsToList(list,
+ socks_socket_pools_,
+ "proxy_socket_pool");
+ AddSocketPoolsToList(list,
+ ssl_socket_pools_for_proxies_,
+ "ssl_socket_pool_for_proxies");
+ return list;
+}
+
// static
int HttpNetworkSession::max_sockets_per_group() {
return g_max_sockets_per_group;
diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h
index 9efcb9f..dd4c800 100644
--- a/net/http/http_network_session.h
+++ b/net/http/http_network_session.h
@@ -106,6 +106,10 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession>,
return http_stream_factory_;
}
+ // Creates a Value summary of the state of the socket pools. The caller is
+ // responsible for deleting the returned value.
+ Value* SocketPoolInfoToValue() const;
+
static int max_sockets_per_group();
static void set_max_sockets_per_group(int socket_count);
static void set_max_sockets_per_proxy_server(int socket_count);
diff --git a/net/http/http_proxy_client_socket_pool.h b/net/http/http_proxy_client_socket_pool.h
index c992cf0..8a16e22 100644
--- a/net/http/http_proxy_client_socket_pool.h
+++ b/net/http/http_proxy_client_socket_pool.h
@@ -175,6 +175,11 @@ class HttpProxyClientSocketPool : public ClientSocketPool {
virtual LoadState GetLoadState(const std::string& group_name,
const ClientSocketHandle* handle) const;
+ virtual Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const {
+ return base_.GetInfoAsValue(name, type);
+ }
+
virtual base::TimeDelta ConnectionTimeout() const {
return base_.ConnectionTimeout();
}
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h
index 1fff2b3..c748bba 100644
--- a/net/socket/client_socket_pool.h
+++ b/net/socket/client_socket_pool.h
@@ -18,6 +18,8 @@
#include "net/base/load_states.h"
#include "net/base/request_priority.h"
+class Value;
+
namespace net {
class ClientSocket;
@@ -103,6 +105,11 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
virtual LoadState GetLoadState(const std::string& group_name,
const ClientSocketHandle* handle) const = 0;
+ // Retrieves information on the current state of the pool as a Value. Caller
+ // takes possession of the returned value.
+ virtual Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const = 0;
+
// Returns the maximum amount of time to wait before retrying a connect.
static const int kMaxConnectRetryIntervalMs = 250;
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 631ef5e..49fa09e 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -395,6 +395,48 @@ LoadState ClientSocketPoolBaseHelper::GetLoadState(
return LOAD_STATE_IDLE;
}
+Value* ClientSocketPoolBaseHelper::GetInfoAsValue(
+ const std::string& name, const std::string& type) const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString("name", name);
+ dict->SetString("type", type);
+ dict->SetInteger("handed_out_socket_count", handed_out_socket_count_);
+ dict->SetInteger("connecting_socket_count", connecting_socket_count_);
+ dict->SetInteger("idle_socket_count", idle_socket_count_);
+ dict->SetInteger("max_socket_count", max_sockets_);
+ dict->SetInteger("max_sockets_per_group", max_sockets_per_group_);
+ dict->SetInteger("pool_generation_number", pool_generation_number_);
+
+ if (group_map_.empty())
+ return dict;
+
+ DictionaryValue* all_groups_dict = new DictionaryValue();
+ for (GroupMap::const_iterator it = group_map_.begin();
+ it != group_map_.end(); it++) {
+ const Group* group = it->second;
+ DictionaryValue* group_dict = new DictionaryValue();
+
+ group_dict->SetInteger("pending_request_count",
+ group->pending_requests().size());
+ if (!group->pending_requests().empty()) {
+ group_dict->SetInteger("top_pending_priority",
+ group->TopPendingPriority());
+ }
+
+ group_dict->SetInteger("active_socket_count", group->active_socket_count());
+ group_dict->SetInteger("idle_socket_count", group->idle_sockets().size());
+ group_dict->SetInteger("connect_job_count", group->jobs().size());
+
+ group_dict->SetBoolean("is_stalled",
+ group->IsStalled(max_sockets_per_group_));
+ group_dict->SetBoolean("has_backup_job", group->HasBackupJob());
+
+ all_groups_dict->SetWithoutPathExpansion(it->first, group_dict);
+ }
+ dict->Set("groups", all_groups_dict);
+ return dict;
+}
+
bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup(
base::TimeTicks now,
base::TimeDelta timeout) const {
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 0fbdf27..032ce38 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -237,6 +237,9 @@ class ClientSocketPoolBaseHelper
// sockets that timed out or can't be reused. Made public for testing.
void CleanupIdleSockets(bool force);
+ // See ClientSocketPool::GetInfoAsValue for documentation on this function.
+ Value* GetInfoAsValue(const std::string& name, const std::string& type) const;
+
base::TimeDelta ConnectionTimeout() const {
return connect_job_factory_->ConnectionTimeout();
}
@@ -601,6 +604,11 @@ class ClientSocketPoolBase {
return helper_->CleanupIdleSockets(force);
}
+ Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const {
+ return helper_->GetInfoAsValue(name, type);
+ }
+
base::TimeDelta ConnectionTimeout() const {
return helper_->ConnectionTimeout();
}
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 2a78fb1..ff67e3b 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -409,6 +409,11 @@ class TestClientSocketPool : public ClientSocketPool {
return base_.GetLoadState(group_name, handle);
}
+ virtual Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const {
+ return base_.GetInfoAsValue(name, type);
+ }
+
virtual base::TimeDelta ConnectionTimeout() const {
return base_.ConnectionTimeout();
}
diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h
index 3735aa3..418d38c 100644
--- a/net/socket/socks_client_socket_pool.h
+++ b/net/socket/socks_client_socket_pool.h
@@ -140,6 +140,11 @@ class SOCKSClientSocketPool : public ClientSocketPool {
virtual LoadState GetLoadState(const std::string& group_name,
const ClientSocketHandle* handle) const;
+ virtual Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const {
+ return base_.GetInfoAsValue(name, type);
+ }
+
virtual base::TimeDelta ConnectionTimeout() const {
return base_.ConnectionTimeout();
}
diff --git a/net/socket/ssl_client_socket_pool.h b/net/socket/ssl_client_socket_pool.h
index 0c8f90f..bd8c22c 100644
--- a/net/socket/ssl_client_socket_pool.h
+++ b/net/socket/ssl_client_socket_pool.h
@@ -209,6 +209,11 @@ class SSLClientSocketPool : public ClientSocketPool {
virtual LoadState GetLoadState(const std::string& group_name,
const ClientSocketHandle* handle) const;
+ virtual Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const {
+ return base_.GetInfoAsValue(name, type);
+ }
+
virtual base::TimeDelta ConnectionTimeout() const {
return base_.ConnectionTimeout();
}
diff --git a/net/socket/tcp_client_socket_pool.h b/net/socket/tcp_client_socket_pool.h
index 12f695d..132f0e2 100644
--- a/net/socket/tcp_client_socket_pool.h
+++ b/net/socket/tcp_client_socket_pool.h
@@ -149,6 +149,11 @@ class TCPClientSocketPool : public ClientSocketPool {
virtual LoadState GetLoadState(const std::string& group_name,
const ClientSocketHandle* handle) const;
+ virtual Value* GetInfoAsValue(const std::string& name,
+ const std::string& type) const {
+ return base_.GetInfoAsValue(name, type);
+ }
+
virtual base::TimeDelta ConnectionTimeout() const {
return base_.ConnectionTimeout();
}