Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Side by Side Diff: extensions/renderer/resources/data_sender.js

Issue 628763002: Mojo JS bindings: simplify mojo.connectToService() usage - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed template indentation Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_sender', [ 5 define('data_sender', [
6 'async_waiter', 6 'async_waiter',
7 'device/serial/data_stream.mojom', 7 'device/serial/data_stream.mojom',
8 'device/serial/data_stream_serialization.mojom', 8 'device/serial/data_stream_serialization.mojom',
9 'mojo/public/js/bindings/core', 9 'mojo/public/js/bindings/core',
10 'mojo/public/js/bindings/router', 10 'mojo/public/js/bindings/router',
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 flags: core.CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, 175 flags: core.CREATE_DATA_PIPE_OPTIONS_FLAG_NONE,
176 elementNumBytes: 1, 176 elementNumBytes: 1,
177 capacityNumBytes: bufferSize, 177 capacityNumBytes: bufferSize,
178 }; 178 };
179 var sendPipe = core.createDataPipe(dataPipeOptions); 179 var sendPipe = core.createDataPipe(dataPipeOptions);
180 this.init_(handle, sendPipe.producerHandle, fatalErrorValue); 180 this.init_(handle, sendPipe.producerHandle, fatalErrorValue);
181 this.sink_.init(sendPipe.consumerHandle); 181 this.sink_.init(sendPipe.consumerHandle);
182 } 182 }
183 183
184 DataSender.prototype = 184 DataSender.prototype =
185 $Object.create(dataStreamMojom.DataSinkClientStub.prototype); 185 $Object.create(dataStreamMojom.DataSinkClient.stubClass.prototype);
186 186
187 /** 187 /**
188 * Closes this DataSender. 188 * Closes this DataSender.
189 */ 189 */
190 DataSender.prototype.close = function() { 190 DataSender.prototype.close = function() {
191 if (this.shutDown_) 191 if (this.shutDown_)
192 return; 192 return;
193 this.shutDown_ = true; 193 this.shutDown_ = true;
194 this.waiter_.stop(); 194 this.waiter_.stop();
195 this.router_.close(); 195 this.router_.close();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 /** 235 /**
236 * The [Router]{@link module:mojo/public/js/bindings/router.Router} for the 236 * The [Router]{@link module:mojo/public/js/bindings/router.Router} for the
237 * connection to the DataSink. 237 * connection to the DataSink.
238 * @private 238 * @private
239 */ 239 */
240 this.router_ = new routerModule.Router(sink); 240 this.router_ = new routerModule.Router(sink);
241 /** 241 /**
242 * The connection to the DataSink. 242 * The connection to the DataSink.
243 * @private 243 * @private
244 */ 244 */
245 this.sink_ = new dataStreamMojom.DataSinkProxy(this.router_); 245 this.sink_ = new dataStreamMojom.DataSink.proxyClass(this.router_);
246 this.router_.setIncomingReceiver(this); 246 this.router_.setIncomingReceiver(this);
247 /** 247 /**
248 * The async waiter used to wait for 248 * The async waiter used to wait for
249 * {@link module:data_sender.DataSender#sendPipe_} to be writable. 249 * {@link module:data_sender.DataSender#sendPipe_} to be writable.
250 * @type {!module:async_waiter.AsyncWaiter} 250 * @type {!module:async_waiter.AsyncWaiter}
251 * @private 251 * @private
252 */ 252 */
253 this.waiter_ = new asyncWaiter.AsyncWaiter( 253 this.waiter_ = new asyncWaiter.AsyncWaiter(
254 this.sendPipe_, core.HANDLE_SIGNAL_WRITABLE, 254 this.sendPipe_, core.HANDLE_SIGNAL_WRITABLE,
255 this.onHandleReady_.bind(this)); 255 this.onHandleReady_.bind(this));
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // Note: Only the first PendingSend in |pendingSends_| will have data to 468 // Note: Only the first PendingSend in |pendingSends_| will have data to
469 // flush as only the first can have written data to the data pipe. 469 // flush as only the first can have written data to the data pipe.
470 bytesToFlush += result.bytesToFlush; 470 bytesToFlush += result.bytesToFlush;
471 } 471 }
472 this.callCancelCallback_(); 472 this.callCancelCallback_();
473 return Promise.resolve({bytes_to_flush: bytesToFlush}); 473 return Promise.resolve({bytes_to_flush: bytesToFlush});
474 }; 474 };
475 475
476 return {DataSender: DataSender}; 476 return {DataSender: DataSender};
477 }); 477 });
OLDNEW
« no previous file with comments | « extensions/renderer/resources/data_receiver.js ('k') | extensions/renderer/resources/serial_service.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698