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 base.dispose(this.desktopActivity_); | |
Jamie
2015/11/09 18:16:45
Do you ever expect desktopActivity to be non-null?
| |
54 this.desktopActivity_ = | 55 this.desktopActivity_ = |
55 new remoting.DesktopRemotingActivity(this, this.logger_); | 56 new remoting.DesktopRemotingActivity(this, this.logger_); |
56 | 57 |
58 function onError(/** remoting.Error */ error) { | |
59 if (error.isCancel()) { | |
60 that.logger_.logSessionStateChange(SessionState.CONNECTION_CANCELED); | |
61 remoting.setMode(remoting.AppMode.HOME); | |
62 } else { | |
63 that.logger_.logSessionStateChange(SessionState.CONNECTION_FAILED, error); | |
64 that.showErrorMessage_(error); | |
65 } | |
66 | |
67 base.dispose(that.desktopActivity_); | |
68 that.desktopActivity_ = null; | |
69 } | |
70 | |
71 var sessionStart = Date.now(); | |
72 | |
57 this.accessCodeDialog_.show().then(function(/** string */ accessCode) { | 73 this.accessCodeDialog_.show().then(function(/** string */ accessCode) { |
74 that.logger_.setAuthTotalTime(Date.now() - sessionStart); | |
58 that.desktopActivity_.getConnectingDialog().show(); | 75 that.desktopActivity_.getConnectingDialog().show(); |
59 return that.verifyAccessCode_(accessCode); | 76 return that.verifyAccessCode_(accessCode); |
60 }).then(function() { | 77 }).then(function() { |
61 return remoting.HostListApi.getInstance().getSupportHost(that.hostId_); | 78 return remoting.HostListApi.getInstance().getSupportHost(that.hostId_); |
62 }).then(function(/** remoting.Host */ host) { | 79 }).then(function(/** remoting.Host */ host) { |
63 that.connect_(host); | 80 that.connect_(host); |
64 }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { | 81 }).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 }; | 82 }; |
72 | 83 |
73 | 84 |
74 /** | 85 /** |
75 * @return {!remoting.SessionLogger} | 86 * @return {!remoting.SessionLogger} |
76 * @private | 87 * @private |
77 */ | 88 */ |
78 remoting.It2MeActivity.prototype.createLogger_ = function() { | 89 remoting.It2MeActivity.prototype.createLogger_ = function() { |
79 var Event = remoting.ChromotingEvent; | 90 var Event = remoting.ChromotingEvent; |
80 var logger = remoting.SessionLogger.createForClient(); | 91 var logger = remoting.SessionLogger.createForClient(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 /** | 176 /** |
166 * @param {remoting.Host} host | 177 * @param {remoting.Host} host |
167 * @private | 178 * @private |
168 */ | 179 */ |
169 remoting.It2MeActivity.prototype.connect_ = function(host) { | 180 remoting.It2MeActivity.prototype.connect_ = function(host) { |
170 this.desktopActivity_.start( | 181 this.desktopActivity_.start( |
171 host, new remoting.CredentialsProvider({accessCode: this.passCode_})); | 182 host, new remoting.CredentialsProvider({accessCode: this.passCode_})); |
172 }; | 183 }; |
173 | 184 |
174 })(); | 185 })(); |
OLD | NEW |