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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 * @param {Element} container The element to add the plugin to. | 104 * @param {Element} container The element to add the plugin to. |
105 * @param {string} oauth2AccessToken A valid OAuth2 access token. | 105 * @param {string} oauth2AccessToken A valid OAuth2 access token. |
106 * @return {void} Nothing. | 106 * @return {void} Nothing. |
107 */ | 107 */ |
108 remoting.ClientSession.prototype.createPluginAndConnect = | 108 remoting.ClientSession.prototype.createPluginAndConnect = |
109 function(container, oauth2AccessToken) { | 109 function(container, oauth2AccessToken) { |
110 this.plugin = document.createElement('embed'); | 110 this.plugin = document.createElement('embed'); |
111 this.plugin.id = this.PLUGIN_ID; | 111 this.plugin.id = this.PLUGIN_ID; |
112 this.plugin.src = 'about://none'; | 112 this.plugin.src = 'about://none'; |
113 this.plugin.type = 'pepper-application/x-chromoting'; | 113 this.plugin.type = 'pepper-application/x-chromoting'; |
114 this.plugin.width = 0; | |
115 this.plugin.height = 0; | |
Jamie
2011/07/25 23:09:50
Although the plugin is blank until we transition t
| |
114 container.appendChild(this.plugin); | 116 container.appendChild(this.plugin); |
115 | 117 |
116 if (!this.isPluginVersionSupported_(this.plugin)) { | 118 if (!this.isPluginVersionSupported_(this.plugin)) { |
117 // TODO(ajwong): Remove from parent. | 119 // TODO(ajwong): Remove from parent. |
118 delete this.plugin; | 120 delete this.plugin; |
119 this.setState_(remoting.ClientSession.BAD_PLUGIN_VERSION); | 121 this.setState_(remoting.ClientSession.BAD_PLUGIN_VERSION); |
120 return; | 122 return; |
121 } | 123 } |
122 | 124 |
123 var that = this; | 125 var that = this; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 } else if (state == this.plugin.STATUS_FAILED) { | 315 } else if (state == this.plugin.STATUS_FAILED) { |
314 this.setState_(remoting.ClientSession.State.CONNECTION_FAILED); | 316 this.setState_(remoting.ClientSession.State.CONNECTION_FAILED); |
315 } | 317 } |
316 }; | 318 }; |
317 | 319 |
318 /** | 320 /** |
319 * @param {remoting.ClientSession.State} state The new state for the session. | 321 * @param {remoting.ClientSession.State} state The new state for the session. |
320 * @return {void} Nothing. | 322 * @return {void} Nothing. |
321 */ | 323 */ |
322 remoting.ClientSession.prototype.setState_ = function(state) { | 324 remoting.ClientSession.prototype.setState_ = function(state) { |
325 if (this.onStateChange) { | |
326 this.onStateChange(state); | |
327 } | |
323 this.state = state; | 328 this.state = state; |
Jamie
2011/07/25 23:09:50
Defer setting the current state so that the callba
awong
2011/07/26 18:51:27
Huh...We should document clearly that onStateChang
Jamie
2011/07/26 19:02:35
Yes, that's generally my preference too, but if th
| |
324 if (this.onStateChange) { | |
325 this.onStateChange(this.state); | |
326 } | |
327 }; | 329 }; |
328 | 330 |
329 /** | 331 /** |
330 * This is a callback that gets called when the desktop size contained in the | 332 * This is a callback that gets called when the desktop size contained in the |
331 * the plugin has changed. | 333 * the plugin has changed. |
332 * | 334 * |
333 * @return {void} Nothing. | 335 * @return {void} Nothing. |
334 */ | 336 */ |
335 remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() { | 337 remoting.ClientSession.prototype.onDesktopSizeChanged_ = function() { |
336 var width = this.plugin.desktopWidth; | 338 var width = this.plugin.desktopWidth; |
(...skipping 23 matching lines...) Expand all Loading... | |
360 'video_bandwidth': this.plugin.videoBandwidth, | 362 'video_bandwidth': this.plugin.videoBandwidth, |
361 'capture_latency': this.plugin.videoCaptureLatency, | 363 'capture_latency': this.plugin.videoCaptureLatency, |
362 'encode_latency': this.plugin.videoEncodeLatency, | 364 'encode_latency': this.plugin.videoEncodeLatency, |
363 'decode_latency': this.plugin.videoDecodeLatency, | 365 'decode_latency': this.plugin.videoDecodeLatency, |
364 'render_latency': this.plugin.videoRenderLatency, | 366 'render_latency': this.plugin.videoRenderLatency, |
365 'roundtrip_latency': this.plugin.roundTripLatency | 367 'roundtrip_latency': this.plugin.roundTripLatency |
366 }; | 368 }; |
367 }; | 369 }; |
368 | 370 |
369 }()); | 371 }()); |
OLD | NEW |