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.clientSession_, this.clientContainer_, this.host_, | 360 this.plugin_, this.clientSession_, this.clientContainer_, this.host_, |
360 this.connectionMode_, | 361 this.connectionMode_, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 break; | 446 break; |
446 | 447 |
447 case remoting.ClientSession.State.CLOSED: | 448 case remoting.ClientSession.State.CLOSED: |
448 // This class deregisters for state-change callbacks when the CONNECTED | 449 // This class deregisters for state-change callbacks when the CONNECTED |
449 // state is reached, so it only sees the CLOSED state in exceptional | 450 // state is reached, so it only sees the CLOSED state in exceptional |
450 // circumstances. For example, a CONNECTING -> CLOSED transition happens | 451 // circumstances. For example, a CONNECTING -> CLOSED transition happens |
451 // if the host closes the connection without an error message instead of | 452 // if the host closes the connection without an error message instead of |
452 // accepting it. Since there's no way of knowing exactly what went wrong, | 453 // accepting it. Since there's no way of knowing exactly what went wrong, |
453 // we rely on server-side logs in this case and report a generic error | 454 // we rely on server-side logs in this case and report a generic error |
454 // message. | 455 // message. |
455 this.onError_(remoting.Error.UNEXPECTED); | 456 this.onError_(remoting.Error.unexpected()); |
456 break; | 457 break; |
457 | 458 |
458 case remoting.ClientSession.State.FAILED: | 459 case remoting.ClientSession.State.FAILED: |
459 var error = this.clientSession_.getError(); | 460 var error = this.clientSession_.getError(); |
460 console.error('Client plugin reported connection failed: ' + error); | 461 console.error('Client plugin reported connection failed: ' + error); |
461 if (error == null) { | 462 if (error == null) { |
462 error = remoting.Error.UNEXPECTED; | 463 error = remoting.Error.unexpected(); |
463 } | 464 } |
464 this.onConnectionFailed_(error); | 465 this.onConnectionFailed_(error); |
465 break; | 466 break; |
466 | 467 |
467 default: | 468 default: |
468 console.error('Unexpected client plugin state: ' + event.current); | 469 console.error('Unexpected client plugin state: ' + event.current); |
469 // This should only happen if the web-app and client plugin get out of | 470 // This should only happen if the web-app and client plugin get out of |
470 // sync, and even then the version check should ensure compatibility. | 471 // sync, and even then the version check should ensure compatibility. |
471 this.onError_(remoting.Error.MISSING_PLUGIN); | 472 this.onError_(new remoting.Error(remoting.Error.Tag.MISSING_PLUGIN)); |
472 } | 473 } |
473 }; | 474 }; |
474 | 475 |
475 /** | 476 /** |
476 * @constructor | 477 * @constructor |
477 * @implements {remoting.SessionConnectorFactory} | 478 * @implements {remoting.SessionConnectorFactory} |
478 */ | 479 */ |
479 remoting.DefaultSessionConnectorFactory = function() {}; | 480 remoting.DefaultSessionConnectorFactory = function() {}; |
480 | 481 |
481 /** | 482 /** |
(...skipping 14 matching lines...) Expand all Loading... |
496 */ | 497 */ |
497 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 498 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
498 function(clientContainer, onConnected, onError, onExtensionMessage, | 499 function(clientContainer, onConnected, onError, onExtensionMessage, |
499 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { | 500 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
500 return new remoting.SessionConnectorImpl(clientContainer, onConnected, | 501 return new remoting.SessionConnectorImpl(clientContainer, onConnected, |
501 onError, onExtensionMessage, | 502 onError, onExtensionMessage, |
502 onConnectionFailed, | 503 onConnectionFailed, |
503 requiredCapabilities, | 504 requiredCapabilities, |
504 defaultRemapKeys); | 505 defaultRemapKeys); |
505 }; | 506 }; |
OLD | NEW |