summaryrefslogtreecommitdiffstats
path: root/chrome/browser
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 /chrome/browser
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 'chrome/browser')
-rw-r--r--chrome/browser/dom_ui/net_internals_ui.cc32
-rw-r--r--chrome/browser/resources/net_internals/index.html23
-rw-r--r--chrome/browser/resources/net_internals/main.css3
-rw-r--r--chrome/browser/resources/net_internals/main.js27
-rw-r--r--chrome/browser/resources/net_internals/socketsview.js93
-rw-r--r--chrome/browser/resources/net_internals/util.js13
6 files changed, 186 insertions, 5 deletions
diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc
index 7158dd4..1e8ec4b 100644
--- a/chrome/browser/dom_ui/net_internals_ui.cc
+++ b/chrome/browser/dom_ui/net_internals_ui.cc
@@ -43,7 +43,13 @@
#include "net/base/sys_addrinfo.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_cache.h"
+#include "net/http/http_network_layer.h"
+#include "net/http/http_network_session.h"
+#include "net/http/http_proxy_client_socket_pool.h"
#include "net/proxy/proxy_service.h"
+#include "net/socket/socks_client_socket_pool.h"
+#include "net/socket/ssl_client_socket_pool.h"
+#include "net/socket/tcp_client_socket_pool.h"
#include "net/url_request/url_request_context.h"
namespace {
@@ -77,6 +83,15 @@ disk_cache::Backend* GetDiskCacheBackend(URLRequestContext* context) {
return http_cache->GetCurrentBackend();
}
+// Returns the http network session for |context| if there is one.
+// Otherwise, returns NULL.
+net::HttpNetworkSession* GetHttpNetworkSession(URLRequestContext* context) {
+ if (!context->http_transaction_factory())
+ return NULL;
+
+ return context->http_transaction_factory()->GetSession();
+}
+
Value* ExperimentToValue(const ConnectionTester::Experiment& experiment) {
DictionaryValue* dict = new DictionaryValue();
@@ -194,6 +209,7 @@ class NetInternalsMessageHandler::IOThreadImpl
void OnGetPassiveLogEntries(const ListValue* list);
void OnStartConnectionTests(const ListValue* list);
void OnGetHttpCacheInfo(const ListValue* list);
+ void OnGetSocketPoolInfo(const ListValue* list);
// ChromeNetLog::Observer implementation:
virtual void OnAddEntry(net::NetLog::EventType type,
@@ -374,6 +390,9 @@ void NetInternalsMessageHandler::RegisterMessages() {
dom_ui_->RegisterMessageCallback(
"getHttpCacheInfo",
proxy_->CreateCallback(&IOThreadImpl::OnGetHttpCacheInfo));
+ dom_ui_->RegisterMessageCallback(
+ "getSocketPoolInfo",
+ proxy_->CreateCallback(&IOThreadImpl::OnGetSocketPoolInfo));
}
void NetInternalsMessageHandler::CallJavascriptFunction(
@@ -559,6 +578,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady(
OnGetBadProxies(NULL);
OnGetHostResolverCache(NULL);
OnGetHttpCacheInfo(NULL);
+ OnGetSocketPoolInfo(NULL);
}
void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings(
@@ -746,6 +766,18 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo(
CallJavascriptFunction(L"g_browser.receivedHttpCacheInfo", info_dict);
}
+void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo(
+ const ListValue* list) {
+ net::HttpNetworkSession *http_network_session =
+ GetHttpNetworkSession(context_getter_->GetURLRequestContext());
+
+ Value *socket_pool_info = NULL;
+ if (http_network_session)
+ socket_pool_info = http_network_session->SocketPoolInfoToValue();
+
+ CallJavascriptFunction(L"g_browser.receivedSocketPoolInfo", socket_pool_info);
+}
+
void NetInternalsMessageHandler::IOThreadImpl::OnAddEntry(
net::NetLog::EventType type,
const base::TimeTicks& time,
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index 86e1aa6..764af97 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -23,6 +23,7 @@ found in the LICENSE file.
<script src="logviewpainter.js"></script>
<script src="loggrouper.js"></script>
<script src="proxyview.js"></script>
+ <script src="socketsview.js"></script>
</head>
<body onload="onLoaded()">
<!-- Tab switcher for main categories. -->
@@ -103,8 +104,26 @@ found in the LICENSE file.
</tbody>
</table>
</div>
- <!-- Sections TODO -->
- <div id=socketsTabContent>TODO: display socket information (outstanding connect jobs)</div>
+ <div id=socketsTabContent>
+ <h4>Socket pools</h4>
+ <table class="styledTable">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Handed Out</th>
+ <th>Connecting</th>
+ <th>Idle</th>
+ <th>Max</th>
+ <th>Max Per Group</th>
+ <th>Generation Number</th>
+ </tr>
+ </thead>
+ <tbody id=socketTabTbody>
+ </tbody>
+ </table>
+ <div id=socketPoolGroupsDiv>
+ </div>
+ </div>
<div id=httpCacheTabContent>
<h4>Entries</h4>
<a href="chrome://view-http-cache" target=_blank>Explore cache entries</a>
diff --git a/chrome/browser/resources/net_internals/main.css b/chrome/browser/resources/net_internals/main.css
index 13b22b2..69e318b 100644
--- a/chrome/browser/resources/net_internals/main.css
+++ b/chrome/browser/resources/net_internals/main.css
@@ -201,6 +201,7 @@ body {
#proxyTabContent,
#dataTabContent,
#dnsTabContent,
+#socketsTabContent,
#testTabContent {
overflow: auto;
padding: 10px;
@@ -222,6 +223,8 @@ table.styledTable,
.styledTable th,
.styledTable td {
border: 1px solid #777;
+ padding-right: 4px;
+ padding-left: 4px;
}
.styledTable th {
diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js
index 03f48083..187a341 100644
--- a/chrome/browser/resources/net_internals/main.js
+++ b/chrome/browser/resources/net_internals/main.js
@@ -77,6 +77,10 @@ function onLoaded() {
var httpCacheView = new HttpCacheView("httpCacheTabContent",
"httpCacheStats");
+ var socketsView = new SocketsView("socketsTabContent",
+ "socketTabTbody",
+ "socketPoolGroupsDiv");
+
// Create a view which lets you tab between the different sub-views.
var categoryTabSwitcher =
new TabSwitcherView(new DivView('categoryTabHandles'));
@@ -85,8 +89,7 @@ function onLoaded() {
categoryTabSwitcher.addTab('requestsTab', requestsView, false);
categoryTabSwitcher.addTab('proxyTab', proxyView, false);
categoryTabSwitcher.addTab('dnsTab', dnsView, false);
- categoryTabSwitcher.addTab('socketsTab', new DivView('socketsTabContent'),
- false);
+ categoryTabSwitcher.addTab('socketsTab', socketsView, false);
categoryTabSwitcher.addTab('httpCacheTab', httpCacheView, false);
categoryTabSwitcher.addTab('dataTab', dataView, false);
categoryTabSwitcher.addTab('testTab', testView, false);
@@ -136,6 +139,7 @@ function BrowserBridge() {
this.httpCacheInfo_ = new PollableDataHelper('onHttpCacheInfoChanged');
this.hostResolverCache_ =
new PollableDataHelper('onHostResolverCacheChanged');
+ this.socketPoolInfo_ = new PollableDataHelper('onSocketPoolInfoChanged');
// Cache of the data received.
// TODO(eroman): the controls to clear data in the "Requests" tab should be
@@ -198,6 +202,10 @@ BrowserBridge.prototype.sendGetHttpCacheInfo = function() {
chrome.send('getHttpCacheInfo');
};
+BrowserBridge.prototype.sendGetSocketPoolInfo = function() {
+ chrome.send('getSocketPoolInfo');
+};
+
//------------------------------------------------------------------------------
// Messages received from the browser
//------------------------------------------------------------------------------
@@ -256,6 +264,10 @@ function(hostResolverCache) {
this.hostResolverCache_.update(hostResolverCache);
};
+BrowserBridge.prototype.receivedSocketPoolInfo = function(socketPoolInfo) {
+ this.socketPoolInfo_.update(socketPoolInfo);
+};
+
BrowserBridge.prototype.receivedPassiveLogEntries = function(entries) {
this.passivelyCapturedEvents_ =
this.passivelyCapturedEvents_.concat(entries);
@@ -364,6 +376,16 @@ BrowserBridge.prototype.addHostResolverCacheObserver = function(observer) {
};
/**
+ * Adds a listener of the socket pool. |observer| will be called back
+ * when data is received, through:
+ *
+ * observer.onSocketPoolInfoChanged(socketPoolInfo)
+ */
+BrowserBridge.prototype.addSocketPoolInfoObserver = function(observer) {
+ this.socketPoolInfo_.addObserver(observer);
+};
+
+/**
* Adds a listener for the progress of the connection tests.
* The observer will be called back with:
*
@@ -426,6 +448,7 @@ BrowserBridge.prototype.doPolling_ = function() {
this.sendGetBadProxies();
this.sendGetHostResolverCache();
this.sendGetHttpCacheInfo();
+ this.sendGetSocketPoolInfo();
};
/**
diff --git a/chrome/browser/resources/net_internals/socketsview.js b/chrome/browser/resources/net_internals/socketsview.js
new file mode 100644
index 0000000..37e7fce
--- /dev/null
+++ b/chrome/browser/resources/net_internals/socketsview.js
@@ -0,0 +1,93 @@
+// 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.
+
+/**
+ * This view displays information on the state of all socket pools.
+ *
+ * - Shows a summary of the state of each socket pool at the top.
+ * - For each pool with allocated sockets or connect jobs, shows all its
+ * groups with any allocated sockets.
+ *
+ * @constructor
+ */
+function SocketsView(mainBoxId, socketPoolsTbodyId, socketPoolGroupsDivId) {
+ DivView.call(this, mainBoxId);
+
+ g_browser.addSocketPoolInfoObserver(this);
+ this.socketPoolsTbody_ = document.getElementById(socketPoolsTbodyId);
+ this.socketPoolGroupsDiv_ = document.getElementById(socketPoolGroupsDivId);
+}
+
+inherits(SocketsView, DivView);
+
+SocketsView.prototype.onSocketPoolInfoChanged = function(socketPoolInfo) {
+ this.socketPoolsTbody_.innerHTML = '';
+ this.socketPoolGroupsDiv_.innerHTML = '';
+
+ if (!socketPoolInfo)
+ return;
+
+ for (var i = 0; i < socketPoolInfo.length; ++i) {
+ this.addSocketPool_(socketPoolInfo[i]);
+ }
+};
+
+// Adds the socket pool to the bottom of the main table and, if there are
+// any groups, creates a table at the bottom listing those as well.
+SocketsView.prototype.addSocketPool_ = function(socketPool) {
+ var socketPoolRow = addNode(this.socketPoolsTbody_, 'tr');
+
+ var socketPoolName = socketPool.name;
+ if (socketPoolName != socketPool.type)
+ socketPoolName += ' (' + socketPool.type + ')';
+
+ addNodeWithText(socketPoolRow, 'td', socketPoolName);
+ addNodeWithText(socketPoolRow, 'td', socketPool.connecting_socket_count);
+ addNodeWithText(socketPoolRow, 'td', socketPool.handed_out_socket_count);
+ addNodeWithText(socketPoolRow, 'td', socketPool.idle_socket_count);
+ addNodeWithText(socketPoolRow, 'td', socketPool.max_socket_count);
+ addNodeWithText(socketPoolRow, 'td', socketPool.max_sockets_per_group);
+ addNodeWithText(socketPoolRow, 'td', socketPool.pool_generation_number);
+
+ if (socketPool.groups != undefined)
+ this.addSocketPoolGroupTable_(socketPoolName, socketPool);
+};
+
+// Creates a table at the bottom listing all a table's groups.
+SocketsView.prototype.addSocketPoolGroupTable_ = function(socketPoolName,
+ socketPool) {
+ addNodeWithText(this.socketPoolGroupsDiv_, 'h4', socketPoolName);
+ var table = addNode(this.socketPoolGroupsDiv_, 'table');
+ table.setAttribute('class', 'styledTable');
+
+ var thead = addNode(table, 'thead');
+ var headerRow = addNode(thead, 'tr');
+ addNodeWithText(headerRow, 'th', 'Name');
+ addNodeWithText(headerRow, 'th', 'Pending');
+ addNodeWithText(headerRow, 'th', 'Top Priority');
+ addNodeWithText(headerRow, 'th', 'Active');
+ addNodeWithText(headerRow, 'th', 'Idle');
+ addNodeWithText(headerRow, 'th', 'Connect Jobs');
+ addNodeWithText(headerRow, 'th', 'Backup Job');
+ addNodeWithText(headerRow, 'th', 'Stalled');
+
+ var tbody = addNode(table, 'tbody');
+ for (var groupName in socketPool.groups) {
+ var group = socketPool.groups[groupName];
+ var tr = addNode(tbody, 'tr');
+
+ addNodeWithText(tr, 'td', groupName);
+ addNodeWithText(tr, 'td', group.pending_request_count);
+ if (group.top_pending_priority != undefined)
+ addNodeWithText(tr, 'td', group.top_pending_priority);
+ else
+ addNodeWithText(tr, 'td', '-');
+ addNodeWithText(tr, 'td', group.active_socket_count);
+ addNodeWithText(tr, 'td', group.idle_socket_count);
+ addNodeWithText(tr, 'td', group.connect_job_count);
+ addNodeWithText(tr, 'td', group.has_backup_job);
+ addNodeWithText(tr, 'td', group.is_stalled);
+ }
+};
+
diff --git a/chrome/browser/resources/net_internals/util.js b/chrome/browser/resources/net_internals/util.js
index 9190300..86284d0 100644
--- a/chrome/browser/resources/net_internals/util.js
+++ b/chrome/browser/resources/net_internals/util.js
@@ -66,7 +66,7 @@ function addNode(parentNode, tagName) {
}
/**
- * Adds text to node |parentNode|.
+ * Adds |text| to node |parentNode|.
*/
function addTextNode(parentNode, text) {
var textNode = parentNode.ownerDocument.createTextNode(text);
@@ -75,6 +75,17 @@ function addTextNode(parentNode, text) {
}
/**
+ * Adds a node to |parentNode|, of type |tagName|. Then adds
+ * |text| to the new node.
+ */
+function addNodeWithText(parentNode, tagName, text) {
+ var elem = parentNode.ownerDocument.createElement(tagName);
+ parentNode.appendChild(elem);
+ addTextNode(elem, text);
+ return elem;
+}
+
+/**
* Adds or removes a CSS class to |node|.
*/
function changeClassName(node, classNameToAddOrRemove, isAdd) {