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

Side by Side Diff: third_party/WebKit/Source/core/streams/ReadableStream.js

Issue 1902963003: [Streams] UnderlyingSourceBase should be kept alive only when locked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-stream-operations
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 readableStreamController = v8.createPrivateSymbol('[[controller]]'); 8 const readableStreamController = v8.createPrivateSymbol('[[controller]]');
9 const readableStreamQueue = v8.createPrivateSymbol('[[queue]]'); 9 const readableStreamQueue = v8.createPrivateSymbol('[[queue]]');
10 const readableStreamQueueSize = 10 const readableStreamQueueSize =
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 class ReadableStreamReader { 270 class ReadableStreamReader {
271 constructor(stream) { 271 constructor(stream) {
272 if (IsReadableStream(stream) === false) { 272 if (IsReadableStream(stream) === false) {
273 throw new TypeError(errReaderConstructorBadArgument); 273 throw new TypeError(errReaderConstructorBadArgument);
274 } 274 }
275 if (IsReadableStreamLocked(stream) === true) { 275 if (IsReadableStreamLocked(stream) === true) {
276 throw new TypeError(errReaderConstructorStreamAlreadyLocked); 276 throw new TypeError(errReaderConstructorStreamAlreadyLocked);
277 } 277 }
278 278
279 // TODO(yhirano): Remove this when we don't need hasPendingActivity in
280 // blink::UnderlyingSourceBase.
281 if (stream[readableStreamController] === null) {
282 // The stream is created with an external controller (i.e. made in
283 // Blink).
284 const underlyingSource = stream[readableStreamUnderlyingSource];
285 callFunction(underlyingSource.notifyLockAcquired, underlyingSource);
286 }
287
279 this[readableStreamReaderOwnerReadableStream] = stream; 288 this[readableStreamReaderOwnerReadableStream] = stream;
280 stream[readableStreamReader] = this; 289 stream[readableStreamReader] = this;
281 290
282 this[readableStreamReaderReadRequests] = new v8.InternalPackedArray(); 291 this[readableStreamReaderReadRequests] = new v8.InternalPackedArray();
283 292
284 switch (stream[readableStreamState]) { 293 switch (stream[readableStreamState]) {
285 case STATE_READABLE: 294 case STATE_READABLE:
286 this[readableStreamReaderClosedPromise] = v8.createPromise(); 295 this[readableStreamReaderClosedPromise] = v8.createPromise();
287 break; 296 break;
288 case STATE_CLOSED: 297 case STATE_CLOSED:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 344
336 const stream = this[readableStreamReaderOwnerReadableStream]; 345 const stream = this[readableStreamReaderOwnerReadableStream];
337 if (stream === undefined) { 346 if (stream === undefined) {
338 return undefined; 347 return undefined;
339 } 348 }
340 349
341 if (this[readableStreamReaderReadRequests].length > 0) { 350 if (this[readableStreamReaderReadRequests].length > 0) {
342 throw new TypeError(errReleaseReaderWithPendingRead); 351 throw new TypeError(errReleaseReaderWithPendingRead);
343 } 352 }
344 353
354 // TODO(yhirano): Remove this when we don't need hasPendingActivity in
355 // blink::UnderlyingSourceBase.
356 if (stream[readableStreamController] === null) {
357 // The stream is created with an external controller (i.e. made in
358 // Blink).
359 const underlyingSource = stream[readableStreamUnderlyingSource];
360 callFunction(underlyingSource.notifyLockReleased, underlyingSource);
361 }
362
345 if (stream[readableStreamState] === STATE_READABLE) { 363 if (stream[readableStreamState] === STATE_READABLE) {
346 v8.rejectPromise(this[readableStreamReaderClosedPromise], 364 v8.rejectPromise(this[readableStreamReaderClosedPromise],
347 new TypeError(errReleasedReaderClosedPromise)); 365 new TypeError(errReleasedReaderClosedPromise));
348 } else { 366 } else {
349 this[readableStreamReaderClosedPromise] = 367 this[readableStreamReaderClosedPromise] =
350 Promise_reject(new TypeError(errReleasedReaderClosedPromise)); 368 Promise_reject(new TypeError(errReleasedReaderClosedPromise));
351 } 369 }
352 370
353 this[readableStreamReaderOwnerReadableStream][readableStreamReader] = 371 this[readableStreamReaderOwnerReadableStream][readableStreamReader] =
354 undefined; 372 undefined;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 binding.GetReadableStreamDesiredSize = GetReadableStreamDesiredSize; 830 binding.GetReadableStreamDesiredSize = GetReadableStreamDesiredSize;
813 binding.EnqueueInReadableStream = EnqueueInReadableStream; 831 binding.EnqueueInReadableStream = EnqueueInReadableStream;
814 binding.ErrorReadableStream = ErrorReadableStream; 832 binding.ErrorReadableStream = ErrorReadableStream;
815 833
816 binding.createReadableStreamWithExternalController = 834 binding.createReadableStreamWithExternalController =
817 (underlyingSource, strategy) => { 835 (underlyingSource, strategy) => {
818 return new ReadableStream( 836 return new ReadableStream(
819 underlyingSource, strategy, createWithExternalControllerSentinel); 837 underlyingSource, strategy, createWithExternalControllerSentinel);
820 }; 838 };
821 }); 839 });
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/streams/ReadableStreamOperationsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698