Chromium Code Reviews| Index: remoting/webapp/app_remoting/js/app_remoting.js |
| diff --git a/remoting/webapp/app_remoting/js/app_remoting.js b/remoting/webapp/app_remoting/js/app_remoting.js |
| index 3d3b58566dc50bdee4b5e19897d15abb322564af..5ddd95c6d915438dccdd1e1d1d8831b6c81ba47c 100644 |
| --- a/remoting/webapp/app_remoting/js/app_remoting.js |
| +++ b/remoting/webapp/app_remoting/js/app_remoting.js |
| @@ -30,8 +30,8 @@ remoting.AppRemoting = function(app) { |
| /** @private {remoting.WindowActivationMenu} */ |
| this.windowActivationMenu_ = null; |
| - /** @private {number} */ |
| - this.pingTimerId_ = 0; |
| + /** @private {base.RepeatingTimer} */ |
|
garykac
2015/03/16 20:43:33
Nice!
|
| + this.pingTimer_ = null; |
| }; |
| /** |
| @@ -216,10 +216,10 @@ remoting.AppRemoting.prototype.getDefaultRemapKeys = function() { |
| /** |
| * Called when a new session has been connected. |
| * |
| - * @param {remoting.ClientSession} clientSession |
| + * @param {remoting.ConnectionInfo} connectionInfo |
| * @return {void} Nothing. |
| */ |
| -remoting.AppRemoting.prototype.handleConnected = function(clientSession) { |
| +remoting.AppRemoting.prototype.handleConnected = function(connectionInfo) { |
| remoting.identity.getUserInfo().then( |
| function(userInfo) { |
| remoting.clientSession.sendClientMessage( |
| @@ -227,13 +227,12 @@ remoting.AppRemoting.prototype.handleConnected = function(clientSession) { |
| JSON.stringify({fullName: userInfo.name})); |
| }); |
| + var clientSession = connectionInfo.session(); |
| // Set up a ping at 10-second intervals to test the connection speed. |
| - function ping() { |
| + this.pingTimer_ = new base.RepeatingTimer(function () { |
| var message = { timestamp: new Date().getTime() }; |
| clientSession.sendClientMessage('pingRequest', JSON.stringify(message)); |
| - }; |
| - ping(); |
| - this.pingTimerId_ = window.setInterval(ping, 10 * 1000); |
| + }, 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.
|
| }; |
| /** |
| @@ -243,7 +242,8 @@ remoting.AppRemoting.prototype.handleConnected = function(clientSession) { |
| */ |
| remoting.AppRemoting.prototype.handleDisconnected = function() { |
| // Cancel the ping when the connection closes. |
| - window.clearInterval(this.pingTimerId_); |
| + base.dispose(this.pingTimer_); |
| + this.pingTimer_ = null; |
| chrome.app.window.current().close(); |
| }; |