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

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

Issue 1410563006: [Chromoting] SessionLogger refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE); 465 new remoting.Error(remoting.Error.Tag.INVALID_ACCESS_CODE);
466 break; 466 break;
467 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: 467 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL:
468 this.error_ = 468 this.error_ =
469 new remoting.Error(remoting.Error.Tag.INCOMPATIBLE_PROTOCOL); 469 new remoting.Error(remoting.Error.Tag.INCOMPATIBLE_PROTOCOL);
470 break; 470 break;
471 case remoting.ClientSession.ConnectionError.NETWORK_FAILURE: 471 case remoting.ClientSession.ConnectionError.NETWORK_FAILURE:
472 this.error_ = new remoting.Error(remoting.Error.Tag.P2P_FAILURE); 472 this.error_ = new remoting.Error(remoting.Error.Tag.P2P_FAILURE);
473 break; 473 break;
474 case remoting.ClientSession.ConnectionError.HOST_OVERLOAD: 474 case remoting.ClientSession.ConnectionError.HOST_OVERLOAD:
475 this.error_ = new remoting.Error(remoting.Error.Tag.HOST_OVERLOAD); 475 this.error_ = new remoting.Error(
476 remoting.Error.Tag.HOST_OVERLOAD,
477 this.xmppErrorCache_.getFirstErrorStanza());
476 break; 478 break;
477 case remoting.ClientSession.ConnectionError.MAX_SESSION_LENGTH: 479 case remoting.ClientSession.ConnectionError.MAX_SESSION_LENGTH:
478 this.error_ = new remoting.Error(remoting.Error.Tag.MAX_SESSION_LENGTH); 480 this.error_ = new remoting.Error(remoting.Error.Tag.MAX_SESSION_LENGTH);
479 break; 481 break;
480 case remoting.ClientSession.ConnectionError.HOST_CONFIGURATION_ERROR: 482 case remoting.ClientSession.ConnectionError.HOST_CONFIGURATION_ERROR:
481 this.error_ = 483 this.error_ =
482 new remoting.Error(remoting.Error.Tag.HOST_CONFIGURATION_ERROR); 484 new remoting.Error(remoting.Error.Tag.HOST_CONFIGURATION_ERROR);
483 break; 485 break;
484 default: 486 default:
485 this.error_ = remoting.Error.unexpected(); 487 this.error_ = remoting.Error.unexpected();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 557 }
556 } else if (this.isFinished()) { 558 } else if (this.isFinished()) {
557 base.dispose(this.connectedDisposables_); 559 base.dispose(this.connectedDisposables_);
558 this.connectedDisposables_ = null; 560 this.connectedDisposables_ = null;
559 } 561 }
560 562
561 this.logAuthMethod_(); 563 this.logAuthMethod_();
562 this.notifyStateChanges_(oldState, this.state_); 564 this.notifyStateChanges_(oldState, this.state_);
563 // Record state count in an UMA enumerated histogram. 565 // Record state count in an UMA enumerated histogram.
564 recordState(this.state_); 566 recordState(this.state_);
565 this.logger_.logClientSessionStateChange( 567 this.logger_.logSessionStateChange(toSessionState(this.state_), this.error_);
Jamie 2015/11/09 18:46:02 This is a change in semantics. Previously, getFirs
kelvinp 2015/11/09 22:59:10 Good catch.
566 this.state_, this.error_, this.xmppErrorCache_.getFirstError());
567 }; 568 };
568 569
569 /** @private */ 570 /** @private */
570 remoting.ClientSession.prototype.logAuthMethod_ = function() { 571 remoting.ClientSession.prototype.logAuthMethod_ = function() {
571 // The AuthMethod is undefined before the AUTHENTICATED stage for a 572 // The AuthMethod is undefined before the AUTHENTICATED stage for a
572 // successful connection or the FAILED stage for a failed connection. 573 // successful connection or the FAILED stage for a failed connection.
573 if (this.state_ == remoting.ClientSession.State.AUTHENTICATED || 574 if (this.state_ == remoting.ClientSession.State.AUTHENTICATED ||
574 this.state_ == remoting.ClientSession.State.FAILED) { 575 this.state_ == remoting.ClientSession.State.FAILED) {
575 var authMethod = this.credentialsProvider_.getAuthMethod(); 576 var authMethod = this.credentialsProvider_.getAuthMethod();
576 if (authMethod != null) { 577 if (authMethod != null) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 console.error('Connection dropped: ' + error.toString()); 655 console.error('Connection dropped: ' + error.toString());
655 this.listener_.onDisconnected(error); 656 this.listener_.onDisconnected(error);
656 break; 657 break;
657 658
658 default: 659 default:
659 console.error('Unexpected client plugin state: ' + newState); 660 console.error('Unexpected client plugin state: ' + newState);
660 } 661 }
661 }; 662 };
662 663
663 /** 664 /**
665 * TODO(kelvinp): Consolidate the two enums (crbug.com/504200)
666 * @param {remoting.ClientSession.State} state
667 * @return {remoting.ChromotingEvent.SessionState}
668 */
669 function toSessionState(state) {
670 var SessionState = remoting.ChromotingEvent.SessionState;
671 switch(state) {
672 case remoting.ClientSession.State.UNKNOWN:
673 return SessionState.UNKNOWN;
674 case remoting.ClientSession.State.INITIALIZING:
675 return SessionState.INITIALIZING;
676 case remoting.ClientSession.State.CONNECTING:
677 return SessionState.CONNECTING;
678 case remoting.ClientSession.State.AUTHENTICATED:
679 return SessionState.AUTHENTICATED;
680 case remoting.ClientSession.State.CONNECTED:
681 return SessionState.CONNECTED;
682 case remoting.ClientSession.State.CLOSED:
683 return SessionState.CLOSED;
684 case remoting.ClientSession.State.FAILED:
685 return SessionState.CONNECTION_FAILED;
686 case remoting.ClientSession.State.CONNECTION_DROPPED:
687 return SessionState.CONNECTION_DROPPED;
688 case remoting.ClientSession.State.CONNECTION_CANCELED:
689 return SessionState.CONNECTION_CANCELED;
690 default:
691 throw new Error('Unknown session state : ' + state);
692 }
693 }
694
695 /**
664 * @param {remoting.ClientSession.State} previous 696 * @param {remoting.ClientSession.State} previous
665 * @param {remoting.ClientSession.State} current 697 * @param {remoting.ClientSession.State} current
666 * @return {remoting.ClientSession.State} 698 * @return {remoting.ClientSession.State}
667 * @private 699 * @private
668 */ 700 */
669 remoting.ClientSession.prototype.translateState_ = function(previous, current) { 701 remoting.ClientSession.prototype.translateState_ = function(previous, current) {
670 var State = remoting.ClientSession.State; 702 var State = remoting.ClientSession.State;
671 if (previous == State.CONNECTING || previous == State.AUTHENTICATED) { 703 if (previous == State.CONNECTING || previous == State.AUTHENTICATED) {
672 if (current == State.CLOSED) { 704 if (current == State.CLOSED) {
673 return remoting.ClientSession.State.CONNECTION_CANCELED; 705 return remoting.ClientSession.State.CONNECTION_CANCELED;
674 } 706 }
675 } else if (previous == State.CONNECTED && current == State.FAILED) { 707 } else if (previous == State.CONNECTED && current == State.FAILED) {
676 return State.CONNECTION_DROPPED; 708 return State.CONNECTION_DROPPED;
677 } 709 }
678 return current; 710 return current;
679 }; 711 };
680 712
681 /** @private */ 713 /** @private */
682 remoting.ClientSession.prototype.reportStatistics = function() { 714 remoting.ClientSession.prototype.reportStatistics = function() {
683 this.logger_.logStatistics(this.plugin_.getPerfStats()); 715 this.logger_.logStatistics(this.plugin_.getPerfStats());
684 }; 716 };
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/base/js/client_session_factory.js » ('j') | remoting/webapp/base/js/client_session_factory.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698