Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: remoting/webapp/app_remoting/js/app_remoting.js

Issue 1010053002: [Webapp Refactor] Implements remoting.ConnectionInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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} */
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
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 var CONNECTION_SPEED_PING_INTERVAL = 10 * 1000;
233 this.pingTimer_ = new base.RepeatingTimer(function () {
232 var message = { timestamp: new Date().getTime() }; 234 var message = { timestamp: new Date().getTime() };
233 clientSession.sendClientMessage('pingRequest', JSON.stringify(message)); 235 clientSession.sendClientMessage('pingRequest', JSON.stringify(message));
234 }; 236 }, CONNECTION_SPEED_PING_INTERVAL);
235 ping();
236 this.pingTimerId_ = window.setInterval(ping, 10 * 1000);
237 }; 237 };
238 238
239 /** 239 /**
240 * Called when the current session has been disconnected. 240 * Called when the current session has been disconnected.
241 * 241 *
242 * @return {void} Nothing. 242 * @return {void} Nothing.
243 */ 243 */
244 remoting.AppRemoting.prototype.handleDisconnected = function() { 244 remoting.AppRemoting.prototype.handleDisconnected = function() {
245 // Cancel the ping when the connection closes. 245 // Cancel the ping when the connection closes.
246 window.clearInterval(this.pingTimerId_); 246 base.dispose(this.pingTimer_);
247 this.pingTimer_ = null;
247 248
248 chrome.app.window.current().close(); 249 chrome.app.window.current().close();
249 }; 250 };
250 251
251 /** 252 /**
252 * Called when the current session's connection has failed. 253 * Called when the current session's connection has failed.
253 * 254 *
254 * @param {remoting.SessionConnector} connector 255 * @param {remoting.SessionConnector} connector
255 * @param {!remoting.Error} error 256 * @param {!remoting.Error} error
256 * @return {void} Nothing. 257 * @return {void} Nothing.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), 339 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'),
339 chrome.i18n.getMessage(/** @type {string} */ (error.tag))); 340 chrome.i18n.getMessage(/** @type {string} */ (error.tag)));
340 }; 341 };
341 342
342 /** 343 /**
343 * Close the loading window before exiting. 344 * Close the loading window before exiting.
344 */ 345 */
345 remoting.AppRemoting.prototype.handleExit = function() { 346 remoting.AppRemoting.prototype.handleExit = function() {
346 remoting.LoadingWindow.close(); 347 remoting.LoadingWindow.close();
347 }; 348 };
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698