OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * This view displays a summary of the state of each SPDY sessions, and | 6 * This view displays a summary of the state of each SPDY sessions, and |
7 * has links to display them in the events tab. | 7 * has links to display them in the events tab. |
8 * | 8 * |
9 * @constructor | 9 * @constructor |
10 */ | 10 */ |
11 function SpdyView(mainBoxId, spdySessionNoneSpanId, spdySessionLinkSpanId, | 11 function SpdyView(mainBoxId, spdyEnabledSpanId, |
| 12 spdyUseAlternateProtocolSpanId, |
| 13 spdyForceAlwaysSpanId, spdyForceOverSslSpanId, |
| 14 spdyNextProtocolsSpanId, spdyAlternateProtocolMappingsDivId, |
| 15 spdySessionNoneSpanId, spdySessionLinkSpanId, |
12 spdySessionDivId) { | 16 spdySessionDivId) { |
13 DivView.call(this, mainBoxId); | 17 DivView.call(this, mainBoxId); |
14 g_browser.addSpdySessionInfoObserver(this); | 18 g_browser.addSpdySessionInfoObserver(this); |
| 19 g_browser.addSpdyStatusObserver(this); |
| 20 g_browser.addSpdyAlternateProtocolMappingsObserver(this); |
15 | 21 |
| 22 this.spdyEnabledSpan_ = document.getElementById(spdyEnabledSpanId); |
| 23 this.spdyUseAlternateProtocolSpan_ = |
| 24 document.getElementById(spdyUseAlternateProtocolSpanId); |
| 25 this.spdyForceAlwaysSpan_ = document.getElementById(spdyForceAlwaysSpanId); |
| 26 this.spdyForceOverSslSpan_ = document.getElementById(spdyForceOverSslSpanId); |
| 27 this.spdyNextProtocolsSpan_ = |
| 28 document.getElementById(spdyNextProtocolsSpanId); |
| 29 |
| 30 this.spdyAlternateProtocolMappingsDiv_ = |
| 31 document.getElementById(spdyAlternateProtocolMappingsDivId); |
16 this.spdySessionNoneSpan_ = document.getElementById(spdySessionNoneSpanId); | 32 this.spdySessionNoneSpan_ = document.getElementById(spdySessionNoneSpanId); |
17 this.spdySessionLinkSpan_ = document.getElementById(spdySessionLinkSpanId); | 33 this.spdySessionLinkSpan_ = document.getElementById(spdySessionLinkSpanId); |
18 this.spdySessionDiv_ = document.getElementById(spdySessionDivId); | 34 this.spdySessionDiv_ = document.getElementById(spdySessionDivId); |
19 } | 35 } |
20 | 36 |
21 inherits(SpdyView, DivView); | 37 inherits(SpdyView, DivView); |
22 | 38 |
23 /** | 39 /** |
24 * If |spdySessionInfo| is not null, displays a single table with information | 40 * If |spdySessionInfo| is not null, displays a single table with information |
25 * on each SPDY session. Otherwise, displays "None". | 41 * on each SPDY session. Otherwise, displays "None". |
26 */ | 42 */ |
27 SpdyView.prototype.onSpdySessionInfoChanged = function(spdySessionInfo) { | 43 SpdyView.prototype.onSpdySessionInfoChanged = function(spdySessionInfo) { |
28 this.spdySessionDiv_.innerHTML = ''; | 44 this.spdySessionDiv_.innerHTML = ''; |
29 | 45 |
30 var hasNoSession = (spdySessionInfo == null || spdySessionInfo.length == 0); | 46 var hasNoSession = (spdySessionInfo == null || spdySessionInfo.length == 0); |
31 setNodeDisplay(this.spdySessionNoneSpan_, hasNoSession); | 47 setNodeDisplay(this.spdySessionNoneSpan_, hasNoSession); |
32 setNodeDisplay(this.spdySessionLinkSpan_, !hasNoSession); | 48 setNodeDisplay(this.spdySessionLinkSpan_, !hasNoSession); |
33 | 49 |
34 if (hasNoSession) | 50 if (hasNoSession) |
35 return; | 51 return; |
36 | 52 |
37 var tablePrinter = SpdyView.createSessionTablePrinter(spdySessionInfo); | 53 var tablePrinter = SpdyView.createSessionTablePrinter(spdySessionInfo); |
38 tablePrinter.toHTML(this.spdySessionDiv_, 'styledTable'); | 54 tablePrinter.toHTML(this.spdySessionDiv_, 'styledTable'); |
| 55 |
| 56 }; |
| 57 |
| 58 /** |
| 59 * Displays information on the global SPDY status. |
| 60 */ |
| 61 SpdyView.prototype.onSpdyStatusChanged = function(spdyStatus) { |
| 62 this.spdyEnabledSpan_.innerText = spdyStatus.spdy_enabled; |
| 63 this.spdyUseAlternateProtocolSpan_.innerText = |
| 64 spdyStatus.use_alternate_protocols; |
| 65 this.spdyForceAlwaysSpan_.innerText = spdyStatus.force_spdy_always; |
| 66 this.spdyForceOverSslSpan_.innerText = spdyStatus.force_spdy_over_ssl; |
| 67 this.spdyNextProtocolsSpan_.innerText = spdyStatus.next_protos; |
| 68 } |
| 69 |
| 70 /** |
| 71 * If |spdyAlternateProtocolMappings| is not empty, displays a single table |
| 72 * with information on each alternate protocol enabled server. Otherwise, |
| 73 * displays "None". |
| 74 */ |
| 75 SpdyView.prototype.onSpdyAlternateProtocolMappingsChanged = |
| 76 function(spdyAlternateProtocolMappings) { |
| 77 |
| 78 this.spdyAlternateProtocolMappingsDiv_.innerHTML = ''; |
| 79 |
| 80 if (spdyAlternateProtocolMappings != null && |
| 81 spdyAlternateProtocolMappings.length > 0) { |
| 82 var tabPrinter = SpdyView.createAlternateProtocolMappingsTablePrinter( |
| 83 spdyAlternateProtocolMappings); |
| 84 tabPrinter.toHTML(this.spdyAlternateProtocolMappingsDiv_, 'styledTable'); |
| 85 } else { |
| 86 this.spdyAlternateProtocolMappingsDiv_.innerHTML = 'None'; |
| 87 } |
39 }; | 88 }; |
40 | 89 |
41 /** | 90 /** |
42 * Creates a table printer to print out the state of list of SPDY sessions. | 91 * Creates a table printer to print out the state of list of SPDY sessions. |
43 */ | 92 */ |
44 SpdyView.createSessionTablePrinter = function(spdySessions) { | 93 SpdyView.createSessionTablePrinter = function(spdySessions) { |
45 var tablePrinter = new TablePrinter(); | 94 var tablePrinter = new TablePrinter(); |
46 tablePrinter.addHeaderCell('Host'); | 95 tablePrinter.addHeaderCell('Host'); |
47 tablePrinter.addHeaderCell('Proxy'); | 96 tablePrinter.addHeaderCell('Proxy'); |
48 tablePrinter.addHeaderCell('ID'); | 97 tablePrinter.addHeaderCell('ID'); |
(...skipping 29 matching lines...) Expand all Loading... |
78 tablePrinter.addCell(session.streams_abandoned_count); | 127 tablePrinter.addCell(session.streams_abandoned_count); |
79 tablePrinter.addCell(session.frames_received); | 128 tablePrinter.addCell(session.frames_received); |
80 tablePrinter.addCell(session.is_secure); | 129 tablePrinter.addCell(session.is_secure); |
81 tablePrinter.addCell(session.sent_settings); | 130 tablePrinter.addCell(session.sent_settings); |
82 tablePrinter.addCell(session.received_settings); | 131 tablePrinter.addCell(session.received_settings); |
83 tablePrinter.addCell(session.error); | 132 tablePrinter.addCell(session.error); |
84 } | 133 } |
85 return tablePrinter; | 134 return tablePrinter; |
86 }; | 135 }; |
87 | 136 |
| 137 |
| 138 /** |
| 139 * Creates a table printer to print out the list of alternate protocol |
| 140 * mappings. |
| 141 */ |
| 142 SpdyView.createAlternateProtocolMappingsTablePrinter = |
| 143 function(spdyAlternateProtocolMappings) { |
| 144 var tablePrinter = new TablePrinter(); |
| 145 tablePrinter.addHeaderCell('Host'); |
| 146 tablePrinter.addHeaderCell('Alternate Protocol'); |
| 147 |
| 148 for (var i = 0; i < spdyAlternateProtocolMappings.length; i++) { |
| 149 var entry = spdyAlternateProtocolMappings[i]; |
| 150 tablePrinter.addRow(); |
| 151 |
| 152 tablePrinter.addCell(entry.host_port_pair); |
| 153 tablePrinter.addCell(entry.alternate_protocol); |
| 154 } |
| 155 return tablePrinter; |
| 156 }; |
| 157 |
OLD | NEW |