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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 28 matching lines...) Expand all
39 * @constructor 39 * @constructor
40 * @extends {base.EventSourceImpl} 40 * @extends {base.EventSourceImpl}
41 * @implements {base.Disposable} 41 * @implements {base.Disposable}
42 * @implements {remoting.ClientPlugin.ConnectionEventHandler} 42 * @implements {remoting.ClientPlugin.ConnectionEventHandler}
43 */ 43 */
44 remoting.ClientSession = function(plugin, host, signalStrategy, mode) { 44 remoting.ClientSession = function(plugin, host, signalStrategy, mode) {
45 /** @private */ 45 /** @private */
46 this.state_ = remoting.ClientSession.State.CREATED; 46 this.state_ = remoting.ClientSession.State.CREATED;
47 47
48 /** @private {!remoting.Error} */ 48 /** @private {!remoting.Error} */
49 this.error_ = remoting.Error.NONE; 49 this.error_ = remoting.Error.none();
50 50
51 /** @private */ 51 /** @private */
52 this.host_ = host; 52 this.host_ = host;
53 53
54 /** @private */ 54 /** @private */
55 this.sessionId_ = ''; 55 this.sessionId_ = '';
56 56
57 /** @private */ 57 /** @private */
58 this.hasReceivedFrame_ = false; 58 this.hasReceivedFrame_ = false;
59 this.logToServer = new remoting.LogToServer(signalStrategy, mode); 59 this.logToServer = new remoting.LogToServer(signalStrategy, mode);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 remoting.ClientSession.prototype.removePlugin = function() { 248 remoting.ClientSession.prototype.removePlugin = function() {
249 this.plugin_ = null; 249 this.plugin_ = null;
250 }; 250 };
251 251
252 /** 252 /**
253 * Disconnect the current session with a particular |error|. The session will 253 * Disconnect the current session with a particular |error|. The session will
254 * raise a |stateChanged| event in response to it. The caller should then call 254 * raise a |stateChanged| event in response to it. The caller should then call
255 * dispose() to remove and destroy the <embed> element. 255 * dispose() to remove and destroy the <embed> element.
256 * 256 *
257 * @param {!remoting.Error} error The reason for the disconnection. Use 257 * @param {!remoting.Error} error The reason for the disconnection. Use
258 * remoting.Error.NONE if there is no error. 258 * remoting.Error.none() if there is no error.
259 * @return {void} Nothing. 259 * @return {void} Nothing.
260 */ 260 */
261 remoting.ClientSession.prototype.disconnect = function(error) { 261 remoting.ClientSession.prototype.disconnect = function(error) {
262 var state = error.isError() ? 262 var state = error.isError() ?
263 remoting.ClientSession.State.FAILED : 263 remoting.ClientSession.State.FAILED :
264 remoting.ClientSession.State.CLOSED; 264 remoting.ClientSession.State.CLOSED;
265 265
266 // The plugin won't send a state change notification, so we explicitly log 266 // The plugin won't send a state change notification, so we explicitly log
267 // the fact that the connection has closed. 267 // the fact that the connection has closed.
268 this.logToServer.logClientSessionStateChange(state, error); 268 this.logToServer.logClientSessionStateChange(state, error);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 * state, if any. 388 * state, if any.
389 */ 389 */
390 remoting.ClientSession.prototype.onConnectionStatusUpdate = 390 remoting.ClientSession.prototype.onConnectionStatusUpdate =
391 function(status, error) { 391 function(status, error) {
392 if (status == remoting.ClientSession.State.CONNECTED) { 392 if (status == remoting.ClientSession.State.CONNECTED) {
393 remoting.desktopConnectedView.updateClientSessionUi_(this); 393 remoting.desktopConnectedView.updateClientSessionUi_(this);
394 394
395 } else if (status == remoting.ClientSession.State.FAILED) { 395 } else if (status == remoting.ClientSession.State.FAILED) {
396 switch (error) { 396 switch (error) {
397 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: 397 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE:
398 this.error_ = remoting.Error.HOST_IS_OFFLINE; 398 this.error_ = new remoting.Error(
399 remoting.Error.Tag.HOST_IS_OFFLINE);
399 break; 400 break;
400 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: 401 case remoting.ClientSession.ConnectionError.SESSION_REJECTED:
401 this.error_ = remoting.Error.INVALID_ACCESS_CODE; 402 this.error_ = new remoting.Error(
403 remoting.Error.Tag.INVALID_ACCESS_CODE);
402 break; 404 break;
403 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: 405 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL:
404 this.error_ = remoting.Error.INCOMPATIBLE_PROTOCOL; 406 this.error_ = new remoting.Error(
407 remoting.Error.Tag.INCOMPATIBLE_PROTOCOL);
405 break; 408 break;
406 case remoting.ClientSession.ConnectionError.NETWORK_FAILURE: 409 case remoting.ClientSession.ConnectionError.NETWORK_FAILURE:
407 this.error_ = remoting.Error.P2P_FAILURE; 410 this.error_ = new remoting.Error(
411 remoting.Error.Tag.P2P_FAILURE);
408 break; 412 break;
409 case remoting.ClientSession.ConnectionError.HOST_OVERLOAD: 413 case remoting.ClientSession.ConnectionError.HOST_OVERLOAD:
410 this.error_ = remoting.Error.HOST_OVERLOAD; 414 this.error_ = new remoting.Error(
415 remoting.Error.Tag.HOST_OVERLOAD);
411 break; 416 break;
412 default: 417 default:
413 this.error_ = remoting.Error.UNEXPECTED; 418 this.error_ = remoting.Error.unexpected();
414 } 419 }
415 } 420 }
416 this.setState_(status); 421 this.setState_(status);
417 }; 422 };
418 423
419 /** 424 /**
420 * Callback that the plugin invokes to indicate that the connection type for 425 * Callback that the plugin invokes to indicate that the connection type for
421 * a channel has changed. 426 * a channel has changed.
422 * 427 *
423 * @param {string} channel The channel name. 428 * @param {string} channel The channel name.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 */ 713 */
709 remoting.ClientSession.prototype.enableDebugRegion = function(enable) { 714 remoting.ClientSession.prototype.enableDebugRegion = function(enable) {
710 if (enable) { 715 if (enable) {
711 this.plugin_.setDebugDirtyRegionHandler( 716 this.plugin_.setDebugDirtyRegionHandler(
712 remoting.desktopConnectedView.handleDebugRegion.bind( 717 remoting.desktopConnectedView.handleDebugRegion.bind(
713 remoting.desktopConnectedView)); 718 remoting.desktopConnectedView));
714 } else { 719 } else {
715 this.plugin_.setDebugDirtyRegionHandler(null); 720 this.plugin_.setDebugDirtyRegionHandler(null);
716 } 721 }
717 } 722 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698