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

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: Requested changes. 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 /** 37 /**
38 * @type {HTMLElement} 38 * @type {HTMLElement}
39 * @private 39 * @private
40 */ 40 */
41 this.clientContainer_ = clientContainer; 41 this.clientContainer_ = clientContainer;
42 42
43 /** 43 /**
44 * @type {function(remoting.ClientSession):void} 44 * @type {function(remoting.ClientSession):void}
45 * @private 45 * @private
46 */ 46 */
47 this.onConnected_ = onConnected; 47 this.onConnected_ = onConnected;
48 48
49 /** 49 /**
50 * @type {function(remoting.Error):void} 50 * @type {function(!remoting.Error):void}
51 * @private 51 * @private
52 */ 52 */
53 this.onError_ = onError; 53 this.onError_ = onError;
54 54
55 /** 55 /**
56 * @type {function(string, string):boolean} 56 * @type {function(string, string):boolean}
57 * @private 57 * @private
58 */ 58 */
59 this.onExtensionMessage_ = onExtensionMessage; 59 this.onExtensionMessage_ = onExtensionMessage;
60 60
61 /** 61 /**
62 * @type {function(remoting.Error):void} 62 * @type {function(!remoting.Error):void}
63 * @private 63 * @private
64 */ 64 */
65 this.onConnectionFailed_ = onConnectionFailed; 65 this.onConnectionFailed_ = onConnectionFailed;
66 66
67 /** 67 /**
68 * @type {Array<string>} 68 * @type {Array<string>}
69 * @private 69 * @private
70 */ 70 */
71 this.requiredCapabilities_ = requiredCapabilities; 71 this.requiredCapabilities_ = requiredCapabilities;
72 72
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 console.error('Unexpected client plugin state: ' + event.current); 564 console.error('Unexpected client plugin state: ' + event.current);
565 // This should only happen if the web-app and client plugin get out of 565 // This should only happen if the web-app and client plugin get out of
566 // sync, and even then the version check should ensure compatibility. 566 // sync, and even then the version check should ensure compatibility.
567 this.onError_(remoting.Error.MISSING_PLUGIN); 567 this.onError_(remoting.Error.MISSING_PLUGIN);
568 } 568 }
569 }; 569 };
570 570
571 /** 571 /**
572 * @param {number} error An HTTP error code returned by the support-hosts 572 * @param {number} error An HTTP error code returned by the support-hosts
573 * endpoint. 573 * endpoint.
574 * @return {remoting.Error} The equivalent remoting.Error code. 574 * @return {!remoting.Error} The equivalent remoting.Error code.
575 * @private 575 * @private
576 */ 576 */
577 remoting.SessionConnectorImpl.prototype.translateSupportHostsError_ = 577 remoting.SessionConnectorImpl.prototype.translateSupportHostsError_ =
578 function(error) { 578 function(error) {
579 switch (error) { 579 switch (error) {
580 case 0: return remoting.Error.NETWORK_FAILURE; 580 case 0: return remoting.Error.NETWORK_FAILURE;
581 case 404: return remoting.Error.INVALID_ACCESS_CODE; 581 case 404: return remoting.Error.INVALID_ACCESS_CODE;
582 case 502: // No break 582 case 502: // No break
583 case 503: return remoting.Error.SERVICE_UNAVAILABLE; 583 case 503: return remoting.Error.SERVICE_UNAVAILABLE;
584 default: return remoting.Error.UNEXPECTED; 584 default: return remoting.Error.UNEXPECTED;
(...skipping 18 matching lines...) Expand all
603 * @constructor 603 * @constructor
604 * @implements {remoting.SessionConnectorFactory} 604 * @implements {remoting.SessionConnectorFactory}
605 */ 605 */
606 remoting.DefaultSessionConnectorFactory = function() { 606 remoting.DefaultSessionConnectorFactory = function() {
607 }; 607 };
608 608
609 /** 609 /**
610 * @param {HTMLElement} clientContainer Container element for the client view. 610 * @param {HTMLElement} clientContainer Container element for the client view.
611 * @param {function(remoting.ClientSession):void} onConnected Callback on 611 * @param {function(remoting.ClientSession):void} onConnected Callback on
612 * success. 612 * success.
613 * @param {function(remoting.Error):void} onError Callback on error. 613 * @param {function(!remoting.Error):void} onError Callback on error.
614 * @param {function(string, string):boolean} onExtensionMessage The handler for 614 * @param {function(string, string):boolean} onExtensionMessage The handler for
615 * protocol extension messages. Returns true if a message is recognized; 615 * protocol extension messages. Returns true if a message is recognized;
616 * false otherwise. 616 * false otherwise.
617 * @param {function(remoting.Error):void} onConnectionFailed Callback for when 617 * @param {function(!remoting.Error):void} onConnectionFailed Callback for when
618 * the connection fails. 618 * the connection fails.
619 * @param {Array<string>} requiredCapabilities Connector capabilities 619 * @param {Array<string>} requiredCapabilities Connector capabilities
620 * required by this application. 620 * required by this application.
621 * @param {string} defaultRemapKeys The default set of key mappings to use 621 * @param {string} defaultRemapKeys The default set of key mappings to use
622 * in the client session. 622 * in the client session.
623 * @return {remoting.SessionConnector} 623 * @return {remoting.SessionConnector}
624 */ 624 */
625 remoting.DefaultSessionConnectorFactory.prototype.createConnector = 625 remoting.DefaultSessionConnectorFactory.prototype.createConnector =
626 function(clientContainer, onConnected, onError, onExtensionMessage, 626 function(clientContainer, onConnected, onError, onExtensionMessage,
627 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { 627 onConnectionFailed, requiredCapabilities, defaultRemapKeys) {
628 return new remoting.SessionConnectorImpl(clientContainer, onConnected, 628 return new remoting.SessionConnectorImpl(clientContainer, onConnected,
629 onError, onExtensionMessage, 629 onError, onExtensionMessage,
630 onConnectionFailed, 630 onConnectionFailed,
631 requiredCapabilities, 631 requiredCapabilities,
632 defaultRemapKeys); 632 defaultRemapKeys);
633 }; 633 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698