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

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

Issue 678223002: Fix a bug in data_sender.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 * resolves. 289 * resolves.
290 * @return {!Promise.<SerializedDataSender>} A promise that will resolve to 290 * @return {!Promise.<SerializedDataSender>} A promise that will resolve to
291 * the serialization of this DataSender. If this DataSender has shut down, 291 * the serialization of this DataSender. If this DataSender has shut down,
292 * the promise will resolve to null. 292 * the promise will resolve to null.
293 */ 293 */
294 DataSender.prototype.serialize = function() { 294 DataSender.prototype.serialize = function() {
295 if (this.shutDown_) 295 if (this.shutDown_)
296 return Promise.resolve(null); 296 return Promise.resolve(null);
297 297
298 var readyToSerialize = Promise.resolve(); 298 var readyToSerialize = Promise.resolve();
299 if (this.pendingSends_.length) { 299 if (this.pendingSends_.length || this.sendsAwaitingAck_.length) {
300 if (this.pendingCancel_) 300 if (this.pendingCancel_)
301 readyToSerialize = this.cancelPromise_; 301 readyToSerialize = this.cancelPromise_;
302 else 302 else
303 readyToSerialize = this.cancel(this.fatalErrorValue_); 303 readyToSerialize = this.cancel(this.fatalErrorValue_);
304 } 304 }
305 return readyToSerialize.then(function() { 305 return readyToSerialize.then(function() {
306 this.waiter_.stop(); 306 this.waiter_.stop();
307 var serialized = new serialization.SerializedDataSender(); 307 var serialized = new serialization.SerializedDataSender();
308 serialized.sink = this.router_.connector_.handle_, 308 serialized.sink = this.router_.connector_.handle_,
309 serialized.data_pipe = this.sendPipe_, 309 serialized.data_pipe = this.sendPipe_,
(...skipping 158 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698