Chromium Code Reviews| 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 * Class handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 | 61 |
| 62 /** @enum {number} */ | 62 /** @enum {number} */ |
| 63 remoting.ClientSession.ConnectionError = { | 63 remoting.ClientSession.ConnectionError = { |
| 64 NONE: 0, | 64 NONE: 0, |
| 65 HOST_IS_OFFLINE: 1, | 65 HOST_IS_OFFLINE: 1, |
| 66 SESSION_REJECTED: 2, | 66 SESSION_REJECTED: 2, |
| 67 INCOMPATIBLE_PROTOCOL: 3, | 67 INCOMPATIBLE_PROTOCOL: 3, |
| 68 NETWORK_FAILURE: 4 | 68 NETWORK_FAILURE: 4 |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // Keys for connection statistics. | |
| 72 remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH = 'video_bandwidth'; | |
| 73 remoting.ClientSession.STATS_KEY_VIDEO_FRAME_RATE = 'video_frame_rate'; | |
| 74 remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY = 'capture_latency'; | |
| 75 remoting.ClientSession.STATS_KEY_ENCODE_LATENCY = 'encode_latency'; | |
| 76 remoting.ClientSession.STATS_KEY_DECODE_LATENCY = 'decode_latency'; | |
| 77 remoting.ClientSession.STATS_KEY_RENDER_LATENCY = 'render_latency'; | |
| 78 remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY = 'roundtrip_latency'; | |
| 79 | |
| 71 /** | 80 /** |
| 72 * The current state of the session. | 81 * The current state of the session. |
| 73 * @type {remoting.ClientSession.State} | 82 * @type {remoting.ClientSession.State} |
| 74 */ | 83 */ |
| 75 remoting.ClientSession.prototype.state = remoting.ClientSession.State.UNKNOWN; | 84 remoting.ClientSession.prototype.state = remoting.ClientSession.State.UNKNOWN; |
| 76 | 85 |
| 77 /** | 86 /** |
| 78 * The last connection error. Set when state is set to CONNECTION_FAILED. | 87 * The last connection error. Set when state is set to CONNECTION_FAILED. |
| 79 * @type {remoting.ClientSession.ConnectionError} | 88 * @type {remoting.ClientSession.ConnectionError} |
| 80 */ | 89 */ |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 this.plugin.width + 'x' + this.plugin.height + '.'); | 415 this.plugin.width + 'x' + this.plugin.height + '.'); |
| 407 this.plugin.setScaleToFit(remoting.scaleToFit); | 416 this.plugin.setScaleToFit(remoting.scaleToFit); |
| 408 }; | 417 }; |
| 409 | 418 |
| 410 /** | 419 /** |
| 411 * Returns an associative array with a set of stats for this connection. | 420 * Returns an associative array with a set of stats for this connection. |
| 412 * | 421 * |
| 413 * @return {Object.<string, number>} The connection statistics. | 422 * @return {Object.<string, number>} The connection statistics. |
| 414 */ | 423 */ |
| 415 remoting.ClientSession.prototype.stats = function() { | 424 remoting.ClientSession.prototype.stats = function() { |
| 416 return { | 425 var dict = {}; |
| 417 'video_bandwidth': this.plugin.videoBandwidth, | 426 dict[remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH] = |
| 418 'video_frame_rate': this.plugin.videoFrameRate, | 427 this.plugin.videoBandwidth; |
| 419 'capture_latency': this.plugin.videoCaptureLatency, | 428 dict[remoting.ClientSession.STATS_KEY_VIDEO_FRAME_RATE] = |
| 420 'encode_latency': this.plugin.videoEncodeLatency, | 429 this.plugin.videoFrameRate; |
| 421 'decode_latency': this.plugin.videoDecodeLatency, | 430 dict[remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY] = |
| 422 'render_latency': this.plugin.videoRenderLatency, | 431 this.plugin.videoCaptureLatency; |
| 423 'roundtrip_latency': this.plugin.roundTripLatency | 432 dict[remoting.ClientSession.STATS_KEY_ENCODE_LATENCY] = |
| 424 }; | 433 this.plugin.videoEncodeLatency; |
| 434 dict[remoting.ClientSession.STATS_KEY_DECODE_LATENCY] = | |
| 435 this.plugin.videoDecodeLatency; | |
| 436 dict[remoting.ClientSession.STATS_KEY_RENDER_LATENCY] = | |
| 437 this.plugin.videoRenderLatency; | |
| 438 dict[remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY] = | |
| 439 this.plugin.roundTripLatency; | |
| 440 return dict; | |
|
Jamie
2011/12/09 19:47:56
Nit: Why change to this form of construction?
simonmorris
2011/12/09 21:12:12
The other form only works with compile-time
consta
| |
| 425 }; | 441 }; |
| 442 | |
| 443 /** | |
| 444 * Logs statistics. | |
| 445 * | |
| 446 * @param {Object.<string, number>} stats | |
| 447 */ | |
| 448 remoting.ClientSession.prototype.logStatistics = function(stats) { | |
| 449 this.logToServer.logStatistics(stats); | |
| 450 }; | |
| OLD | NEW |