OLD | NEW |
---|---|
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 host session. | 7 * Class handling creation and teardown of a remoting host session. |
8 * | 8 * |
9 * This abstracts a <embed> element and controls the plugin which does the | 9 * This abstracts a <embed> element and controls the plugin which does the |
10 * actual remoting work. There should be no UI code inside this class. It | 10 * actual remoting work. There should be no UI code inside this class. It |
11 * should be purely thought of as a controller of sorts. | 11 * should be purely thought of as a controller of sorts. |
12 */ | 12 */ |
13 | 13 |
14 'use strict'; | |
15 | |
16 /** @suppress {duplicate} */ | 14 /** @suppress {duplicate} */ |
17 var remoting = remoting || {}; | 15 var remoting = remoting || {}; |
18 | 16 |
17 (function() { | |
18 | |
19 'use strict'; | |
20 | |
19 /** | 21 /** |
20 * @constructor | 22 * @constructor |
23 * @implements {base.Disposable} | |
21 */ | 24 */ |
22 remoting.HostSession = function() { | 25 remoting.HostSession = function() { |
23 /** @type {remoting.It2MeHostFacade} @private */ | 26 /** @type {remoting.It2MeHostFacade} @private */ |
24 this.hostFacade_ = null; | 27 this.hostFacade_ = null; |
25 }; | 28 }; |
26 | 29 |
30 })(); | |
kelvinp
2015/02/04 01:38:10
JsCompile cannot handle enums (remoting.HostSessio
Sergey Ulanov
2015/02/04 19:52:46
I didn't have any problems with it inside dns_blac
Jamie
2015/02/04 21:02:39
Alternatively, you could get rid of the IIFE for t
kelvinp
2015/02/04 21:36:15
This is because BlackholeState is not referenced a
| |
31 | |
27 // Note that these values are copied directly from host_script_object.h and | 32 // Note that these values are copied directly from host_script_object.h and |
28 // must be kept in sync. | 33 // must be kept in sync. |
29 /** @enum {number} */ | 34 /** @enum {number} */ |
30 remoting.HostSession.State = { | 35 remoting.HostSession.State = { |
31 UNKNOWN: -1, | 36 UNKNOWN: -1, |
32 DISCONNECTED: 0, | 37 DISCONNECTED: 0, |
33 STARTING: 1, | 38 STARTING: 1, |
34 REQUESTED_ACCESS_CODE: 2, | 39 REQUESTED_ACCESS_CODE: 2, |
35 RECEIVED_ACCESS_CODE: 3, | 40 RECEIVED_ACCESS_CODE: 3, |
36 CONNECTED: 4, | 41 CONNECTED: 4, |
37 DISCONNECTING: 5, | 42 DISCONNECTING: 5, |
38 ERROR: 6, | 43 ERROR: 6, |
39 INVALID_DOMAIN_ERROR: 7 | 44 INVALID_DOMAIN_ERROR: 7 |
40 }; | 45 }; |
41 | 46 |
47 (function() { | |
48 | |
49 remoting.HostSession.prototype.dispose = function() { | |
50 base.dispose(this.hostFacade_); | |
51 this.hostFacade_ = null; | |
52 }; | |
53 | |
42 /** | 54 /** |
43 * @param {string} stateString The string representation of the host state. | 55 * @param {string} stateString The string representation of the host state. |
44 * @return {remoting.HostSession.State} The HostSession.State enum value | 56 * @return {remoting.HostSession.State} The HostSession.State enum value |
45 * corresponding to stateString. | 57 * corresponding to stateString. |
46 */ | 58 */ |
47 remoting.HostSession.State.fromString = function(stateString) { | 59 remoting.HostSession.State.fromString = function(stateString) { |
48 if (!remoting.HostSession.State.hasOwnProperty(stateString)) { | 60 if (!remoting.HostSession.State.hasOwnProperty(stateString)) { |
49 console.error('Unexpected HostSession.State string: ', stateString); | 61 console.error('Unexpected HostSession.State string: ', stateString); |
50 return remoting.HostSession.State.UNKNOWN; | 62 return remoting.HostSession.State.UNKNOWN; |
51 } | 63 } |
52 return remoting.HostSession.State[stateString]; | 64 return remoting.HostSession.State[stateString]; |
53 } | 65 }; |
54 | 66 |
55 /** | 67 /** |
56 * Initiates a connection. | 68 * Initiates a connection. |
57 * @param {remoting.It2MeHostFacade} hostFacade It2Me host facade to use. | 69 * @param {remoting.It2MeHostFacade} hostFacade It2Me host facade to use. |
58 * @param {string} email The user's email address. | 70 * @param {string} email The user's email address. |
59 * @param {string} accessToken A valid OAuth2 access token. | 71 * @param {string} accessToken A valid OAuth2 access token. |
60 * @param {function(remoting.HostSession.State):void} onStateChanged | 72 * @param {function(remoting.HostSession.State):void} onStateChanged |
61 * Callback for notifications of changes to the host plugin's state. | 73 * Callback for notifications of changes to the host plugin's state. |
62 * @param {function(boolean):void} onNatTraversalPolicyChanged Callback | 74 * @param {function(boolean):void} onNatTraversalPolicyChanged Callback |
63 * for notification of changes to the NAT traversal policy. | 75 * for notification of changes to the NAT traversal policy. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 return this.hostFacade_.getClient(); | 119 return this.hostFacade_.getClient(); |
108 }; | 120 }; |
109 | 121 |
110 /** | 122 /** |
111 * Disconnect the it2me session. | 123 * Disconnect the it2me session. |
112 * @return {void} Nothing. | 124 * @return {void} Nothing. |
113 */ | 125 */ |
114 remoting.HostSession.prototype.disconnect = function() { | 126 remoting.HostSession.prototype.disconnect = function() { |
115 this.hostFacade_.disconnect(); | 127 this.hostFacade_.disconnect(); |
116 }; | 128 }; |
129 | |
130 })(); | |
OLD | NEW |