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

Unified Diff: netlog_viewer/sockets_view.js

Issue 2154753002: Serving version 1 of the web app. All code has been copied from the (Closed) Base URL: https://github.com/catapult-project/catapult.git@gh-pages
Patch Set: Removed some unecessary files. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « netlog_viewer/sockets_view.html ('k') | netlog_viewer/source_entry.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: netlog_viewer/sockets_view.js
diff --git a/netlog_viewer/sockets_view.js b/netlog_viewer/sockets_view.js
new file mode 100644
index 0000000000000000000000000000000000000000..9b12cb3376662ebc572426575554c197a15a6d52
--- /dev/null
+++ b/netlog_viewer/sockets_view.js
@@ -0,0 +1,95 @@
+// Copyright (c) 2012 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.
+ */
+var SocketsView = (function() {
+ 'use strict';
+
+ // We inherit from DivView.
+ var superClass = DivView;
+
+ /**
+ * @constructor
+ */
+ function SocketsView() {
+ assertFirstConstructorCall(SocketsView);
+
+ // Call superclass's constructor.
+ superClass.call(this, SocketsView.MAIN_BOX_ID);
+
+ g_browser.addSocketPoolInfoObserver(this, true);
+ this.socketPoolDiv_ = $(SocketsView.SOCKET_POOL_DIV_ID);
+ this.socketPoolGroupsDiv_ = $(SocketsView.SOCKET_POOL_GROUPS_DIV_ID);
+
+ var closeIdleButton = $(SocketsView.CLOSE_IDLE_SOCKETS_BUTTON_ID);
+ closeIdleButton.onclick = this.closeIdleSockets.bind(this);
+
+ var flushSocketsButton = $(SocketsView.SOCKET_POOL_FLUSH_BUTTON_ID);
+ flushSocketsButton.onclick = this.flushSocketPools.bind(this);
+ }
+
+ SocketsView.TAB_ID = 'tab-handle-sockets';
+ SocketsView.TAB_NAME = 'Sockets';
+ SocketsView.TAB_HASH = '#sockets';
+
+ // IDs for special HTML elements in sockets_view.html
+ SocketsView.MAIN_BOX_ID = 'sockets-view-tab-content';
+ SocketsView.SOCKET_POOL_DIV_ID = 'sockets-view-pool-div';
+ SocketsView.SOCKET_POOL_GROUPS_DIV_ID = 'sockets-view-pool-groups-div';
+ SocketsView.CLOSE_IDLE_SOCKETS_BUTTON_ID = 'sockets-view-close-idle-button';
+ SocketsView.SOCKET_POOL_FLUSH_BUTTON_ID = 'sockets-view-flush-button';
+
+ cr.addSingletonGetter(SocketsView);
+
+ SocketsView.prototype = {
+ // Inherit the superclass's methods.
+ __proto__: superClass.prototype,
+
+ onLoadLogFinish: function(data) {
+ return this.onSocketPoolInfoChanged(data.socketPoolInfo);
+ },
+
+ onSocketPoolInfoChanged: function(socketPoolInfo) {
+ this.socketPoolDiv_.innerHTML = '';
+ this.socketPoolGroupsDiv_.innerHTML = '';
+
+ if (!socketPoolInfo)
+ return false;
+
+ var socketPools = SocketPoolWrapper.createArrayFrom(socketPoolInfo);
+ var tablePrinter = SocketPoolWrapper.createTablePrinter(socketPools);
+ tablePrinter.toHTML(this.socketPoolDiv_, 'styled-table');
+
+ // Add table for each socket pool with information on each of its groups.
+ for (var i = 0; i < socketPools.length; ++i) {
+ if (socketPools[i].origPool.groups != undefined) {
+ var p = addNode(this.socketPoolGroupsDiv_, 'p');
+ var br = addNode(p, 'br');
+ var groupTablePrinter = socketPools[i].createGroupTablePrinter();
+ groupTablePrinter.toHTML(p, 'styled-table');
+ }
+ }
+ return true;
+ },
+
+ closeIdleSockets: function() {
+ g_browser.sendCloseIdleSockets();
+ g_browser.checkForUpdatedInfo(false);
+ },
+
+ flushSocketPools: function() {
+ g_browser.sendFlushSocketPools();
+ g_browser.checkForUpdatedInfo(false);
+ }
+ };
+
+ return SocketsView;
+})();
+
« no previous file with comments | « netlog_viewer/sockets_view.html ('k') | netlog_viewer/source_entry.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698