From cb61f37e5f706260e86e7e95e91596408cf78e9c Mon Sep 17 00:00:00 2001 From: kelvinp Date: Tue, 10 Nov 2015 11:26:51 -0800 Subject: [Chromoting] Fix telemetry error in remoting.It2MeActivity 1. Excludes the access code entry time from the session duration. 2. Reports cancellation/error to the telemetry service if the main promise in It2meActivity.start() rejects. 3. Disposes DesktopRemotingActivity if the session fails to connect. BUG=549658 Review URL: https://codereview.chromium.org/1413923015 Cr-Commit-Position: refs/heads/master@{#358874} --- remoting/webapp/crd/js/it2me_activity.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'remoting') diff --git a/remoting/webapp/crd/js/it2me_activity.js b/remoting/webapp/crd/js/it2me_activity.js index c05d219..1e69c63 100644 --- a/remoting/webapp/crd/js/it2me_activity.js +++ b/remoting/webapp/crd/js/it2me_activity.js @@ -46,28 +46,41 @@ remoting.It2MeActivity.prototype.dispose = function() { remoting.It2MeActivity.prototype.start = function() { var that = this; + var SessionState = remoting.ChromotingEvent.SessionState; this.logger_ = this.createLogger_(); - this.logger_.logSessionStateChange( - remoting.ChromotingEvent.SessionState.STARTED); + this.logger_.logSessionStateChange(SessionState.STARTED); + console.assert( + !this.desktopActivity_, 'Zombie DesktopActivity from previous session'); + base.dispose(this.desktopActivity_); this.desktopActivity_ = new remoting.DesktopRemotingActivity(this, this.logger_); + function onError(/** remoting.Error */ error) { + if (error.isCancel()) { + that.logger_.logSessionStateChange(SessionState.CONNECTION_CANCELED); + remoting.setMode(remoting.AppMode.HOME); + } else { + that.logger_.logSessionStateChange(SessionState.CONNECTION_FAILED, error); + that.showErrorMessage_(error); + } + + base.dispose(that.desktopActivity_); + that.desktopActivity_ = null; + } + + var sessionStart = Date.now(); + this.accessCodeDialog_.show().then(function(/** string */ accessCode) { + that.logger_.setAuthTotalTime(Date.now() - sessionStart); that.desktopActivity_.getConnectingDialog().show(); return that.verifyAccessCode_(accessCode); }).then(function() { return remoting.HostListApi.getInstance().getSupportHost(that.hostId_); }).then(function(/** remoting.Host */ host) { that.connect_(host); - }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { - if (error.hasTag(remoting.Error.Tag.CANCELLED)) { - remoting.setMode(remoting.AppMode.HOME); - } else { - that.showErrorMessage_(error); - } - })); + }).catch(remoting.Error.handler(onError)); }; -- cgit v1.1