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

Side by Side Diff: remoting/webapp/crd/js/session_connector_impl.js

Issue 955283002: Converted remoting.Error from an enum to a class (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 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';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * @param {HTMLElement} clientContainer Container element for the client view. 16 * @param {HTMLElement} clientContainer Container element for the client view.
17 * @param {function(remoting.ClientSession):void} onConnected Callback on 17 * @param {function(remoting.ClientSession):void} onConnected Callback on
18 * success. 18 * success.
19 * @param {function(remoting.Error):void} onError Callback on error. 19 * @param {function(!remoting.Error):void} onError Callback on error.
20 * @param {function(string, string):boolean} onExtensionMessage The handler for 20 * @param {function(string, string):boolean} onExtensionMessage The handler for
21 * protocol extension messages. Returns true if a message is recognized; 21 * protocol extension messages. Returns true if a message is recognized;
22 * false otherwise. 22 * false otherwise.
23 * @param {function(remoting.Error):void} onConnectionFailed Callback for when 23 * @param {function(!remoting.Error):void} onConnectionFailed Callback for when
24 * the connection fails. 24 * the connection fails.
25 * @param {Array<string>} requiredCapabilities Connector capabilities 25 * @param {Array<string>} requiredCapabilities Connector capabilities
26 * required by this application. 26 * required by this application.
27 * @param {string} defaultRemapKeys The default set of key mappings for the 27 * @param {string} defaultRemapKeys The default set of key mappings for the
28 * client session to use. 28 * client session to use.
29 * @constructor 29 * @constructor
30 * @implements {remoting.SessionConnector} 30 * @implements {remoting.SessionConnector}
31 */ 31 */
32 remoting.SessionConnectorImpl = function(clientContainer, onConnected, onError, 32 remoting.SessionConnectorImpl = function(clientContainer, onConnected, onError,
33 onExtensionMessage, 33 onExtensionMessage,
34 onConnectionFailed, 34 onConnectionFailed,
35 requiredCapabilities, 35 requiredCapabilities,
36 defaultRemapKeys) { 36 defaultRemapKeys) {
37 /** @private {HTMLElement} */ 37 /** @private {HTMLElement} */
38 this.clientContainer_ = clientContainer; 38 this.clientContainer_ = clientContainer;
39 39
40 /** @private {function(remoting.ClientSession):void} */ 40 /** @private {function(remoting.ClientSession):void} */
41 this.onConnected_ = onConnected; 41 this.onConnected_ = onConnected;
42 42
43 /** @private {function(remoting.Error):void} */ 43 /** @private {function(!remoting.Error):void} */
44 this.onError_ = onError; 44 this.onError_ = onError;
45 45
46 /** @private {function(string, string):boolean} */ 46 /** @private {function(string, string):boolean} */
47 this.onExtensionMessage_ = onExtensionMessage; 47 this.onExtensionMessage_ = onExtensionMessage;
48 48
49 /** @private {function(remoting.Error):void} */ 49 /** @private {function(!remoting.Error):void} */
50 this.onConnectionFailed_ = onConnectionFailed; 50 this.onConnectionFailed_ = onConnectionFailed;
51 51
52 /** @private {Array<string>} */ 52 /** @private {Array<string>} */
53 this.requiredCapabilities_ = requiredCapabilities; 53 this.requiredCapabilities_ = requiredCapabilities;
54 54
55 /** @private {string} */ 55 /** @private {string} */
56 this.defaultRemapKeys_ = defaultRemapKeys; 56 this.defaultRemapKeys_ = defaultRemapKeys;
57 57
58 /** @private {string} */ 58 /** @private {string} */
59 this.clientJid_ = ''; 59 this.clientJid_ = '';
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 console.error('Unexpected client plugin state: ' + event.current); 467 console.error('Unexpected client plugin state: ' + event.current);
468 // This should only happen if the web-app and client plugin get out of 468 // This should only happen if the web-app and client plugin get out of
469 // sync, and even then the version check should ensure compatibility. 469 // sync, and even then the version check should ensure compatibility.
470 this.onError_(remoting.Error.MISSING_PLUGIN); 470 this.onError_(remoting.Error.MISSING_PLUGIN);
471 } 471 }
472 }; 472 };
473 473
474 /** 474 /**
475 * @param {number} error An HTTP error code returned by the support-hosts 475 * @param {number} error An HTTP error code returned by the support-hosts
476 * endpoint. 476 * endpoint.
477 * @return {remoting.Error} The equivalent remoting.Error code. 477 * @return {!remoting.Error} The equivalent remoting.Error code.
478 * @private 478 * @private
479 */ 479 */
480 remoting.SessionConnectorImpl.prototype.translateSupportHostsError_ = 480 remoting.SessionConnectorImpl.prototype.translateSupportHostsError_ =
481 function(error) { 481 function(error) {
482 switch (error) { 482 switch (error) {
483 case 0: return remoting.Error.NETWORK_FAILURE; 483 case 0: return remoting.Error.NETWORK_FAILURE;
484 case 404: return remoting.Error.INVALID_ACCESS_CODE; 484 case 404: return remoting.Error.INVALID_ACCESS_CODE;
485 case 502: // No break 485 case 502: // No break
486 case 503: return remoting.Error.SERVICE_UNAVAILABLE; 486 case 503: return remoting.Error.SERVICE_UNAVAILABLE;
487 default: return remoting.Error.UNEXPECTED; 487 default: return remoting.Error.UNEXPECTED;
(...skipping 18 matching lines...) Expand all
506 * @constructor 506 * @constructor
507 * @implements {remoting.SessionConnectorFactory} 507 * @implements {remoting.SessionConnectorFactory}
508 */ 508 */
509 remoting.DefaultSessionConnectorFactory = function() { 509 remoting.DefaultSessionConnectorFactory = function() {
510 }; 510 };
511 511
512 /** 512 /**
513 * @param {HTMLElement} clientContainer Container element for the client view. 513 * @param {HTMLElement} clientContainer Container element for the client view.
514 * @param {function(remoting.ClientSession):void} onConnected Callback on 514 * @param {function(remoting.ClientSession):void} onConnected Callback on
515 * success. 515 * success.
516 * @param {function(remoting.Error):void} onError Callback on error. 516 * @param {function(!remoting.Error):void} onError Callback on error.
517 * @param {function(string, string):boolean} onExtensionMessage The handler for 517 * @param {function(string, string):boolean} onExtensionMessage The handler for
518 * protocol extension messages. Returns true if a message is recognized; 518 * protocol extension messages. Returns true if a message is recognized;
519 * false otherwise. 519 * false otherwise.
520 * @param {function(remoting.Error):void} onConnectionFailed Callback for when 520 * @param {function(!remoting.Error):void} onConnectionFailed Callback for when
521 * the connection fails. 521 * the connection fails.
522 * @param {Array<string>} requiredCapabilities Connector capabilities 522 * @param {Array<string>} requiredCapabilities Connector capabilities
523 * required by this application. 523 * required by this application.
524 * @param {string} defaultRemapKeys The default set of key mappings to use 524 * @param {string} defaultRemapKeys The default set of key mappings to use
525 * in the client session. 525 * in the client session.
526 * @return {remoting.SessionConnector} 526 * @return {remoting.SessionConnector}
527 */ 527 */
528 remoting.DefaultSessionConnectorFactory.prototype.createConnector = 528 remoting.DefaultSessionConnectorFactory.prototype.createConnector =
529 function(clientContainer, onConnected, onError, onExtensionMessage, 529 function(clientContainer, onConnected, onError, onExtensionMessage,
530 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { 530 onConnectionFailed, requiredCapabilities, defaultRemapKeys) {
531 return new remoting.SessionConnectorImpl(clientContainer, onConnected, 531 return new remoting.SessionConnectorImpl(clientContainer, onConnected,
532 onError, onExtensionMessage, 532 onError, onExtensionMessage,
533 onConnectionFailed, 533 onConnectionFailed,
534 requiredCapabilities, 534 requiredCapabilities,
535 defaultRemapKeys); 535 defaultRemapKeys);
536 }; 536 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698