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

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

Issue 7108007: Add basic debug log to host page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months 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
« no previous file with comments | « remoting/webapp/me2mom/remoting_session.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Maximum numer of lines to record in the debug log.
6 // Only the most recent <n> lines are displayed.
7 var MAX_DEBUG_LOG_SIZE = 1000;
8
9 var remoting = chrome.extension.getBackgroundPage().remoting; 5 var remoting = chrome.extension.getBackgroundPage().remoting;
10 6
11 // Chromoting session API version (for this javascript). 7 // Chromoting session API version (for this javascript).
12 // This is compared with the plugin API version to verify that they are 8 // This is compared with the plugin API version to verify that they are
13 // compatible. 9 // compatible.
14 remoting.apiVersion = 2; 10 remoting.apiVersion = 2;
15 11
16 // The oldest API version that we support. 12 // The oldest API version that we support.
17 // This will differ from the |apiVersion| if we maintain backward 13 // This will differ from the |apiVersion| if we maintain backward
18 // compatibility with older API versions. 14 // compatibility with older API versions.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 'oauth2:' + remoting.oauth2.getAccessToken(), remoting.accessCode); 159 'oauth2:' + remoting.oauth2.getAccessToken(), remoting.accessCode);
164 } 160 }
165 } 161 }
166 } else { 162 } else {
167 addToDebugLog('ERROR: remoting plugin not loaded'); 163 addToDebugLog('ERROR: remoting plugin not loaded');
168 setClientStateMessage('Plugin not loaded'); 164 setClientStateMessage('Plugin not loaded');
169 } 165 }
170 166
171 } 167 }
172 168
173 function toggleDebugLog() {
174 debugLog = document.getElementById('debug-log');
175 toggleButton = document.getElementById('debug-log-toggle');
176
177 if (!debugLog.style.display || debugLog.style.display == 'none') {
178 debugLog.style.display = 'block';
179 toggleButton.value = 'Hide Debug Log';
180 } else {
181 debugLog.style.display = 'none';
182 toggleButton.value = 'Show Debug Log';
183 }
184 }
185
186 function toggleScaleToFit() { 169 function toggleScaleToFit() {
187 remoting.scaleToFit = !remoting.scaleToFit; 170 remoting.scaleToFit = !remoting.scaleToFit;
188 document.getElementById('scale-to-fit-toggle').value = 171 document.getElementById('scale-to-fit-toggle').value =
189 remoting.scaleToFit ? 'No scaling' : 'Scale to fit'; 172 remoting.scaleToFit ? 'No scaling' : 'Scale to fit';
190 remoting.plugin.setScaleToFit(remoting.scaleToFit); 173 remoting.plugin.setScaleToFit(remoting.scaleToFit);
191 } 174 }
192 175
193 /** 176 /**
194 * This is the callback method that the plugin calls to request username and 177 * This is the callback method that the plugin calls to request username and
195 * password for logging into the remote host. For Me2Mom we are pre-authorized 178 * password for logging into the remote host. For Me2Mom we are pre-authorized
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 289 }
307 290
308 /** 291 /**
309 * This is that callback that the plugin invokes to indicate that there 292 * This is that callback that the plugin invokes to indicate that there
310 * is additional debug log info to display. 293 * is additional debug log info to display.
311 */ 294 */
312 function debugInfoCallback(msg) { 295 function debugInfoCallback(msg) {
313 addToDebugLog('plugin: ' + msg); 296 addToDebugLog('plugin: ' + msg);
314 } 297 }
315 298
316 /**
317 * Add the given message to the debug log.
318 *
319 * @param {string} message The debug info to add to the log.
320 */
321 function addToDebugLog(message) {
322 var debugLog = document.getElementById('debug-log');
323
324 // Remove lines from top if we've hit our max log size.
325 if (debugLog.childNodes.length == MAX_DEBUG_LOG_SIZE) {
326 debugLog.removeChild(debugLog.firstChild);
327 }
328
329 // Add the new <p> to the end of the debug log.
330 var p = document.createElement('p');
331 p.appendChild(document.createTextNode(message));
332 debugLog.appendChild(p);
333
334 // Scroll to bottom of div
335 debugLog.scrollTop = debugLog.scrollHeight;
336 }
337
338 function updateStatusBarStats() { 299 function updateStatusBarStats() {
339 if (remoting.plugin.status != remoting.plugin.STATUS_CONNECTED) 300 if (remoting.plugin.status != remoting.plugin.STATUS_CONNECTED)
340 return; 301 return;
341 var videoBandwidth = remoting.plugin.videoBandwidth; 302 var videoBandwidth = remoting.plugin.videoBandwidth;
342 var videoCaptureLatency = remoting.plugin.videoCaptureLatency; 303 var videoCaptureLatency = remoting.plugin.videoCaptureLatency;
343 var videoEncodeLatency = remoting.plugin.videoEncodeLatency; 304 var videoEncodeLatency = remoting.plugin.videoEncodeLatency;
344 var videoDecodeLatency = remoting.plugin.videoDecodeLatency; 305 var videoDecodeLatency = remoting.plugin.videoDecodeLatency;
345 var videoRenderLatency = remoting.plugin.videoRenderLatency; 306 var videoRenderLatency = remoting.plugin.videoRenderLatency;
346 307
347 var units = ''; 308 var units = '';
(...skipping 13 matching lines...) Expand all
361 setClientStateMessage( 322 setClientStateMessage(
362 'Bandwidth: ' + videoBandwidth.toFixed(2) + units + 323 'Bandwidth: ' + videoBandwidth.toFixed(2) + units +
363 ', Capture: ' + videoCaptureLatency.toFixed(2) + 'ms' + 324 ', Capture: ' + videoCaptureLatency.toFixed(2) + 'ms' +
364 ', Encode: ' + videoEncodeLatency.toFixed(2) + 'ms' + 325 ', Encode: ' + videoEncodeLatency.toFixed(2) + 'ms' +
365 ', Decode: ' + videoDecodeLatency.toFixed(2) + 'ms' + 326 ', Decode: ' + videoDecodeLatency.toFixed(2) + 'ms' +
366 ', Render: ' + videoRenderLatency.toFixed(2) + 'ms'); 327 ', Render: ' + videoRenderLatency.toFixed(2) + 'ms');
367 328
368 // Update the stats once per second. 329 // Update the stats once per second.
369 window.setTimeout('updateStatusBarStats()', 1000); 330 window.setTimeout('updateStatusBarStats()', 1000);
370 } 331 }
OLDNEW
« no previous file with comments | « remoting/webapp/me2mom/remoting_session.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698