OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** | 10 /** |
11 * Abstract interface for various signaling mechanisms. | 11 * Abstract interface for various signaling mechanisms. |
12 * | 12 * |
13 * @interface | 13 * @interface |
14 * @extends {base.Disposable} | 14 * @extends {base.Disposable} |
15 */ | 15 */ |
16 remoting.SignalStrategy = function() {}; | 16 remoting.SignalStrategy = function() {}; |
17 | 17 |
18 /** | 18 /** |
19 * @enum {number} SignalStrategy states. Possible state transitions: | 19 * @enum {number} SignalStrategy states. Possible state transitions: |
20 * NOT_CONNECTED -> CONNECTING (connect() called). | 20 * NOT_CONNECTED -> CONNECTING (connect() called). |
21 * CONNECTING -> HANDSHAKE (connected successfully). | 21 * CONNECTING -> HANDSHAKE (connected successfully). |
22 * HANDSHAKE -> CONNECTED (authenticated successfully). | 22 * HANDSHAKE -> CONNECTED (authenticated successfully). |
23 * CONNECTING -> FAILED (connection failed). | 23 * CONNECTING -> FAILED (connection failed). |
24 * HANDSHAKE -> FAILED (authentication failed). | 24 * HANDSHAKE -> FAILED (authentication failed). |
25 * * -> CLOSED (dispose() called). | 25 * * -> CLOSED (dispose() called). |
26 * | |
27 * Do not re-order these values without updating fallback_signal_strategy.js. | |
26 */ | 28 */ |
27 remoting.SignalStrategy.State = { | 29 remoting.SignalStrategy.State = { |
28 NOT_CONNECTED: 0, | 30 NOT_CONNECTED: 0, |
29 CONNECTING: 1, | 31 CONNECTING: 1, |
30 HANDSHAKE: 2, | 32 HANDSHAKE: 2, |
31 CONNECTED: 3, | 33 CONNECTED: 3, |
32 FAILED: 4, | 34 FAILED: 4, |
33 CLOSED: 5 | 35 CLOSED: 5 |
34 }; | 36 }; |
35 | 37 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 /** | 71 /** |
70 * Creates the appropriate signal strategy for the current environment. | 72 * Creates the appropriate signal strategy for the current environment. |
71 * @param {function(remoting.SignalStrategy.State): void} onStateChangedCallback | 73 * @param {function(remoting.SignalStrategy.State): void} onStateChangedCallback |
72 * @return {remoting.SignalStrategy} New signal strategy object. | 74 * @return {remoting.SignalStrategy} New signal strategy object. |
73 */ | 75 */ |
74 remoting.SignalStrategy.create = function(onStateChangedCallback) { | 76 remoting.SignalStrategy.create = function(onStateChangedCallback) { |
75 // Only use XMPP when TCP API is available and TLS support is enabled. That's | 77 // Only use XMPP when TCP API is available and TLS support is enabled. That's |
76 // not the case for V1 app (socket API is available only to platform apps) | 78 // not the case for V1 app (socket API is available only to platform apps) |
77 // and for Chrome releases before 38. | 79 // and for Chrome releases before 38. |
78 if (chrome.socket && chrome.socket.secure) { | 80 if (chrome.socket && chrome.socket.secure) { |
79 return new remoting.XmppConnection(onStateChangedCallback); | 81 return new remoting.FallbackSignalStrategy( |
82 /** | |
83 * @param {function(remoting.SignalStrategy.State): void} | |
84 * onStateChangedCallback_ | |
85 */ | |
86 function(onStateChangedCallback_) { | |
Sergey Ulanov
2015/01/13 19:43:51
here and below: remove _ suffix from the name
Sergey Ulanov
2015/01/13 19:43:51
Maybe move this function out of the argument list,
Jamie
2015/01/14 01:36:26
Done.
Jamie
2015/01/14 01:36:26
Done.
| |
87 return new remoting.XmppConnection(onStateChangedCallback_); | |
88 }, | |
89 /** | |
90 * @param {function(remoting.SignalStrategy.State): void} | |
91 * onStateChangedCallback_ | |
92 */ | |
93 function(onStateChangedCallback_) { | |
94 return new remoting.WcsAdapter(onStateChangedCallback_); | |
95 }, | |
96 onStateChangedCallback, | |
97 /** | |
98 * @param {remoting.FallbackSignalStrategy.Result} progress | |
99 */ | |
100 function(progress) { | |
101 console.warn('FallbackStrategyProgress: ' + progress); | |
102 }); | |
80 } else { | 103 } else { |
81 return new remoting.WcsAdapter(onStateChangedCallback); | 104 return new remoting.WcsAdapter(onStateChangedCallback); |
82 } | 105 } |
83 }; | 106 }; |
OLD | NEW |