OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Connect set-up state machine for Me2Me and IT2Me | 7 * Connect set-up state machine for Me2Me and IT2Me |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 }; | 334 }; |
335 | 335 |
336 /** | 336 /** |
337 * @param {boolean} initialized | 337 * @param {boolean} initialized |
338 * @private | 338 * @private |
339 */ | 339 */ |
340 remoting.SessionConnectorImpl.prototype.onPluginInitialized_ = function( | 340 remoting.SessionConnectorImpl.prototype.onPluginInitialized_ = function( |
341 initialized) { | 341 initialized) { |
342 if (!initialized) { | 342 if (!initialized) { |
343 console.error('ERROR: remoting plugin not loaded'); | 343 console.error('ERROR: remoting plugin not loaded'); |
344 this.pluginError_(remoting.Error.MISSING_PLUGIN); | 344 this.pluginError_(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 if (!this.plugin_.isSupportedVersion()) { | 348 if (!this.plugin_.isSupportedVersion()) { |
349 console.error('ERROR: bad plugin version'); | 349 console.error('ERROR: bad plugin version'); |
350 this.pluginError_(remoting.Error.BAD_PLUGIN_VERSION); | 350 this.pluginError_(new remoting.Error( |
| 351 remoting.Error.Tag.BAD_PLUGIN_VERSION)); |
351 return; | 352 return; |
352 } | 353 } |
353 | 354 |
354 this.clientSession_ = new remoting.ClientSession( | 355 this.clientSession_ = new remoting.ClientSession( |
355 this.plugin_, this.host_, this.signalStrategy_, this.connectionMode_); | 356 this.plugin_, this.host_, this.signalStrategy_, this.connectionMode_); |
356 remoting.clientSession = this.clientSession_; | 357 remoting.clientSession = this.clientSession_; |
357 | 358 |
358 this.connectedView_ = new remoting.DesktopConnectedView( | 359 this.connectedView_ = new remoting.DesktopConnectedView( |
359 this.plugin_, this.clientContainer_, this.host_, | 360 this.plugin_, this.clientContainer_, this.host_, |
360 this.connectionMode_, this.defaultRemapKeys_); | 361 this.connectionMode_, this.defaultRemapKeys_); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 break; | 441 break; |
441 | 442 |
442 case remoting.ClientSession.State.CLOSED: | 443 case remoting.ClientSession.State.CLOSED: |
443 // This class deregisters for state-change callbacks when the CONNECTED | 444 // This class deregisters for state-change callbacks when the CONNECTED |
444 // state is reached, so it only sees the CLOSED state in exceptional | 445 // state is reached, so it only sees the CLOSED state in exceptional |
445 // circumstances. For example, a CONNECTING -> CLOSED transition happens | 446 // circumstances. For example, a CONNECTING -> CLOSED transition happens |
446 // if the host closes the connection without an error message instead of | 447 // if the host closes the connection without an error message instead of |
447 // accepting it. Since there's no way of knowing exactly what went wrong, | 448 // accepting it. Since there's no way of knowing exactly what went wrong, |
448 // we rely on server-side logs in this case and report a generic error | 449 // we rely on server-side logs in this case and report a generic error |
449 // message. | 450 // message. |
450 this.onError_(remoting.Error.UNEXPECTED); | 451 this.onError_(remoting.Error.unexpected()); |
451 break; | 452 break; |
452 | 453 |
453 case remoting.ClientSession.State.FAILED: | 454 case remoting.ClientSession.State.FAILED: |
454 var error = this.clientSession_.getError(); | 455 var error = this.clientSession_.getError(); |
455 console.error('Client plugin reported connection failed: ' + error); | 456 console.error('Client plugin reported connection failed: ' + error); |
456 if (error == null) { | 457 if (error == null) { |
457 error = remoting.Error.UNEXPECTED; | 458 error = remoting.Error.unexpected(); |
458 } | 459 } |
459 this.onConnectionFailed_(error); | 460 this.onConnectionFailed_(error); |
460 break; | 461 break; |
461 | 462 |
462 default: | 463 default: |
463 console.error('Unexpected client plugin state: ' + event.current); | 464 console.error('Unexpected client plugin state: ' + event.current); |
464 // This should only happen if the web-app and client plugin get out of | 465 // This should only happen if the web-app and client plugin get out of |
465 // sync, and even then the version check should ensure compatibility. | 466 // sync, and even then the version check should ensure compatibility. |
466 this.onError_(remoting.Error.MISSING_PLUGIN); | 467 this.onError_(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); |
467 } | 468 } |
468 }; | 469 }; |
469 | 470 |
470 /** | 471 /** |
471 * @constructor | 472 * @constructor |
472 * @implements {remoting.SessionConnectorFactory} | 473 * @implements {remoting.SessionConnectorFactory} |
473 */ | 474 */ |
474 remoting.DefaultSessionConnectorFactory = function() {}; | 475 remoting.DefaultSessionConnectorFactory = function() {}; |
475 | 476 |
476 /** | 477 /** |
(...skipping 14 matching lines...) Expand all Loading... |
491 */ | 492 */ |
492 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 493 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
493 function(clientContainer, onConnected, onError, onExtensionMessage, | 494 function(clientContainer, onConnected, onError, onExtensionMessage, |
494 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { | 495 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
495 return new remoting.SessionConnectorImpl(clientContainer, onConnected, | 496 return new remoting.SessionConnectorImpl(clientContainer, onConnected, |
496 onError, onExtensionMessage, | 497 onError, onExtensionMessage, |
497 onConnectionFailed, | 498 onConnectionFailed, |
498 requiredCapabilities, | 499 requiredCapabilities, |
499 defaultRemapKeys); | 500 defaultRemapKeys); |
500 }; | 501 }; |
OLD | NEW |