| 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 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 */ | 28 */ |
| 29 remoting.SignalStrategy.State = { | 29 remoting.SignalStrategy.State = { |
| 30 NOT_CONNECTED: 0, | 30 NOT_CONNECTED: 0, |
| 31 CONNECTING: 1, | 31 CONNECTING: 1, |
| 32 HANDSHAKE: 2, | 32 HANDSHAKE: 2, |
| 33 CONNECTED: 3, | 33 CONNECTED: 3, |
| 34 FAILED: 4, | 34 FAILED: 4, |
| 35 CLOSED: 5 | 35 CLOSED: 5 |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /** |
| 39 * @enum {string} SignalStrategy types. Do not add to these values without |
| 40 * updating the corresponding enum in chromoting_extensions.proto. |
| 41 */ |
| 42 remoting.SignalStrategy.Type = { |
| 43 XMPP: 'xmpp', |
| 44 WCS: 'wcs' |
| 45 }; |
| 46 |
| 38 remoting.SignalStrategy.prototype.dispose = function() {}; | 47 remoting.SignalStrategy.prototype.dispose = function() {}; |
| 39 | 48 |
| 40 /** | 49 /** |
| 41 * @param {function(remoting.SignalStrategy.State):void} onStateChangedCallback | 50 * @param {function(remoting.SignalStrategy.State):void} onStateChangedCallback |
| 42 * Callback to call on state change. | 51 * Callback to call on state change. |
| 43 */ | 52 */ |
| 44 remoting.SignalStrategy.prototype.setStateChangedCallback = | 53 remoting.SignalStrategy.prototype.setStateChangedCallback = |
| 45 function(onStateChangedCallback) {}; | 54 function(onStateChangedCallback) {}; |
| 46 | 55 |
| 47 /** | 56 /** |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 remoting.SignalStrategy.prototype.connect = | 68 remoting.SignalStrategy.prototype.connect = |
| 60 function(server, username, authToken) { | 69 function(server, username, authToken) { |
| 61 }; | 70 }; |
| 62 | 71 |
| 63 /** | 72 /** |
| 64 * Sends a message. Can be called only in CONNECTED state. | 73 * Sends a message. Can be called only in CONNECTED state. |
| 65 * @param {string} message | 74 * @param {string} message |
| 66 */ | 75 */ |
| 67 remoting.SignalStrategy.prototype.sendMessage = function(message) {}; | 76 remoting.SignalStrategy.prototype.sendMessage = function(message) {}; |
| 68 | 77 |
| 78 /** |
| 79 * Send any messages accumulated during connection set-up. |
| 80 * |
| 81 * @param {remoting.LogToServer} logToServer The LogToServer instance for the |
| 82 * connection. |
| 83 */ |
| 84 remoting.SignalStrategy.prototype.sendConnectionSetupResults = |
| 85 function(logToServer) { |
| 86 }; |
| 87 |
| 69 /** @return {remoting.SignalStrategy.State} Current state */ | 88 /** @return {remoting.SignalStrategy.State} Current state */ |
| 70 remoting.SignalStrategy.prototype.getState = function() {}; | 89 remoting.SignalStrategy.prototype.getState = function() {}; |
| 71 | 90 |
| 72 /** @return {remoting.Error} Error when in FAILED state. */ | 91 /** @return {remoting.Error} Error when in FAILED state. */ |
| 73 remoting.SignalStrategy.prototype.getError = function() {}; | 92 remoting.SignalStrategy.prototype.getError = function() {}; |
| 74 | 93 |
| 75 /** @return {string} Current JID when in CONNECTED state. */ | 94 /** @return {string} Current JID when in CONNECTED state. */ |
| 76 remoting.SignalStrategy.prototype.getJid = function() {}; | 95 remoting.SignalStrategy.prototype.getJid = function() {}; |
| 77 | 96 |
| 97 /** @return {remoting.SignalStrategy.Type} The signal strategy type. */ |
| 98 remoting.SignalStrategy.prototype.getType = function() {}; |
| 99 |
| 78 /** | 100 /** |
| 79 * Creates the appropriate signal strategy for the current environment. | 101 * Creates the appropriate signal strategy for the current environment. |
| 80 * @return {remoting.SignalStrategy} New signal strategy object. | 102 * @return {remoting.SignalStrategy} New signal strategy object. |
| 81 */ | 103 */ |
| 82 remoting.SignalStrategy.create = function() { | 104 remoting.SignalStrategy.create = function() { |
| 83 // Only use XMPP when TCP API is available and TLS support is enabled. That's | 105 // Only use XMPP when TCP API is available and TLS support is enabled. That's |
| 84 // not the case for V1 app (socket API is available only to platform apps) | 106 // not the case for V1 app (socket API is available only to platform apps) |
| 85 // and for Chrome releases before 38. | 107 // and for Chrome releases before 38. |
| 86 if (chrome.socket && chrome.socket.secure) { | 108 if (chrome.socket && chrome.socket.secure) { |
| 87 /** | 109 /** |
| 88 * @param {remoting.FallbackSignalStrategy.Progress} progress | 110 * @param {remoting.FallbackSignalStrategy.Progress} progress |
| 89 */ | 111 */ |
| 90 var progressCallback = function(progress) { | 112 var progressCallback = function(progress) { |
| 91 console.log('FallbackSignalStrategy progress: ' + progress); | 113 console.log('FallbackSignalStrategy progress: ' + progress); |
| 92 }; | 114 }; |
| 93 | 115 |
| 94 return new remoting.FallbackSignalStrategy(new remoting.XmppConnection(), | 116 return new remoting.FallbackSignalStrategy(new remoting.XmppConnection(), |
| 95 new remoting.WcsAdapter(), | 117 new remoting.WcsAdapter()); |
| 96 progressCallback); | |
| 97 | 118 |
| 98 } else { | 119 } else { |
| 99 return new remoting.WcsAdapter(); | 120 return new remoting.WcsAdapter(); |
| 100 } | 121 } |
| 101 }; | 122 }; |
| OLD | NEW |