summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorkelvinp <kelvinp@chromium.org>2015-10-09 13:48:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-09 20:49:32 +0000
commit6128404bfc3e3f07e86627049d10293d274ab08f (patch)
treec43e066554df66839704a2c8b47bc6189e30c5a7 /remoting
parent9bdd4a4a9b0062684a110885c368b38477ac5ba2 (diff)
downloadchromium_src-6128404bfc3e3f07e86627049d10293d274ab08f.zip
chromium_src-6128404bfc3e3f07e86627049d10293d274ab08f.tar.gz
chromium_src-6128404bfc3e3f07e86627049d10293d274ab08f.tar.bz2
Report connection cancellation due to host version mismatch.
BUG=539927 Review URL: https://codereview.chromium.org/1395893003 Cr-Commit-Position: refs/heads/master@{#353378}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/webapp/base/js/chromoting_event.js2
-rw-r--r--remoting/webapp/base/js/client_session_factory.js6
-rw-r--r--remoting/webapp/base/js/error.js58
-rw-r--r--remoting/webapp/base/js/server_log_entry.js2
-rw-r--r--remoting/webapp/base/js/session_logger.js42
-rw-r--r--remoting/webapp/crd/js/me2me_activity.js26
6 files changed, 82 insertions, 54 deletions
diff --git a/remoting/webapp/base/js/chromoting_event.js b/remoting/webapp/base/js/chromoting_event.js
index c0c9e67..fad1074 100644
--- a/remoting/webapp/base/js/chromoting_event.js
+++ b/remoting/webapp/base/js/chromoting_event.js
@@ -258,7 +258,7 @@ remoting.ChromotingEvent.ConnectionError = {
INVALID_ACCESS_CODE: 7,
MISSING_PLUGIN: 8,
AUTHENTICATION_FAILED: 9,
- ERROR_BAD_PLUGIN_VERSION: 10,
+ BAD_VERSION: 10,
HOST_OVERLOAD: 11,
P2P_FAILURE: 12,
UNEXPECTED: 13,
diff --git a/remoting/webapp/base/js/client_session_factory.js b/remoting/webapp/base/js/client_session_factory.js
index 0dcadbd..e25b6f4 100644
--- a/remoting/webapp/base/js/client_session_factory.js
+++ b/remoting/webapp/base/js/client_session_factory.js
@@ -133,11 +133,7 @@ function createPlugin(container, capabilities) {
*/
function toConnectionError(/** Error */ e) {
if (e instanceof remoting.Error) {
- if (e.getTag() == remoting.Error.Tag.MISSING_PLUGIN) {
- return remoting.ChromotingEvent.ConnectionError.MISSING_PLUGIN;
- } else if (e.getTag() == remoting.Error.Tag.NACL_DISABLED) {
- return remoting.ChromotingEvent.ConnectionError.NACL_DISABLED;
- }
+ return e.toConnectionError();
}
return remoting.ChromotingEvent.ConnectionError.UNEXPECTED;
}
diff --git a/remoting/webapp/base/js/error.js b/remoting/webapp/base/js/error.js
index fa1684d..23ee1f8 100644
--- a/remoting/webapp/base/js/error.js
+++ b/remoting/webapp/base/js/error.js
@@ -36,6 +36,54 @@ remoting.Error.prototype.toString = function() {
};
/**
+ * @return {remoting.ChromotingEvent.ConnectionError} error
+ */
+remoting.Error.prototype.toConnectionError = function() {
+ var Tag = remoting.Error.Tag;
+ var ConnectionError = remoting.ChromotingEvent.ConnectionError;
+ switch (this.tag_) {
+ case Tag.NONE:
+ return ConnectionError.NONE;
+ case Tag.CLIENT_SUSPENDED:
+ return ConnectionError.CLIENT_SUSPENDED;
+ case Tag.INVALID_ACCESS_CODE:
+ return ConnectionError.INVALID_ACCESS_CODE;
+ case Tag.MISSING_PLUGIN:
+ return ConnectionError.MISSING_PLUGIN;
+ case Tag.AUTHENTICATION_FAILED:
+ return ConnectionError.AUTHENTICATION_FAILED;
+ case Tag.HOST_IS_OFFLINE:
+ return ConnectionError.HOST_OFFLINE;
+ case Tag.INCOMPATIBLE_PROTOCOL:
+ return ConnectionError.INCOMPATIBLE_PROTOCOL;
+ case Tag.BAD_VERSION:
+ return ConnectionError.BAD_VERSION;
+ case Tag.NETWORK_FAILURE:
+ return ConnectionError.NETWORK_FAILURE;
+ case Tag.HOST_OVERLOAD:
+ return ConnectionError.HOST_OVERLOAD;
+ case Tag.P2P_FAILURE:
+ return ConnectionError.P2P_FAILURE;
+ case Tag.NACL_DISABLED:
+ return ConnectionError.NACL_DISABLED;
+ case Tag.UNEXPECTED:
+ return ConnectionError.UNEXPECTED;
+ // For errors that don't have a corresponding ConnectionError mapping,
+ // default to Error.UNKNOWN_ERROR.
+ case Tag.SERVICE_UNAVAILABLE:
+ case Tag.NOT_AUTHENTICATED:
+ case Tag.NOT_FOUND:
+ case Tag.INVALID_HOST_DOMAIN:
+ case Tag.REGISTRATION_FAILED:
+ case Tag.NOT_AUTHORIZED:
+ case Tag.APP_NOT_AUTHORIZED:
+ case Tag.CANCELLED:
+ return ConnectionError.UNKNOWN_ERROR;
+ }
+ return ConnectionError.UNKNOWN_ERROR;
+};
+
+/**
* @return {remoting.Error.Tag} The tag used to create this Error.
*/
remoting.Error.prototype.getTag = function() {
@@ -74,6 +122,14 @@ remoting.Error.prototype.isNone = function() {
};
/**
+ * @return {boolean} True if this object's tag is CANCELLED, meaning this
+ * object represents the lack of an error.
+ */
+remoting.Error.prototype.isCancel = function() {
+ return this.hasTag(remoting.Error.Tag.CANCELLED);
+};
+
+/**
* Convenience method for creating the second most common error type.
* @return {!remoting.Error}
*/
@@ -111,7 +167,7 @@ remoting.Error.Tag = {
AUTHENTICATION_FAILED: /*i18n-content*/ 'ERROR_AUTHENTICATION_FAILED',
HOST_IS_OFFLINE: /*i18n-content*/ 'ERROR_HOST_IS_OFFLINE',
INCOMPATIBLE_PROTOCOL: /*i18n-content*/ 'ERROR_INCOMPATIBLE_PROTOCOL',
- BAD_PLUGIN_VERSION: /*i18n-content*/ 'ERROR_BAD_PLUGIN_VERSION',
+ BAD_VERSION: /*i18n-content*/ 'ERROR_BAD_PLUGIN_VERSION',
NETWORK_FAILURE: /*i18n-content*/ 'ERROR_NETWORK_FAILURE',
HOST_OVERLOAD: /*i18n-content*/ 'ERROR_HOST_OVERLOAD',
UNEXPECTED: /*i18n-content*/ 'ERROR_UNEXPECTED',
diff --git a/remoting/webapp/base/js/server_log_entry.js b/remoting/webapp/base/js/server_log_entry.js
index 2e5d856..d63f13e 100644
--- a/remoting/webapp/base/js/server_log_entry.js
+++ b/remoting/webapp/base/js/server_log_entry.js
@@ -106,7 +106,7 @@ remoting.ServerLogEntry.getValueForError_ = function(connectionError) {
return 'host-is-offline';
case remoting.Error.Tag.INCOMPATIBLE_PROTOCOL:
return 'incompatible-protocol';
- case remoting.Error.Tag.BAD_PLUGIN_VERSION:
+ case remoting.Error.Tag.BAD_VERSION:
return 'bad-plugin-version';
case remoting.Error.Tag.NETWORK_FAILURE:
return 'network-failure';
diff --git a/remoting/webapp/base/js/session_logger.js b/remoting/webapp/base/js/session_logger.js
index be7c6dc..34490f6 100644
--- a/remoting/webapp/base/js/session_logger.js
+++ b/remoting/webapp/base/js/session_logger.js
@@ -125,10 +125,10 @@ remoting.SessionLogger.prototype.logSignalStrategyProgress =
/** @override {remoting.Logger} */
remoting.SessionLogger.prototype.logClientSessionStateChange = function(
- state, connectionError, xmppError) {
+ state, stateError, xmppError) {
this.logSessionStateChange(
toSessionState(state),
- toConnectionError(connectionError),
+ stateError.toConnectionError(),
xmppError);
};
@@ -366,44 +366,6 @@ function toSessionState(state) {
}
/**
- * @param {remoting.Error} error
- * @return {remoting.ChromotingEvent.ConnectionError}
- */
-function toConnectionError(error) {
- var ConnectionError = remoting.ChromotingEvent.ConnectionError;
- switch (error.getTag()) {
- case remoting.Error.Tag.NONE:
- return ConnectionError.NONE;
- case remoting.Error.Tag.INVALID_ACCESS_CODE:
- return ConnectionError.INVALID_ACCESS_CODE;
- case remoting.Error.Tag.MISSING_PLUGIN:
- return ConnectionError.MISSING_PLUGIN;
- case remoting.Error.Tag.AUTHENTICATION_FAILED:
- return ConnectionError.AUTHENTICATION_FAILED;
- case remoting.Error.Tag.HOST_IS_OFFLINE:
- return ConnectionError.HOST_OFFLINE;
- case remoting.Error.Tag.INCOMPATIBLE_PROTOCOL:
- return ConnectionError.INCOMPATIBLE_PROTOCOL;
- case remoting.Error.Tag.BAD_PLUGIN_VERSION:
- return ConnectionError.ERROR_BAD_PLUGIN_VERSION;
- case remoting.Error.Tag.NETWORK_FAILURE:
- return ConnectionError.NETWORK_FAILURE;
- case remoting.Error.Tag.HOST_OVERLOAD:
- return ConnectionError.HOST_OVERLOAD;
- case remoting.Error.Tag.P2P_FAILURE:
- return ConnectionError.P2P_FAILURE;
- case remoting.Error.Tag.CLIENT_SUSPENDED:
- return ConnectionError.CLIENT_SUSPENDED;
- case remoting.Error.Tag.UNEXPECTED:
- return ConnectionError.UNEXPECTED;
- case remoting.Error.Tag.NACL_DISABLED:
- return ConnectionError.NACL_DISABLED;
- default:
- throw new Error('Unknown error Tag : ' + error.getTag());
- }
-}
-
-/**
* @param {remoting.SignalStrategy.Type} type
* @return {remoting.ChromotingEvent.SignalStrategyType}
*/
diff --git a/remoting/webapp/crd/js/me2me_activity.js b/remoting/webapp/crd/js/me2me_activity.js
index 57b1fd7..a366fe1 100644
--- a/remoting/webapp/crd/js/me2me_activity.js
+++ b/remoting/webapp/crd/js/me2me_activity.js
@@ -57,15 +57,29 @@ remoting.Me2MeActivity.prototype.start = function() {
this.logger_.logSessionStateChange(Event.SessionState.STARTED,
Event.ConnectionError.NONE);
+ var errorTag = Event.ConnectionError.NONE;
+
+ function handleError(/** remoting.Error */ error) {
+ if (error.isCancel()) {
+ remoting.setMode(remoting.AppMode.HOME);
+ that.logger_.logSessionStateChange(Event.SessionState.CONNECTION_CANCELED,
+ errorTag);
+ } else {
+ that.logger_.logSessionStateChange(Event.SessionState.CONNECTION_FAILED,
+ error.toConnectionError());
+ that.showErrorMessage_(error);
+ }
+ }
+
this.hostUpdateDialog_.showIfNecessary(webappVersion).then(function() {
return that.host_.options.load();
- }).then(function() {
- that.connect_();
}).catch(remoting.Error.handler(function(/** remoting.Error */ error) {
- if (error.hasTag(remoting.Error.Tag.CANCELLED)) {
- remoting.setMode(remoting.AppMode.HOME);
- }
- }));
+ // User cancels out of the Host upgrade dialog. Report it as bad version.
+ errorTag = Event.ConnectionError.BAD_VERSION;
+ throw error;
+ })).then(
+ this.connect_.bind(this)
+ ).catch(remoting.Error.handler(handleError));
};
remoting.Me2MeActivity.prototype.stop = function() {