| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * This view displays information on the state of all socket pools. | |
| 7 * | |
| 8 * - Shows a summary of the state of each socket pool at the top. | |
| 9 * - For each pool with allocated sockets or connect jobs, shows all its | |
| 10 * groups with any allocated sockets. | |
| 11 * | |
| 12 * @constructor | |
| 13 */ | |
| 14 function SocketsView() { | |
| 15 const mainBoxId = 'socketsTabContent'; | |
| 16 const socketPoolDivId = 'socketPoolDiv'; | |
| 17 const socketPoolGroupsDivId = 'socketPoolGroupsDiv'; | |
| 18 const closeIdleSocketsButtonId = 'socketPoolCloseIdleButton'; | |
| 19 const socketPoolFlushButtonId = 'socketPoolFlushButton'; | |
| 20 | |
| 21 DivView.call(this, mainBoxId); | |
| 22 | |
| 23 g_browser.addSocketPoolInfoObserver(this); | |
| 24 this.socketPoolDiv_ = $(socketPoolDivId); | |
| 25 this.socketPoolGroupsDiv_ = $(socketPoolGroupsDivId); | |
| 26 | |
| 27 var closeIdleButton = $(closeIdleSocketsButtonId); | |
| 28 closeIdleButton.onclick = this.closeIdleSockets.bind(this); | |
| 29 | |
| 30 var flushSocketsButton = $(socketPoolFlushButtonId); | |
| 31 flushSocketsButton.onclick = this.flushSocketPools.bind(this); | |
| 32 } | |
| 33 | |
| 34 inherits(SocketsView, DivView); | |
| 35 | |
| 36 SocketsView.prototype.onLoadLogFinish = function(data) { | |
| 37 return this.onSocketPoolInfoChanged(data.socketPoolInfo); | |
| 38 }; | |
| 39 | |
| 40 SocketsView.prototype.onSocketPoolInfoChanged = function(socketPoolInfo) { | |
| 41 this.socketPoolDiv_.innerHTML = ''; | |
| 42 this.socketPoolGroupsDiv_.innerHTML = ''; | |
| 43 | |
| 44 if (!socketPoolInfo) | |
| 45 return false; | |
| 46 | |
| 47 var socketPools = SocketPoolWrapper.createArrayFrom(socketPoolInfo); | |
| 48 var tablePrinter = SocketPoolWrapper.createTablePrinter(socketPools); | |
| 49 tablePrinter.toHTML(this.socketPoolDiv_, 'styledTable'); | |
| 50 | |
| 51 // Add table for each socket pool with information on each of its groups. | |
| 52 for (var i = 0; i < socketPools.length; ++i) { | |
| 53 if (socketPools[i].origPool.groups != undefined) { | |
| 54 var p = addNode(this.socketPoolGroupsDiv_, 'p'); | |
| 55 var br = addNode(p, 'br'); | |
| 56 var groupTablePrinter = socketPools[i].createGroupTablePrinter(); | |
| 57 groupTablePrinter.toHTML(p, 'styledTable'); | |
| 58 } | |
| 59 } | |
| 60 return true; | |
| 61 }; | |
| 62 | |
| 63 SocketsView.prototype.closeIdleSockets = function() { | |
| 64 g_browser.sendCloseIdleSockets(); | |
| 65 g_browser.checkForUpdatedInfo(false); | |
| 66 } | |
| 67 | |
| 68 SocketsView.prototype.flushSocketPools = function() { | |
| 69 g_browser.sendFlushSocketPools(); | |
| 70 g_browser.checkForUpdatedInfo(false); | |
| 71 } | |
| OLD | NEW |