OLD | NEW |
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 define('data_receiver', [ | 5 define('data_receiver', [ |
6 'device/serial/data_stream.mojom', | 6 'device/serial/data_stream.mojom', |
7 'device/serial/data_stream_serialization.mojom', | 7 'device/serial/data_stream_serialization.mojom', |
8 'mojo/public/js/bindings/core', | 8 'mojo/public/js/core', |
9 'mojo/public/js/bindings/router', | 9 'mojo/public/js/router', |
10 ], function(dataStream, serialization, core, router) { | 10 ], function(dataStream, serialization, core, router) { |
11 /** | 11 /** |
12 * @module data_receiver | 12 * @module data_receiver |
13 */ | 13 */ |
14 | 14 |
15 /** | 15 /** |
16 * A pending receive operation. | 16 * A pending receive operation. |
17 * @constructor | 17 * @constructor |
18 * @alias module:data_receiver~PendingReceive | 18 * @alias module:data_receiver~PendingReceive |
19 * @private | 19 * @private |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 * @param {boolean} paused Whether the DataSource is paused. | 128 * @param {boolean} paused Whether the DataSource is paused. |
129 * @private | 129 * @private |
130 */ | 130 */ |
131 DataReceiver.prototype.init_ = function(source, | 131 DataReceiver.prototype.init_ = function(source, |
132 fatalErrorValue, | 132 fatalErrorValue, |
133 bytesReceived, | 133 bytesReceived, |
134 pendingError, | 134 pendingError, |
135 pendingData, | 135 pendingData, |
136 paused) { | 136 paused) { |
137 /** | 137 /** |
138 * The [Router]{@link module:mojo/public/js/bindings/router.Router} for the | 138 * The [Router]{@link module:mojo/public/js/router.Router} for the |
139 * connection to the DataSource. | 139 * connection to the DataSource. |
140 * @private | 140 * @private |
141 */ | 141 */ |
142 this.router_ = new router.Router(source); | 142 this.router_ = new router.Router(source); |
143 /** | 143 /** |
144 * The connection to the DataSource. | 144 * The connection to the DataSource. |
145 * @private | 145 * @private |
146 */ | 146 */ |
147 this.source_ = new dataStream.DataSource.proxyClass(this.router_); | 147 this.source_ = new dataStream.DataSource.proxyClass(this.router_); |
148 this.router_.setIncomingReceiver(this); | 148 this.router_.setIncomingReceiver(this); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 var buffer = new ArrayBuffer(data.length); | 320 var buffer = new ArrayBuffer(data.length); |
321 var uintView = new Uint8Array(buffer); | 321 var uintView = new Uint8Array(buffer); |
322 uintView.set(data); | 322 uintView.set(data); |
323 this.pendingDataBuffers_.push(buffer); | 323 this.pendingDataBuffers_.push(buffer); |
324 if (this.receive_) | 324 if (this.receive_) |
325 this.dispatchData_(); | 325 this.dispatchData_(); |
326 }; | 326 }; |
327 | 327 |
328 return {DataReceiver: DataReceiver}; | 328 return {DataReceiver: DataReceiver}; |
329 }); | 329 }); |
OLD | NEW |