| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 (function(global, binding, v8) { | 5 (function(global, binding, v8) { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 const _reader = v8.createPrivateSymbol('[[reader]]'); | 8 const _reader = v8.createPrivateSymbol('[[reader]]'); |
| 9 const _storedError = v8.createPrivateSymbol('[[storedError]]'); | 9 const _storedError = v8.createPrivateSymbol('[[storedError]]'); |
| 10 const _controller = v8.createPrivateSymbol('[[controller]]'); | 10 const _controller = v8.createPrivateSymbol('[[controller]]'); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 return true; | 262 return true; |
| 263 } | 263 } |
| 264 | 264 |
| 265 function pump() { | 265 function pump() { |
| 266 if (shuttingDown) { | 266 if (shuttingDown) { |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 const desiredSize = | 269 const desiredSize = |
| 270 binding.WritableStreamDefaultWriterGetDesiredSize(writer); | 270 binding.WritableStreamDefaultWriterGetDesiredSize(writer); |
| 271 if (desiredSize === null) { | 271 if (desiredSize === null) { |
| 272 writableError(binding.getWritableStreamStoredError(dest)); | 272 // This can happen if abort() is queued but not yet started when |
| 273 // pipeTo() is called. In that case [[storedError]] is not set yet, and |
| 274 // we need to wait until it is before we can cancel the pipe. Once |
| 275 // [[storedError]] has been set, the rejection handler set on the writer |
| 276 // closed promise above will detect it, so all we need to do here is |
| 277 // nothing. |
| 278 return; |
| 273 } | 279 } |
| 274 if (desiredSize <= 0) { | 280 if (desiredSize <= 0) { |
| 275 thenPromise( | 281 thenPromise( |
| 276 binding.getWritableStreamDefaultWriterReadyPromise(writer), pump, | 282 binding.getWritableStreamDefaultWriterReadyPromise(writer), pump, |
| 277 writableError); | 283 writableError); |
| 278 return; | 284 return; |
| 279 } | 285 } |
| 280 reading = true; | 286 reading = true; |
| 281 // TODO(ricea): Delay reads heuristically when desiredSize is low. | 287 // TODO(ricea): Delay reads heuristically when desiredSize is low. |
| 282 thenPromise( | 288 thenPromise( |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 (underlyingSource, strategy) => { | 1113 (underlyingSource, strategy) => { |
| 1108 return new ReadableStream( | 1114 return new ReadableStream( |
| 1109 underlyingSource, strategy, createWithExternalControllerSentinel); | 1115 underlyingSource, strategy, createWithExternalControllerSentinel); |
| 1110 }; | 1116 }; |
| 1111 | 1117 |
| 1112 // Temporary exports while pipeTo() and pipeThrough() are behind flags | 1118 // Temporary exports while pipeTo() and pipeThrough() are behind flags |
| 1113 binding.ReadableStream_prototype_pipeThrough = | 1119 binding.ReadableStream_prototype_pipeThrough = |
| 1114 ReadableStream_prototype_pipeThrough; | 1120 ReadableStream_prototype_pipeThrough; |
| 1115 binding.ReadableStream_prototype_pipeTo = ReadableStream_prototype_pipeTo; | 1121 binding.ReadableStream_prototype_pipeTo = ReadableStream_prototype_pipeTo; |
| 1116 }); | 1122 }); |
| OLD | NEW |