зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1809895 - Part 4: Implement ReadableStream::ErrorNative and use it in BodyStream r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D166922
This commit is contained in:
Родитель
db1b686751
Коммит
b1c436975f
|
@ -398,12 +398,10 @@ void BodyStream::ErrorPropagation(JSContext* aCx,
|
|||
|
||||
{
|
||||
MutexSingleWriterAutoUnlock unlock(mMutex);
|
||||
// Don't re-error an already errored stream.
|
||||
if (aStream->State() == ReadableStream::ReaderState::Readable) {
|
||||
IgnoredErrorResult rv;
|
||||
ReadableStreamError(aCx, aStream, errorValue, rv);
|
||||
NS_WARNING_ASSERTION(!rv.Failed(), "Failed to error BodyStream");
|
||||
}
|
||||
// This will be ignored if it's already errored.
|
||||
IgnoredErrorResult rv;
|
||||
aStream->ErrorNative(aCx, errorValue, rv);
|
||||
NS_WARNING_ASSERTION(!rv.Failed(), "Failed to error BodyStream");
|
||||
}
|
||||
|
||||
if (mState == eInitializing) {
|
||||
|
|
|
@ -130,7 +130,7 @@ class BodyStream final : public nsIInputStreamCallback,
|
|||
// This is a script boundary until Bug 1750605 is resolved and allows us
|
||||
// to replace this with MOZ_CAN_RUN_SCRIPT.
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY void EnqueueChunkWithSizeIntoStream(
|
||||
JSContext* aCx, ReadableStream* aStream, uint64_t bytes,
|
||||
JSContext* aCx, ReadableStream* aStream, uint64_t aAvailableData,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void ErrorPropagation(JSContext* aCx,
|
||||
|
|
|
@ -1066,6 +1066,21 @@ void ReadableStream::CloseNative(JSContext* aCx, ErrorResult& aRv) {
|
|||
ReadableStreamDefaultControllerClose(aCx, controller, aRv);
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestream-error
|
||||
void ReadableStream::ErrorNative(JSContext* aCx, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv) {
|
||||
// Step 1: If stream.[[controller]] implements ReadableByteStreamController,
|
||||
// then perform ! ReadableByteStreamControllerError(stream.[[controller]], e).
|
||||
if (mController->IsByte()) {
|
||||
ReadableByteStreamControllerError(mController->AsByte(), aError, aRv);
|
||||
return;
|
||||
}
|
||||
// Step 2: Otherwise, perform !
|
||||
// ReadableStreamDefaultControllerError(stream.[[controller]], e).
|
||||
ReadableStreamDefaultControllerError(aCx, mController->AsDefault(), aError,
|
||||
aRv);
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestream-current-byob-request-view
|
||||
static void CurrentBYOBRequestView(JSContext* aCx,
|
||||
ReadableByteStreamController& aController,
|
||||
|
|
|
@ -119,6 +119,10 @@ class ReadableStream : public nsISupports, public nsWrapperCache {
|
|||
// https://streams.spec.whatwg.org/#readablestream-close
|
||||
MOZ_CAN_RUN_SCRIPT void CloseNative(JSContext* aCx, ErrorResult& aRv);
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestream-error
|
||||
void ErrorNative(JSContext* aCx, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestream-enqueue
|
||||
MOZ_CAN_RUN_SCRIPT void EnqueueNative(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aChunk,
|
||||
|
@ -151,7 +155,7 @@ class ReadableStream : public nsISupports, public nsWrapperCache {
|
|||
ErrorResult& aRv);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> PipeTo(
|
||||
WritableStream& aDestinaton, const StreamPipeOptions& aOptions,
|
||||
WritableStream& aDestination, const StreamPipeOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT void Tee(JSContext* aCx,
|
||||
|
|
Загрузка…
Ссылка в новой задаче