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. 4 5/** 6 * This view displays a summary of the state of each QUIC session, and 7 * has links to display them in the events tab. 8 */ 9var QuicView = (function() { 10 'use strict'; 11 12 // We inherit from DivView. 13 var superClass = DivView; 14 15 /** 16 * @constructor 17 */ 18 function QuicView() { 19 assertFirstConstructorCall(QuicView); 20 21 // Call superclass's constructor. 22 superClass.call(this, QuicView.MAIN_BOX_ID); 23 24 g_browser.addQuicInfoObserver(this, true); 25 } 26 27 QuicView.TAB_ID = 'tab-handle-quic'; 28 QuicView.TAB_NAME = 'QUIC'; 29 QuicView.TAB_HASH = '#quic'; 30 31 // IDs for special HTML elements in quic_view.html 32 QuicView.MAIN_BOX_ID = 'quic-view-tab-content'; 33 QuicView.STATUS_QUIC_ENABLED = 'quic-view-quic-enabled'; 34 QuicView.STATUS_ORIGINS_TO_FORCE_QUIC_ON = 35 'quic-view-origins-to-force-quic-on'; 36 QuicView.STATUS_CONNECTION_OPTIONS = 37 'quic-view-connection-options'; 38 QuicView.STATUS_CONSISTENT_PORT_SELECTION_ENABLED = 39 'quic-view-port-selection-enabled'; 40 QuicView.STATUS_LOAD_SERVER_INFO_TIMEOUT_MULTIPLIER = 41 'quic-view-server-info-timeout-mult'; 42 QuicView.STATUS_ENABLE_CONNECTION_RACING = 43 'quic-view-enable-connection-racing'; 44 QuicView.STATUS_DISABLE_DISK_CACHE = 45 'quic-view-disable-disk-cache'; 46 QuicView.STATUS_PREFER_AES = 47 'quic-view-prefer-aes'; 48 QuicView.STATUS_MAX_NUM_OF_LOSSY_CONNECTIONS = 49 'quic-view-max-num-lossy-connections'; 50 QuicView.STATUS_PACKET_LOSS_THRESHOLD = 51 'quic-view-packet-loss-threshold'; 52 QuicView.STATUS_DELAY_TCP_RACE = 'quic-view-delay-tcp-race'; 53 QuicView.STATUS_STORE_SERVER_CONFIGS_IN_PROPERITES_FILE = 54 'quic-view-configs-in-file'; 55 QuicView.STATUS_IDLE_CONNECTION_TIMEOUT_IN_SECS = 56 'quic-view-connection-timeout-in-secs'; 57 QuicView.STATUS_DISABLE_PRECONNECT_IF_ORTT = 58 'quic-view-disable-preconnect-if-ortt'; 59 QuicView.STATUS_DISABLE_QUIC_ON_TIMEOUT_WITH_OPEN_STREAMS = 60 'quic-view-disable-quic-on-timeout-with-open-streams'; 61 QuicView.STATUS_DYNAMICALLY_DISABLED_BULLET_POINT = 62 'quic-view-dynamically-disabled-bullet-point'; 63 QuicView.STATUS_DYNAMICALLY_DISABLED_SPAN = 64 'quic-view-dynamically-disabled-span'; 65 QuicView.SESSION_INFO_CONTENT_ID = 66 'quic-view-session-info-content'; 67 QuicView.SESSION_INFO_NO_CONTENT_ID = 68 'quic-view-session-info-no-content'; 69 QuicView.SESSION_INFO_TBODY_ID = 'quic-view-session-info-tbody'; 70 71 cr.addSingletonGetter(QuicView); 72 73 QuicView.prototype = { 74 // Inherit the superclass's methods. 75 __proto__: superClass.prototype, 76 77 onLoadLogFinish: function(data) { 78 return this.onQuicInfoChanged(data.quicInfo); 79 }, 80 81 /** 82 * If there are any sessions, display a single table with 83 * information on each QUIC session. Otherwise, displays "None". 84 */ 85 onQuicInfoChanged: function(quicInfo) { 86 if (!quicInfo) 87 return false; 88 89 $(QuicView.STATUS_QUIC_ENABLED).textContent = 90 !!quicInfo.quic_enabled; 91 92 $(QuicView.STATUS_ORIGINS_TO_FORCE_QUIC_ON).textContent = 93 quicInfo.origins_to_force_quic_on; 94 95 $(QuicView.STATUS_CONNECTION_OPTIONS).textContent = 96 quicInfo.connection_options; 97 98 $(QuicView.STATUS_CONSISTENT_PORT_SELECTION_ENABLED). 99 textContent = !!quicInfo.enable_quic_port_selection; 100 101 $(QuicView.STATUS_LOAD_SERVER_INFO_TIMEOUT_MULTIPLIER). 102 textContent = quicInfo.load_server_info_timeout_srtt_multiplier; 103 104 $(QuicView.STATUS_ENABLE_CONNECTION_RACING).textContent = 105 !!quicInfo.enable_connection_racing; 106 107 $(QuicView.STATUS_DISABLE_DISK_CACHE).textContent = 108 !!quicInfo.disable_disk_cache; 109 110 $(QuicView.STATUS_PREFER_AES).textContent = 111 !!quicInfo.prefer_aes; 112 113 $(QuicView.STATUS_MAX_NUM_OF_LOSSY_CONNECTIONS).textContent = 114 quicInfo.max_number_of_lossy_connections; 115 116 $(QuicView.STATUS_PACKET_LOSS_THRESHOLD).textContent = 117 quicInfo.packet_loss_threshold; 118 119 $(QuicView.STATUS_DELAY_TCP_RACE).textContent = 120 !!quicInfo.delay_tcp_race; 121 122 $(QuicView.STATUS_STORE_SERVER_CONFIGS_IN_PROPERITES_FILE). 123 textContent = !!quicInfo.store_server_configs_in_properties; 124 125 $(QuicView.STATUS_IDLE_CONNECTION_TIMEOUT_IN_SECS).textContent = 126 quicInfo.idle_connection_timeout_seconds; 127 128 $(QuicView.STATUS_DISABLE_PRECONNECT_IF_ORTT).textContent = 129 quicInfo.disable_preconnect_if_0rtt; 130 131 $(QuicView.STATUS_DISABLE_QUIC_ON_TIMEOUT_WITH_OPEN_STREAMS). 132 textContent = 133 quicInfo.disable_quic_on_timeout_with_open_streams; 134 135 setNodeDisplay($(QuicView.STATUS_DYNAMICALLY_DISABLED_BULLET_POINT), 136 quicInfo.disabled_reason && quicInfo.disabled_reason.length > 0); 137 if (quicInfo.disabled_reason && 138 quicInfo.disabled_reason.length > 0) { 139 $(QuicView.STATUS_DYNAMICALLY_DISABLED_SPAN).textContent = 140 'QUIC dynamically disabled: ' + quicInfo.disabled_reason; 141 } 142 143 var sessions = quicInfo.sessions; 144 145 var hasSessions = sessions && sessions.length > 0; 146 147 setNodeDisplay($(QuicView.SESSION_INFO_CONTENT_ID), hasSessions); 148 setNodeDisplay($(QuicView.SESSION_INFO_NO_CONTENT_ID), !hasSessions); 149 150 var tbody = $(QuicView.SESSION_INFO_TBODY_ID); 151 tbody.innerHTML = ''; 152 153 // Fill in the sessions info table. 154 for (var i = 0; i < sessions.length; ++i) { 155 var q = sessions[i]; 156 var tr = addNode(tbody, 'tr'); 157 158 addNodeWithText(tr, 'td', q.aliases ? q.aliases.join(' ') : ''); 159 addNodeWithText(tr, 'td', !!q.secure); 160 addNodeWithText(tr, 'td', q.version); 161 addNodeWithText(tr, 'td', q.peer_address); 162 163 var connectionUIDCell = addNode(tr, 'td'); 164 var a = addNode(connectionUIDCell, 'a'); 165 a.href = '#events&q=type:QUIC_SESSION%20' + q.connection_id; 166 a.textContent = q.connection_id; 167 168 addNodeWithText(tr, 'td', q.open_streams); 169 170 addNodeWithText(tr, 'td', 171 q.active_streams && q.active_streams.length > 0 ? 172 q.active_streams.join(', ') : 'None'); 173 174 addNodeWithText(tr, 'td', q.total_streams); 175 addNodeWithText(tr, 'td', q.packets_sent); 176 addNodeWithText(tr, 'td', q.packets_lost); 177 addNodeWithText(tr, 'td', q.packets_received); 178 addNodeWithText(tr, 'td', q.connected); 179 } 180 181 return true; 182 }, 183 }; 184 185 return QuicView; 186})(); 187 188