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

Side by Side Diff: remoting/webapp/client_session.js

Issue 10825187: Suppress "errors" that aren't really errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added JSCompiler hints. Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 * Class handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 /** @type {HTMLElement} @private */ 87 /** @type {HTMLElement} @private */
88 this.originalSize_ = document.getElementById('disable-shrink-to-fit'); 88 this.originalSize_ = document.getElementById('disable-shrink-to-fit');
89 /** @type {HTMLElement} @private */ 89 /** @type {HTMLElement} @private */
90 this.fullScreen_ = document.getElementById('toggle-full-screen'); 90 this.fullScreen_ = document.getElementById('toggle-full-screen');
91 91
92 this.shrinkToFit_.addEventListener('click', this.callEnableShrink_, false); 92 this.shrinkToFit_.addEventListener('click', this.callEnableShrink_, false);
93 this.originalSize_.addEventListener('click', this.callDisableShrink_, false); 93 this.originalSize_.addEventListener('click', this.callDisableShrink_, false);
94 this.fullScreen_.addEventListener('click', this.callToggleFullScreen_, false); 94 this.fullScreen_.addEventListener('click', this.callToggleFullScreen_, false);
95 /** @type {number?} @private */ 95 /** @type {number?} @private */
96 this.bumpScrollTimer_ = null; 96 this.bumpScrollTimer_ = null;
97 /**
98 * Allow error reporting to be suppressed in situations where it would not
99 * be useful, for example, when the device is offline.
100 *
101 * @type {boolean} @private
102 */
103 this.logErrors_ = true;
Wez 2012/08/07 00:01:00 There's a danger that we suppress logging and miss
Jamie 2012/08/07 00:37:04 We still log eof-session, and it will still have t
97 }; 104 };
98 105
99 // Note that the positive values in both of these enums are copied directly 106 // Note that the positive values in both of these enums are copied directly
100 // from chromoting_scriptable_object.h and must be kept in sync. The negative 107 // from chromoting_scriptable_object.h and must be kept in sync. The negative
101 // values represent states transitions that occur within the web-app that have 108 // values represent states transitions that occur within the web-app that have
102 // no corresponding plugin state transition. 109 // no corresponding plugin state transition.
103 /** @enum {number} */ 110 /** @enum {number} */
104 remoting.ClientSession.State = { 111 remoting.ClientSession.State = {
105 CREATED: -3, 112 CREATED: -3,
106 BAD_PLUGIN_VERSION: -2, 113 BAD_PLUGIN_VERSION: -2,
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 * @private 521 * @private
515 * @param {remoting.ClientSession.State} newState The new state for the session. 522 * @param {remoting.ClientSession.State} newState The new state for the session.
516 * @return {void} Nothing. 523 * @return {void} Nothing.
517 */ 524 */
518 remoting.ClientSession.prototype.setState_ = function(newState) { 525 remoting.ClientSession.prototype.setState_ = function(newState) {
519 var oldState = this.state; 526 var oldState = this.state;
520 this.state = newState; 527 this.state = newState;
521 if (this.onStateChange) { 528 if (this.onStateChange) {
522 this.onStateChange(oldState, newState); 529 this.onStateChange(oldState, newState);
523 } 530 }
524 this.logToServer.logClientSessionStateChange(this.state, this.error, 531 // If connection errors are being suppressed from the logs, translate
525 this.mode); 532 // FAILED to CLOSED here. This ensures that the duration is still logged.
533 var state = this.state;
534 if (this.state == remoting.ClientSession.State.FAILED &&
535 !this.logErrors_) {
536 console.log('Suppressing error.');
537 state = remoting.ClientSession.State.CLOSED;
538 }
539 this.logToServer.logClientSessionStateChange(state, this.error, this.mode);
526 }; 540 };
527 541
528 /** 542 /**
529 * This is a callback that gets called when the window is resized. 543 * This is a callback that gets called when the window is resized.
530 * 544 *
531 * @return {void} Nothing. 545 * @return {void} Nothing.
532 */ 546 */
533 remoting.ClientSession.prototype.onResize = function() { 547 remoting.ClientSession.prototype.onResize = function() {
534 this.updateDimensions(); 548 this.updateDimensions();
535 549
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 /** 656 /**
643 * Logs statistics. 657 * Logs statistics.
644 * 658 *
645 * @param {remoting.ClientSession.PerfStats} stats 659 * @param {remoting.ClientSession.PerfStats} stats
646 */ 660 */
647 remoting.ClientSession.prototype.logStatistics = function(stats) { 661 remoting.ClientSession.prototype.logStatistics = function(stats) {
648 this.logToServer.logStatistics(stats, this.mode); 662 this.logToServer.logStatistics(stats, this.mode);
649 }; 663 };
650 664
651 /** 665 /**
666 * Enable or disable logging of connection errors. For example, if attempting
667 * a connection using a cached JID, errors should not be logged because the
668 * JID will be refreshed and the connection retried.
669 *
670 * @param {boolean} enable True to log errors; false to suppress them.
671 */
672 remoting.ClientSession.prototype.logErrors = function(enable) {
673 this.logErrors_ = enable;
674 };
675
676 /**
652 * Toggles between full-screen and windowed mode. 677 * Toggles between full-screen and windowed mode.
653 * @return {void} Nothing. 678 * @return {void} Nothing.
654 * @private 679 * @private
655 */ 680 */
656 remoting.ClientSession.prototype.toggleFullScreen_ = function() { 681 remoting.ClientSession.prototype.toggleFullScreen_ = function() {
657 if (document.webkitIsFullScreen) { 682 if (document.webkitIsFullScreen) {
658 document.webkitCancelFullScreen(); 683 document.webkitCancelFullScreen();
659 this.enableBumpScroll_(false); 684 this.enableBumpScroll_(false);
660 } else { 685 } else {
661 document.body.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); 686 document.body.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 var lateAdjustment = 1 + (now - expected) / timeout; 816 var lateAdjustment = 1 + (now - expected) / timeout;
792 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) { 817 if (!that.scroll_(lateAdjustment * dx, lateAdjustment * dy)) {
793 that.bumpScrollTimer_ = window.setTimeout( 818 that.bumpScrollTimer_ = window.setTimeout(
794 function() { repeatScroll(now + timeout); }, 819 function() { repeatScroll(now + timeout); },
795 timeout); 820 timeout);
796 } 821 }
797 }; 822 };
798 repeatScroll(new Date().getTime()); 823 repeatScroll(new Date().getTime());
799 } 824 }
800 }; 825 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698