OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @suppress {duplicate} */ | 5 /** @suppress {duplicate} */ |
6 var remoting = remoting || {}; | 6 var remoting = remoting || {}; |
7 | 7 |
8 (function() { | 8 (function() { |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 }; | 40 }; |
41 | 41 |
42 remoting.It2MeActivity.prototype.dispose = function() { | 42 remoting.It2MeActivity.prototype.dispose = function() { |
43 base.dispose(this.desktopActivity_); | 43 base.dispose(this.desktopActivity_); |
44 this.desktopActivity_ = null; | 44 this.desktopActivity_ = null; |
45 }; | 45 }; |
46 | 46 |
47 remoting.It2MeActivity.prototype.start = function() { | 47 remoting.It2MeActivity.prototype.start = function() { |
48 var that = this; | 48 var that = this; |
| 49 var SessionState = remoting.ChromotingEvent.SessionState; |
49 | 50 |
50 this.logger_ = this.createLogger_(); | 51 this.logger_ = this.createLogger_(); |
51 this.logger_.logSessionStateChange( | 52 this.logger_.logSessionStateChange(SessionState.STARTED); |
52 remoting.ChromotingEvent.SessionState.STARTED); | |
53 | 53 |
| 54 console.assert( |
| 55 !this.desktopActivity_, 'Zombie DesktopActivity from previous session'); |
| 56 base.dispose(this.desktopActivity_); |
54 this.desktopActivity_ = | 57 this.desktopActivity_ = |
55 new remoting.DesktopRemotingActivity(this, this.logger_); | 58 new remoting.DesktopRemotingActivity(this, this.logger_); |
56 | 59 |
| 60 function onError(/** remoting.Error */ error) { |
| 61 if (error.isCancel()) { |
| 62 that.logger_.logSessionStateChange(SessionState.CONNECTION_CANCELED); |
| 63 remoting.setMode(remoting.AppMode.HOME); |
| 64 } else { |
| 65 that.logger_.logSessionStateChange(SessionState.CONNECTION_FAILED, error); |
| 66 that.showErrorMessage_(error); |
| 67 } |
| 68 |
| 69 base.dispose(that.desktopActivity_); |
| 70 that.desktopActivity_ = null; |
| 71 } |
| 72 |
| 73 var sessionStart = Date.now(); |
| 74 |
57 this.accessCodeDialog_.show().then(function(/** string */ accessCode) { | 75 this.accessCodeDialog_.show().then(function(/** string */ accessCode) { |
| 76 that.logger_.setAuthTotalTime(Date.now() - sessionStart); |
58 that.desktopActivity_.getConnectingDialog().show(); | 77 that.desktopActivity_.getConnectingDialog().show(); |
59 return that.verifyAccessCode_(accessCode); | 78 return that.verifyAccessCode_(accessCode); |
60 }).then(function() { | 79 }).then(function() { |
61 return remoting.HostListApi.getInstance().getSupportHost(that.hostId_); | 80 return remoting.HostListApi.getInstance().getSupportHost(that.hostId_); |
62 }).then(function(/** remoting.Host */ host) { | 81 }).then(function(/** remoting.Host */ host) { |
63 that.connect_(host); | 82 that.connect_(host); |
64 }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { | 83 }).catch(remoting.Error.handler(onError)); |
65 if (error.hasTag(remoting.Error.Tag.CANCELLED)) { | |
66 remoting.setMode(remoting.AppMode.HOME); | |
67 } else { | |
68 that.showErrorMessage_(error); | |
69 } | |
70 })); | |
71 }; | 84 }; |
72 | 85 |
73 | 86 |
74 /** | 87 /** |
75 * @return {!remoting.SessionLogger} | 88 * @return {!remoting.SessionLogger} |
76 * @private | 89 * @private |
77 */ | 90 */ |
78 remoting.It2MeActivity.prototype.createLogger_ = function() { | 91 remoting.It2MeActivity.prototype.createLogger_ = function() { |
79 var Event = remoting.ChromotingEvent; | 92 var Event = remoting.ChromotingEvent; |
80 var logger = remoting.SessionLogger.createForClient(); | 93 var logger = remoting.SessionLogger.createForClient(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 /** | 178 /** |
166 * @param {remoting.Host} host | 179 * @param {remoting.Host} host |
167 * @private | 180 * @private |
168 */ | 181 */ |
169 remoting.It2MeActivity.prototype.connect_ = function(host) { | 182 remoting.It2MeActivity.prototype.connect_ = function(host) { |
170 this.desktopActivity_.start( | 183 this.desktopActivity_.start( |
171 host, new remoting.CredentialsProvider({accessCode: this.passCode_})); | 184 host, new remoting.CredentialsProvider({accessCode: this.passCode_})); |
172 }; | 185 }; |
173 | 186 |
174 })(); | 187 })(); |
OLD | NEW |