1 // Copyright (c) 2013 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.
6 * This view displays a summary of the state of each QUIC session, and
7 * has links to display them in the events tab.
9 var QuicView
= (function() {
12 // We inherit from DivView.
13 var superClass
= DivView
;
19 assertFirstConstructorCall(QuicView
);
21 // Call superclass's constructor.
22 superClass
.call(this, QuicView
.MAIN_BOX_ID
);
24 g_browser
.addQuicInfoObserver(this, true);
26 this.quicEnabledSpan_
= $(QuicView
.ENABLED_SPAN_ID
);
27 this.quicForcePortSpan_
= $(QuicView
.FORCE_PORT_SPAN_ID
);
29 this.quicSessionNoneSpan_
= $(QuicView
.SESSION_NONE_SPAN_ID
);
30 this.quicSessionLinkSpan_
= $(QuicView
.SESSION_LINK_SPAN_ID
);
31 this.quicSessionDiv_
= $(QuicView
.SESSION_DIV_ID
);
34 // ID for special HTML element in category_tabs.html
35 QuicView
.TAB_HANDLE_ID
= 'tab-handle-quic';
37 // IDs for special HTML elements in quic_view.html
38 QuicView
.MAIN_BOX_ID
= 'quic-view-tab-content';
39 QuicView
.ENABLED_SPAN_ID
= 'quic-view-enabled-span';
40 QuicView
.FORCE_PORT_SPAN_ID
= 'quic-view-force-port-span';
41 QuicView
.SESSION_NONE_SPAN_ID
= 'quic-view-session-none-span';
42 QuicView
.SESSION_LINK_SPAN_ID
= 'quic-view-session-link-span';
43 QuicView
.SESSION_DIV_ID
= 'quic-view-session-div';
45 cr
.addSingletonGetter(QuicView
);
47 QuicView
.prototype = {
48 // Inherit the superclass's methods.
49 __proto__
: superClass
.prototype,
51 onLoadLogFinish: function(data
) {
52 return this.onQuicInfoChanged(data
.quicInfo
);
56 * If there are any sessions, display a single table with
57 * information on each QUIC session. Otherwise, displays "None".
59 onQuicInfoChanged: function(quicInfo
) {
60 this.quicSessionDiv_
.innerHTML
= '';
63 (!quicInfo
|| !quicInfo
.sessions
|| quicInfo
.sessions
.length
== 0);
64 setNodeDisplay(this.quicSessionNoneSpan_
, hasNoSession
);
65 setNodeDisplay(this.quicSessionLinkSpan_
, !hasNoSession
);
67 // Only want to be hide the tab if there's no data. In the case of having
68 // data but no sessions, still show the tab.
72 this.quicEnabledSpan_
.textContent
= quicInfo
.quic_enabled
;
73 this.quicForcePortSpan_
.textContent
=
74 quicInfo
.origin_port_to_force_quic_on
;
77 var tablePrinter
= createSessionTablePrinter(quicInfo
.sessions
);
78 tablePrinter
.toHTML(this.quicSessionDiv_
, 'styled-table');
86 * Creates a table printer to print out the state of list of QUIC sessions.
88 function createSessionTablePrinter(quicSessions
) {
89 var tablePrinter
= new TablePrinter();
91 tablePrinter
.addHeaderCell('Host');
92 tablePrinter
.addHeaderCell('Peer address');
93 tablePrinter
.addHeaderCell('GUID');
94 tablePrinter
.addHeaderCell('Active streams');
96 for (var i
= 0; i
< quicSessions
.length
; i
++) {
97 var session
= quicSessions
[i
];
98 tablePrinter
.addRow();
100 var host
= session
.host_port_pair
;
102 host
+= ' ' + session
.aliases
.join(' ');
103 tablePrinter
.addCell(host
);
105 tablePrinter
.addCell(session
.peer_address
);
106 tablePrinter
.addCell(session
.guid
);
107 tablePrinter
.addCell(session
.open_streams
);