| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 that wraps low-level details of interacting with the client plugin. | 7 * Class that wraps low-level details of interacting with the client plugin. |
| 8 * | 8 * |
| 9 * This abstracts a <embed> element and controls the plugin which does | 9 * This abstracts a <embed> element and controls the plugin which does |
| 10 * the actual remoting work. It also handles differences between | 10 * the actual remoting work. It also handles differences between |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 this.onOutgoingIqHandler(message.data['iq']); | 112 this.onOutgoingIqHandler(message.data['iq']); |
| 113 } else if (message.method == 'logDebugMessage') { | 113 } else if (message.method == 'logDebugMessage') { |
| 114 if (typeof message.data['message'] != 'string') { | 114 if (typeof message.data['message'] != 'string') { |
| 115 console.error('Received invalid logDebugMessage message: ' + message_str); | 115 console.error('Received invalid logDebugMessage message: ' + message_str); |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 this.onDebugMessageHandler(message.data['message']); | 118 this.onDebugMessageHandler(message.data['message']); |
| 119 } else if (message.method == 'onConnectionStatus') { | 119 } else if (message.method == 'onConnectionStatus') { |
| 120 if (typeof message.data['state'] != 'string' || | 120 if (typeof message.data['state'] != 'string' || |
| 121 !(message.data['state'] in remoting.ClientSession.State) || | 121 !(message.data['state'] in remoting.ClientSession.State) || |
| 122 typeof message.data['error'] != 'string' || | 122 typeof message.data['error'] != 'string') { |
| 123 !(message.data['error'] in remoting.ClientSession.ConnectionError)) { | |
| 124 console.error('Received invalid onConnectionState message: ' + | 123 console.error('Received invalid onConnectionState message: ' + |
| 125 message_str); | 124 message_str); |
| 126 return; | 125 return; |
| 127 } | 126 } |
| 127 |
| 128 /** @type {remoting.ClientSession.State} */ | 128 /** @type {remoting.ClientSession.State} */ |
| 129 var state = remoting.ClientSession.State[message.data['state']]; | 129 var state = remoting.ClientSession.State[message.data['state']]; |
| 130 /** @type {remoting.ClientSession.ConnectionError} */ | 130 var error; |
| 131 var error = remoting.ClientSession.ConnectionError[message.data['error']]; | 131 if (message.data['error'] in remoting.ClientSession.ConnectionError) { |
| 132 error = /** @type {remoting.ClientSession.ConnectionError} */ |
| 133 remoting.ClientSession.ConnectionError[message.data['error']]; |
| 134 } else { |
| 135 error = remoting.ClientSession.ConnectionError.UNKNOWN; |
| 136 } |
| 137 |
| 132 this.onConnectionStatusUpdateHandler(state, error); | 138 this.onConnectionStatusUpdateHandler(state, error); |
| 133 } else if (message.method == 'onDesktopSize') { | 139 } else if (message.method == 'onDesktopSize') { |
| 134 if (typeof message.data['width'] != 'number' || | 140 if (typeof message.data['width'] != 'number' || |
| 135 typeof message.data['height'] != 'number') { | 141 typeof message.data['height'] != 'number') { |
| 136 console.error('Received invalid onDesktopSize message: ' + message_str); | 142 console.error('Received invalid onDesktopSize message: ' + message_str); |
| 137 return; | 143 return; |
| 138 } | 144 } |
| 139 this.desktopWidth = /** @type {number} */ message.data['width']; | 145 this.desktopWidth = /** @type {number} */ message.data['width']; |
| 140 this.desktopHeight = /** @type {number} */ message.data['height']; | 146 this.desktopHeight = /** @type {number} */ message.data['height']; |
| 141 this.onDesktopSizeUpdateHandler(); | 147 this.onDesktopSizeUpdateHandler(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 }; | 267 }; |
| 262 | 268 |
| 263 /** | 269 /** |
| 264 * Returns an associative array with a set of stats for this connecton. | 270 * Returns an associative array with a set of stats for this connecton. |
| 265 * | 271 * |
| 266 * @return {remoting.ClientSession.PerfStats} The connection statistics. | 272 * @return {remoting.ClientSession.PerfStats} The connection statistics. |
| 267 */ | 273 */ |
| 268 remoting.ClientPluginAsync.prototype.getPerfStats = function() { | 274 remoting.ClientPluginAsync.prototype.getPerfStats = function() { |
| 269 return this.perfStats_; | 275 return this.perfStats_; |
| 270 }; | 276 }; |
| OLD | NEW |