Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * This class implements the functionality that is specific to application | 7 * This class implements the functionality that is specific to application |
| 8 * remoting ("AppRemoting" or AR). | 8 * remoting ("AppRemoting" or AR). |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 /** @private {remoting.ApplicationContextMenu} */ | 24 /** @private {remoting.ApplicationContextMenu} */ |
| 25 this.contextMenu_ = null; | 25 this.contextMenu_ = null; |
| 26 | 26 |
| 27 /** @private {remoting.KeyboardLayoutsMenu} */ | 27 /** @private {remoting.KeyboardLayoutsMenu} */ |
| 28 this.keyboardLayoutsMenu_ = null; | 28 this.keyboardLayoutsMenu_ = null; |
| 29 | 29 |
| 30 /** @private {remoting.WindowActivationMenu} */ | 30 /** @private {remoting.WindowActivationMenu} */ |
| 31 this.windowActivationMenu_ = null; | 31 this.windowActivationMenu_ = null; |
| 32 | 32 |
| 33 /** @private {number} */ | 33 /** @private {base.RepeatingTimer} */ |
|
garykac
2015/03/16 20:43:33
Nice!
| |
| 34 this.pingTimerId_ = 0; | 34 this.pingTimer_ = null; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Type definition for the RunApplicationResponse returned by the API. | 38 * Type definition for the RunApplicationResponse returned by the API. |
| 39 * | 39 * |
| 40 * @constructor | 40 * @constructor |
| 41 * @private | 41 * @private |
| 42 */ | 42 */ |
| 43 remoting.AppRemoting.AppHostResponse = function() { | 43 remoting.AppRemoting.AppHostResponse = function() { |
| 44 /** @type {string} */ | 44 /** @type {string} */ |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 // shortcuts, but we want them to act as natively as possible. | 209 // shortcuts, but we want them to act as natively as possible. |
| 210 if (remoting.platformIsMac()) { | 210 if (remoting.platformIsMac()) { |
| 211 return '0x0700e3>0x0700e0,0x0700e7>0x0700e4'; | 211 return '0x0700e3>0x0700e0,0x0700e7>0x0700e4'; |
| 212 } | 212 } |
| 213 return ''; | 213 return ''; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 /** | 216 /** |
| 217 * Called when a new session has been connected. | 217 * Called when a new session has been connected. |
| 218 * | 218 * |
| 219 * @param {remoting.ClientSession} clientSession | 219 * @param {remoting.ConnectionInfo} connectionInfo |
| 220 * @return {void} Nothing. | 220 * @return {void} Nothing. |
| 221 */ | 221 */ |
| 222 remoting.AppRemoting.prototype.handleConnected = function(clientSession) { | 222 remoting.AppRemoting.prototype.handleConnected = function(connectionInfo) { |
| 223 remoting.identity.getUserInfo().then( | 223 remoting.identity.getUserInfo().then( |
| 224 function(userInfo) { | 224 function(userInfo) { |
| 225 remoting.clientSession.sendClientMessage( | 225 remoting.clientSession.sendClientMessage( |
| 226 'setUserDisplayInfo', | 226 'setUserDisplayInfo', |
| 227 JSON.stringify({fullName: userInfo.name})); | 227 JSON.stringify({fullName: userInfo.name})); |
| 228 }); | 228 }); |
| 229 | 229 |
| 230 var clientSession = connectionInfo.session(); | |
| 230 // Set up a ping at 10-second intervals to test the connection speed. | 231 // Set up a ping at 10-second intervals to test the connection speed. |
| 231 function ping() { | 232 this.pingTimer_ = new base.RepeatingTimer(function () { |
| 232 var message = { timestamp: new Date().getTime() }; | 233 var message = { timestamp: new Date().getTime() }; |
| 233 clientSession.sendClientMessage('pingRequest', JSON.stringify(message)); | 234 clientSession.sendClientMessage('pingRequest', JSON.stringify(message)); |
| 234 }; | 235 }, 10 * 1000); |
|
garykac
2015/03/16 20:43:33
Can we move this into a constant (with a descripti
kelvinp
2015/03/16 21:00:21
Done.
| |
| 235 ping(); | |
| 236 this.pingTimerId_ = window.setInterval(ping, 10 * 1000); | |
| 237 }; | 236 }; |
| 238 | 237 |
| 239 /** | 238 /** |
| 240 * Called when the current session has been disconnected. | 239 * Called when the current session has been disconnected. |
| 241 * | 240 * |
| 242 * @return {void} Nothing. | 241 * @return {void} Nothing. |
| 243 */ | 242 */ |
| 244 remoting.AppRemoting.prototype.handleDisconnected = function() { | 243 remoting.AppRemoting.prototype.handleDisconnected = function() { |
| 245 // Cancel the ping when the connection closes. | 244 // Cancel the ping when the connection closes. |
| 246 window.clearInterval(this.pingTimerId_); | 245 base.dispose(this.pingTimer_); |
| 246 this.pingTimer_ = null; | |
| 247 | 247 |
| 248 chrome.app.window.current().close(); | 248 chrome.app.window.current().close(); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 /** | 251 /** |
| 252 * Called when the current session's connection has failed. | 252 * Called when the current session's connection has failed. |
| 253 * | 253 * |
| 254 * @param {remoting.SessionConnector} connector | 254 * @param {remoting.SessionConnector} connector |
| 255 * @param {!remoting.Error} error | 255 * @param {!remoting.Error} error |
| 256 * @return {void} Nothing. | 256 * @return {void} Nothing. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), | 338 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), |
| 339 chrome.i18n.getMessage(/** @type {string} */ (error.tag))); | 339 chrome.i18n.getMessage(/** @type {string} */ (error.tag))); |
| 340 }; | 340 }; |
| 341 | 341 |
| 342 /** | 342 /** |
| 343 * Close the loading window before exiting. | 343 * Close the loading window before exiting. |
| 344 */ | 344 */ |
| 345 remoting.AppRemoting.prototype.handleExit = function() { | 345 remoting.AppRemoting.prototype.handleExit = function() { |
| 346 remoting.LoadingWindow.close(); | 346 remoting.LoadingWindow.close(); |
| 347 }; | 347 }; |
| OLD | NEW |