OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * Session class that handles creation and teardown of a remoting session. | 7 * Session class that handles creation and teardown of a remoting session. |
8 * | 8 * |
9 * This abstracts a <embed> element and controls the plugin which does the | 9 * This abstracts a <embed> element and controls the plugin which does the |
10 * actual remoting work. There should be no UI code inside this class. It | 10 * actual remoting work. There should be no UI code inside this class. It |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 } | 345 } |
346 }; | 346 }; |
347 | 347 |
348 /** | 348 /** |
349 * This is a callback that gets called when the desktop size contained in the | 349 * This is a callback that gets called when the desktop size contained in the |
350 * the plugin has changed. | 350 * the plugin has changed. |
351 * | 351 * |
352 * @return {void} Nothing. | 352 * @return {void} Nothing. |
353 */ | 353 */ |
354 remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() { | 354 remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() { |
355 var width = this.plugin.desktopWidth; | 355 remoting.debug.log('desktop size changed: ' + |
356 var height = this.plugin.desktopHeight; | 356 this.plugin.desktopWidth + 'x' + |
357 remoting.debug.log('desktop size changed: ' + width + 'x' + height); | 357 this.plugin.desktopHeight); |
358 this.plugin.width = width; | 358 this.setScaleToFit(remoting.scaleToFit); |
359 this.plugin.height = height; | |
Jamie
2011/09/06 17:19:25
Don't you still need these last two lines in the c
Wez
2011/09/07 00:28:43
setScaleToFit() already has those lines in the not
| |
360 }; | 359 }; |
361 | 360 |
362 /** | 361 /** |
363 * Informs the plugin that it should scale itself. | 362 * Informs the plugin that it should scale itself. |
364 * | 363 * |
365 * @param {boolean} shouldScale If the plugin should scale itself. | 364 * @param {boolean} shouldScale If the plugin should scale itself. |
366 * @return {void} Nothing. | 365 * @return {void} Nothing. |
367 */ | 366 */ |
368 remoting.ClientSession.prototype.setScaleToFit = function(shouldScale) { | 367 remoting.ClientSession.prototype.setScaleToFit = function(shouldScale) { |
369 if (shouldScale) { | 368 if (shouldScale) { |
(...skipping 18 matching lines...) Expand all Loading... | |
388 remoting.debug.log('scale up is not supported'); | 387 remoting.debug.log('scale up is not supported'); |
389 scale = 1.0; | 388 scale = 1.0; |
390 } | 389 } |
391 | 390 |
392 this.plugin.width = this.plugin.desktopWidth * scale; | 391 this.plugin.width = this.plugin.desktopWidth * scale; |
393 this.plugin.height = this.plugin.desktopHeight * scale; | 392 this.plugin.height = this.plugin.desktopHeight * scale; |
394 } else { | 393 } else { |
395 this.plugin.width = this.plugin.desktopWidth; | 394 this.plugin.width = this.plugin.desktopWidth; |
396 this.plugin.height = this.plugin.desktopHeight; | 395 this.plugin.height = this.plugin.desktopHeight; |
397 } | 396 } |
397 | |
398 // Update the containing element accordingly. | |
399 if (this.plugin.parentNode) { | |
400 var parentNode = this.plugin.parentNode; | |
401 parentNode.style["width"] = this.plugin.width + "px"; | |
402 parentNode.style["height"] = this.plugin.height + "px"; | |
403 parentNode.style["margin-left"] = -(this.plugin.width/2) + "px"; | |
Jamie
2011/09/06 17:19:25
Please add a comment above the margin setters to e
Wez
2011/09/07 00:28:43
Done.
| |
404 parentNode.style["margin-top"] = -(this.plugin.height/2) + "px"; | |
405 } | |
406 | |
398 remoting.debug.log('plugin size is now: ' + | 407 remoting.debug.log('plugin size is now: ' + |
399 this.plugin.width + ' x ' + this.plugin.height + '.'); | 408 this.plugin.width + ' x ' + this.plugin.height + '.'); |
400 this.plugin.setScaleToFit(shouldScale); | 409 this.plugin.setScaleToFit(shouldScale); |
401 remoting.debug.log('scale to fit is now: ' + shouldScale); | 410 remoting.debug.log('scale to fit is now: ' + shouldScale); |
402 }; | 411 }; |
403 | 412 |
404 /** | 413 /** |
405 * Returns an associative array with a set of stats for this connection. | 414 * Returns an associative array with a set of stats for this connection. |
406 * | 415 * |
407 * @return {Object} The connection statistics. | 416 * @return {Object} The connection statistics. |
408 */ | 417 */ |
409 remoting.ClientSession.prototype.stats = function() { | 418 remoting.ClientSession.prototype.stats = function() { |
410 return { | 419 return { |
411 'video_bandwidth': this.plugin.videoBandwidth, | 420 'video_bandwidth': this.plugin.videoBandwidth, |
412 'capture_latency': this.plugin.videoCaptureLatency, | 421 'capture_latency': this.plugin.videoCaptureLatency, |
413 'encode_latency': this.plugin.videoEncodeLatency, | 422 'encode_latency': this.plugin.videoEncodeLatency, |
414 'decode_latency': this.plugin.videoDecodeLatency, | 423 'decode_latency': this.plugin.videoDecodeLatency, |
415 'render_latency': this.plugin.videoRenderLatency, | 424 'render_latency': this.plugin.videoRenderLatency, |
416 'roundtrip_latency': this.plugin.roundTripLatency | 425 'roundtrip_latency': this.plugin.roundTripLatency |
417 }; | 426 }; |
418 }; | 427 }; |
419 | 428 |
420 }()); | 429 }()); |
OLD | NEW |