1 // Copyright (c) 2012 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 SPDY sessions, and
7 * has links to display them in the events tab.
9 var SpdyView = (function() {
12 // We inherit from DivView.
13 var superClass = DivView;
19 assertFirstConstructorCall(SpdyView);
21 // Call superclass's constructor.
22 superClass.call(this, SpdyView.MAIN_BOX_ID);
24 g_browser.addSpdySessionInfoObserver(this, true);
25 g_browser.addSpdyStatusObserver(this, true);
26 g_browser.addSpdyAlternateProtocolMappingsObserver(this, true);
29 SpdyView.TAB_ID = 'tab-handle-spdy';
30 SpdyView.TAB_NAME = 'HTTP/2';
31 SpdyView.TAB_HASH = '#http2';
33 // IDs for special HTML elements in spdy_view.html
34 SpdyView.MAIN_BOX_ID = 'spdy-view-tab-content';
35 SpdyView.STATUS_ID = 'spdy-view-status';
36 SpdyView.SESSION_INFO_ID = 'spdy-view-session-info';
37 SpdyView.ALTERNATE_PROTOCOL_MAPPINGS_ID =
38 'spdy-view-alternate-protocol-mappings';
40 cr.addSingletonGetter(SpdyView);
42 SpdyView.prototype = {
43 // Inherit the superclass's methods.
44 __proto__: superClass.prototype,
46 onLoadLogFinish: function(data) {
47 return this.onSpdySessionInfoChanged(data.spdySessionInfo) &&
48 this.onSpdyStatusChanged(data.spdyStatus) &&
49 this.onSpdyAlternateProtocolMappingsChanged(
50 data.spdyAlternateProtocolMappings);
54 * If |spdySessionInfo| contains any sessions, displays a single table with
55 * information on each SPDY session. Otherwise, displays "None".
57 onSpdySessionInfoChanged: function(spdySessionInfo) {
60 var input = new JsEvalContext({ spdySessionInfo: spdySessionInfo });
61 jstProcess(input, $(SpdyView.SESSION_INFO_ID));
66 * Displays information on the global SPDY status.
68 onSpdyStatusChanged: function(spdyStatus) {
71 var input = new JsEvalContext(spdyStatus);
72 jstProcess(input, $(SpdyView.STATUS_ID));
77 * Displays information on the SPDY alternate protocol mappings.
79 onSpdyAlternateProtocolMappingsChanged: function(
80 spdyAlternateProtocolMappings) {
81 if (!spdyAlternateProtocolMappings)
83 var input = new JsEvalContext(
84 {spdyAlternateProtocolMappings: spdyAlternateProtocolMappings});
85 jstProcess(input, $(SpdyView.ALTERNATE_PROTOCOL_MAPPINGS_ID));