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

Unified Diff: remoting/webapp/crd/js/client_session.js

Issue 1004513002: Eliminated named constants for instances of remoting.Error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/base/js/application.js ('k') | remoting/webapp/crd/js/crd_connect.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/client_session.js
diff --git a/remoting/webapp/crd/js/client_session.js b/remoting/webapp/crd/js/client_session.js
index 3d58d15f9268132ff827936138466849350ffa23..a77be6934f6ad28c156d6c4f50d9aa5071c593c9 100644
--- a/remoting/webapp/crd/js/client_session.js
+++ b/remoting/webapp/crd/js/client_session.js
@@ -51,7 +51,7 @@ remoting.ClientSession = function(plugin, host, signalStrategy, mode,
this.state_ = remoting.ClientSession.State.CREATED;
/** @private {!remoting.Error} */
- this.error_ = remoting.Error.NONE;
+ this.error_ = remoting.Error.none();
/** @private */
this.host_ = host;
@@ -253,13 +253,13 @@ remoting.ClientSession.prototype.removePlugin = function() {
* dispose() to remove and destroy the <embed> element.
*
* @param {!remoting.Error} error The reason for the disconnection. Use
- * remoting.Error.NONE if there is no error.
+ * remoting.Error.none() if there is no error.
* @return {void} Nothing.
*/
remoting.ClientSession.prototype.disconnect = function(error) {
- var state = error.isError() ?
- remoting.ClientSession.State.FAILED :
- remoting.ClientSession.State.CLOSED;
+ var state = error.isNone() ?
+ remoting.ClientSession.State.CLOSED :
+ remoting.ClientSession.State.FAILED;
// The plugin won't send a state change notification, so we explicitly log
// the fact that the connection has closed.
@@ -392,22 +392,27 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate =
} else if (status == remoting.ClientSession.State.FAILED) {
switch (error) {
case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE:
- this.error_ = remoting.Error.HOST_IS_OFFLINE;
+ this.error_ = new remoting.Error(
+ remoting.Error.Tag.HOST_IS_OFFLINE);
break;
case remoting.ClientSession.ConnectionError.SESSION_REJECTED:
- this.error_ = remoting.Error.INVALID_ACCESS_CODE;
+ this.error_ = new remoting.Error(
+ remoting.Error.Tag.INVALID_ACCESS_CODE);
break;
case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL:
- this.error_ = remoting.Error.INCOMPATIBLE_PROTOCOL;
+ this.error_ = new remoting.Error(
+ remoting.Error.Tag.INCOMPATIBLE_PROTOCOL);
break;
case remoting.ClientSession.ConnectionError.NETWORK_FAILURE:
- this.error_ = remoting.Error.P2P_FAILURE;
+ this.error_ = new remoting.Error(
+ remoting.Error.Tag.P2P_FAILURE);
break;
case remoting.ClientSession.ConnectionError.HOST_OVERLOAD:
- this.error_ = remoting.Error.HOST_OVERLOAD;
+ this.error_ = new remoting.Error(
+ remoting.Error.Tag.HOST_OVERLOAD);
break;
default:
- this.error_ = remoting.Error.UNEXPECTED;
+ this.error_ = remoting.Error.unexpected();
}
}
this.setState_(status);
@@ -497,7 +502,7 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
if (this.state_ == remoting.ClientSession.State.CLOSED) {
state = remoting.ClientSession.State.CONNECTION_CANCELED;
} else if (this.state_ == remoting.ClientSession.State.FAILED &&
- this.error_.tag == remoting.Error.Tag.HOST_IS_OFFLINE &&
+ this.error_.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) &&
!this.logHostOfflineErrors_) {
// The application requested host-offline errors to be suppressed, for
// example, because this connection attempt is using a cached host JID.
@@ -599,7 +604,7 @@ remoting.ClientSession.prototype.sendGoogleDriveAccessToken_ = function() {
};
/** @param {!remoting.Error} error */
var sendError = function(error) {
- console.log('Failed to refresh access token: ' + error);
+ console.log('Failed to refresh access token: ' + error.toString());
};
remoting.identity.getNewToken().
then(sendToken).
« no previous file with comments | « remoting/webapp/base/js/application.js ('k') | remoting/webapp/crd/js/crd_connect.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698