Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: remoting/webapp/me2mom/debug_log.js

Issue 8865005: The chromoting client logs connection statistics to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 * @fileoverview 6 * @fileoverview
7 * Module to support logging debug messages. 7 * Module to support logging debug messages.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 20 matching lines...) Expand all
31 remoting.DebugLog.prototype.MAX_DEBUG_LOG_SIZE = 1000; 31 remoting.DebugLog.prototype.MAX_DEBUG_LOG_SIZE = 1000;
32 32
33 /** 33 /**
34 * JID for the remoting bot which is used to bridge communication between 34 * JID for the remoting bot which is used to bridge communication between
35 * the Talk network and the Remoting directory service. 35 * the Talk network and the Remoting directory service.
36 */ 36 */
37 remoting.DebugLog.prototype.REMOTING_DIRECTORY_SERVICE_BOT = 37 remoting.DebugLog.prototype.REMOTING_DIRECTORY_SERVICE_BOT =
38 'remoting@bot.talk.google.com'; 38 'remoting@bot.talk.google.com';
39 39
40 /** 40 /**
41 * The host attributes in a log entry.
42 *
43 * @private
44 */
45 remoting.DebugLog.prototype.LOG_ENTRY_HOST_ATTRIBUTES_ =
46 'cpu,os-name,browser-version,webapp-version';
47
48 /**
49 * The id attribute in a log entry.
50 *
51 * @private
52 */
53 remoting.DebugLog.prototype.LOG_ENTRY_ID_ATTRIBUTE_ = 'id';
54
55 /**
41 * Add the given message to the debug log. 56 * Add the given message to the debug log.
42 * 57 *
43 * @param {number} indentLevel The indention level for this message. 58 * @param {number} indentLevel The indention level for this message.
44 * @param {string} message The debug info to add to the log. 59 * @param {string} message The debug info to add to the log.
45 */ 60 */
46 remoting.DebugLog.prototype.logIndent = function(indentLevel, message) { 61 remoting.DebugLog.prototype.logIndent = function(indentLevel, message) {
47 // Remove lines from top if we've hit our max log size. 62 // Remove lines from top if we've hit our max log size.
48 if (this.logElement.childNodes.length == this.MAX_DEBUG_LOG_SIZE) { 63 if (this.logElement.childNodes.length == this.MAX_DEBUG_LOG_SIZE) {
49 this.logElement.removeChild(this.logElement.firstChild); 64 this.logElement.removeChild(this.logElement.firstChild);
50 } 65 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 debugLog.hidden = true; 98 debugLog.hidden = true;
84 } 99 }
85 }; 100 };
86 101
87 /** 102 /**
88 * Update the statistics panel. 103 * Update the statistics panel.
89 * @param {Object.<string, number>} stats The connection statistics. 104 * @param {Object.<string, number>} stats The connection statistics.
90 */ 105 */
91 remoting.DebugLog.prototype.updateStatistics = function(stats) { 106 remoting.DebugLog.prototype.updateStatistics = function(stats) {
92 var units = ''; 107 var units = '';
93 var videoBandwidth = stats['video_bandwidth']; 108 var videoBandwidth = stats[remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH];
94 if (videoBandwidth < 1024) { 109 if (videoBandwidth < 1024) {
95 units = 'Bps'; 110 units = 'Bps';
96 } else if (videoBandwidth < 1048576) { 111 } else if (videoBandwidth < 1048576) {
97 units = 'KiBps'; 112 units = 'KiBps';
98 videoBandwidth = videoBandwidth / 1024; 113 videoBandwidth = videoBandwidth / 1024;
99 } else if (videoBandwidth < 1073741824) { 114 } else if (videoBandwidth < 1073741824) {
100 units = 'MiBps'; 115 units = 'MiBps';
101 videoBandwidth = videoBandwidth / 1048576; 116 videoBandwidth = videoBandwidth / 1048576;
102 } else { 117 } else {
103 units = 'GiBps'; 118 units = 'GiBps';
104 videoBandwidth = videoBandwidth / 1073741824; 119 videoBandwidth = videoBandwidth / 1073741824;
105 } 120 }
106 121
107 var statistics = document.getElementById('statistics'); 122 var statistics = document.getElementById('statistics');
108 this.statsElement.innerText = 123 this.statsElement.innerText =
109 'Bandwidth: ' + videoBandwidth.toFixed(2) + units + 124 'Bandwidth: ' + videoBandwidth.toFixed(2) + units +
110 ', Frame Rate: ' + 125 ', Frame Rate: ' +
111 (stats['video_frame_rate'] ? 126 (stats[remoting.ClientSession.STATS_KEY_VIDEO_FRAME_RATE] ?
112 stats['video_frame_rate'].toFixed(2) + ' fps' : 'n/a') + 127 stats[remoting.ClientSession.STATS_KEY_VIDEO_FRAME_RATE].toFixed(2)
113 ', Capture: ' + stats['capture_latency'].toFixed(2) + 'ms' + 128 + ' fps' : 'n/a') +
114 ', Encode: ' + stats['encode_latency'].toFixed(2) + 'ms' + 129 ', Capture: ' +
115 ', Decode: ' + stats['decode_latency'].toFixed(2) + 'ms' + 130 stats[remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY].toFixed(2) +
116 ', Render: ' + stats['render_latency'].toFixed(2) + 'ms' + 131 'ms' +
117 ', Latency: ' + stats['roundtrip_latency'].toFixed(2) + 'ms'; 132 ', Encode: ' +
133 stats[remoting.ClientSession.STATS_KEY_ENCODE_LATENCY].toFixed(2) +
134 'ms' +
135 ', Decode: ' +
136 stats[remoting.ClientSession.STATS_KEY_DECODE_LATENCY].toFixed(2) +
137 'ms' +
138 ', Render: ' +
139 stats[remoting.ClientSession.STATS_KEY_RENDER_LATENCY].toFixed(2) +
140 'ms' +
141 ', Latency: ' +
142 stats[remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY].toFixed(2) +
143 'ms';
118 }; 144 };
119 145
120 /** 146 /**
121 * Check for the debug toggle hot-key. 147 * Check for the debug toggle hot-key.
122 * 148 *
123 * @param {Event} event The keyboard event. 149 * @param {Event} event The keyboard event.
124 * @return {void} Nothing. 150 * @return {void} Nothing.
125 */ 151 */
126 remoting.DebugLog.onKeydown = function(event) { 152 remoting.DebugLog.onKeydown = function(event) {
127 var element = /** @type {Element} */ (event.target); 153 var element = /** @type {Element} */ (event.target);
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 var log = child; 682 var log = child;
657 if (log.childNodes.length != 1) { 683 if (log.childNodes.length != 1) {
658 return false; 684 return false;
659 } 685 }
660 if (!this.verifyAttributes(log, 'xmlns:gr')) { 686 if (!this.verifyAttributes(log, 'xmlns:gr')) {
661 return false; 687 return false;
662 } 688 }
663 689
664 /** @type {Node} */ 690 /** @type {Node} */
665 var entry = log.childNodes[0]; 691 var entry = log.childNodes[0];
666 if (!this.verifyAttributes(entry, 'role,event-name,session-state,cpu,' +
667 'os-name,browser-version,webapp-version,id')) {
668 return false;
669 }
670 var role = entry.getAttribute('role'); 692 var role = entry.getAttribute('role');
671 if (role != 'client') { 693 if (role != 'client') {
672 return false; 694 return false;
673 } 695 }
674 var event_name = entry.getAttribute('event-name'); 696 var event_name = entry.getAttribute('event-name');
675 if (event_name != 'session-state') { 697 if (event_name == 'session-state') {
Jamie 2011/12/09 06:58:34 This feels unnecessary to me. My understanding of
simonmorris 2011/12/09 18:40:36 Done.
676 return false; 698 if (!this.verifyAttributes(entry,
699 'role,event-name,session-state,' +
700 this.LOG_ENTRY_HOST_ATTRIBUTES_ + ',' +
701 this.LOG_ENTRY_ID_ATTRIBUTE_)) {
702 return false;
703 }
704 var session_state = entry.getAttribute('session-state');
705 this.prettyIqHeading(action, '?', 'log session-state ' + session_state,
706 null);
707 this.prettyLogEntryHostAttributes(entry);
708 this.prettyLogEntryIdAttribute(entry);
709 return true;
710 } else if (event_name == 'connection-statistics') {
711 if (!this.verifyAttributes(entry,
712 'role,event-name,video-bandwidth,capture-latency,encode-latency,' +
713 'decode-latency,render-latency,roundtrip-latency,' +
714 this.LOG_ENTRY_HOST_ATTRIBUTES_ + ',' +
715 this.LOG_ENTRY_ID_ATTRIBUTE_)) {
716 return false;
717 }
718 this.prettyIqHeading(action, '?', 'log connection-statistics', null);
719 var video_bandwidth = entry.getAttribute('video-bandwidth');
720 if (video_bandwidth) {
721 this.logIndent(1, 'video bandwidth: ' + video_bandwidth);
722 }
723 var capture_latency = entry.getAttribute('capture-latency');
724 if (capture_latency) {
725 this.logIndent(1, 'capture latency: ' + capture_latency);
726 }
727 var encode_latency = entry.getAttribute('encode-latency');
728 if (encode_latency) {
729 this.logIndent(1, 'encode latency: ' + encode_latency);
730 }
731 var decode_latency = entry.getAttribute('decode-latency');
732 if (decode_latency) {
733 this.logIndent(1, 'decode latency: ' + decode_latency);
734 }
735 var render_latency = entry.getAttribute('render-latency');
736 if (render_latency) {
737 this.logIndent(1, 'render latency: ' + render_latency);
738 }
739 var roundtrip_latency = entry.getAttribute('roundtrip-latency');
740 if (roundtrip_latency) {
741 this.logIndent(1, 'roundtrip latency: ' + roundtrip_latency);
742 }
743 this.prettyLogEntryHostAttributes(entry);
744 this.prettyLogEntryIdAttribute(entry);
745 return true;
677 } 746 }
678 var session_state = entry.getAttribute('session-state'); 747 return false;
679 this.prettyIqHeading(action, '?', 'log session-state ' + session_state,
680 null);
681
682 var os_name = entry.getAttribute('os-name');
683 var cpu = entry.getAttribute('cpu');
684 var browser_version = entry.getAttribute('browser-version');
685 var webapp_version = entry.getAttribute('webapp-version');
686 this.logIndent(1, os_name + ' ' + cpu + ' Chromium_v' + browser_version +
687 ' Chromoting_v' + webapp_version);
688 var remoting_id = entry.getAttribute('id');
689 if (remoting_id) {
690 this.logIndent(1, 'id: ' + remoting_id);
691 }
692 return true;
693 } 748 }
694 } 749 }
695 return false; 750 return false;
696 } 751 };
752
753 /**
754 * Print out the host attributes in a log entry.
755 *
756 * @private
757 * @param {Node} entry
758 */
759 remoting.DebugLog.prototype.prettyLogEntryHostAttributes = function(entry) {
760 var os_name = entry.getAttribute('os-name');
761 var cpu = entry.getAttribute('cpu');
762 var browser_version = entry.getAttribute('browser-version');
763 var webapp_version = entry.getAttribute('webapp-version');
764 this.logIndent(1, os_name + ' ' + cpu + ' Chromium_v' + browser_version +
765 ' Chromoting_v' + webapp_version);
766 };
767
768 /**
769 * Print out the id attribute in a log entry.
770 *
771 * @private
772 * @param {Node} entry
773 */
774 remoting.DebugLog.prototype.prettyLogEntryIdAttribute = function(entry) {
775 var remoting_id = entry.getAttribute('id');
776 if (remoting_id) {
777 this.logIndent(1, 'id: ' + remoting_id);
778 }
779 };
697 780
698 /** 781 /**
699 * Print out an iq 'error'-type node. 782 * Print out an iq 'error'-type node.
700 * 783 *
701 * @param {string} action String describing action (send/receive). 784 * @param {string} action String describing action (send/receive).
702 * @param {NodeList} iq_list Node containing the 'error' xml. 785 * @param {NodeList} iq_list Node containing the 'error' xml.
703 * 786 *
704 * @return {boolean} True if the data was logged successfully. 787 * @return {boolean} True if the data was logged successfully.
705 */ 788 */
706 remoting.DebugLog.prototype.prettyIqError = function(action, iq_list) { 789 remoting.DebugLog.prototype.prettyIqError = function(action, iq_list) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 remoting.DebugLog.prototype.logIq = function(send, message) { 902 remoting.DebugLog.prototype.logIq = function(send, message) {
820 if (!this.prettyIq(send, message)) { 903 if (!this.prettyIq(send, message)) {
821 // Fall back to showing the raw stanza. 904 // Fall back to showing the raw stanza.
822 var prefix = (send ? 'Sending Iq: ' : 'Receiving Iq: '); 905 var prefix = (send ? 'Sending Iq: ' : 'Receiving Iq: ');
823 this.log(prefix + message); 906 this.log(prefix + message);
824 } 907 }
825 }; 908 };
826 909
827 /** @type {remoting.DebugLog} */ 910 /** @type {remoting.DebugLog} */
828 remoting.debug = null; 911 remoting.debug = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698