зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1811538 - Part 3: Remove ErrorResult that became redundant r=smaug
Some spec comments now matches the implementations (as `Perform ! Foo()` means Foo can't fail). This only covers a small part of actual redundant ErrorResult parameters because: 1. This patch stack only covers Promise::CreateFallible and does not cover helper functions e.g. Promise::CreateResolvedWithUndefined. 2. All callback calls still require ErrorResult as the IDL layer uses the existing Promise::Create Differential Revision: https://phabricator.services.mozilla.com/D167701
This commit is contained in:
Родитель
ea0cb48ccd
Коммит
98c86fef45
|
@ -370,10 +370,7 @@ already_AddRefed<Promise> FileSystemWritableFileStream::Write(
|
|||
RefPtr<Promise> promise = writer->Write(cx, val, aError);
|
||||
|
||||
// Step 3. Release writer.
|
||||
{
|
||||
IgnoredErrorResult error;
|
||||
writer->ReleaseLock(cx, error);
|
||||
}
|
||||
writer->ReleaseLock(cx);
|
||||
|
||||
// Step 4. Return result.
|
||||
return promise.forget();
|
||||
|
@ -411,10 +408,7 @@ already_AddRefed<Promise> FileSystemWritableFileStream::Seek(
|
|||
RefPtr<Promise> promise = writer->Write(cx, val, aError);
|
||||
|
||||
// Step 3. Release writer.
|
||||
{
|
||||
IgnoredErrorResult error;
|
||||
writer->ReleaseLock(cx, error);
|
||||
}
|
||||
writer->ReleaseLock(cx);
|
||||
|
||||
// Step 4. Return result.
|
||||
return promise.forget();
|
||||
|
@ -452,10 +446,7 @@ already_AddRefed<Promise> FileSystemWritableFileStream::Truncate(
|
|||
RefPtr<Promise> promise = writer->Write(cx, val, aError);
|
||||
|
||||
// Step 3. Release writer.
|
||||
{
|
||||
IgnoredErrorResult error;
|
||||
writer->ReleaseLock(cx, error);
|
||||
}
|
||||
writer->ReleaseLock(cx);
|
||||
|
||||
// Step 4. Return result.
|
||||
return promise.forget();
|
||||
|
|
|
@ -60,10 +60,7 @@ void SetUpReadableStreamBYOBReader(ReadableStreamBYOBReader* reader,
|
|||
}
|
||||
|
||||
// Step 3. Perform ! ReadableStreamReaderGenericInitialize(reader, stream).
|
||||
ReadableStreamReaderGenericInitialize(reader, &stream, rv);
|
||||
if (rv.Failed()) {
|
||||
return;
|
||||
}
|
||||
ReadableStreamReaderGenericInitialize(reader, &stream);
|
||||
|
||||
// Step 4. Set reader.[[readIntoRequests]] to a new empty list.
|
||||
reader->ReadIntoRequests().clear();
|
||||
|
|
|
@ -59,8 +59,7 @@ JSObject* ReadableStreamDefaultReader::WrapObject(
|
|||
|
||||
// https://streams.spec.whatwg.org/#readable-stream-reader-generic-initialize
|
||||
bool ReadableStreamReaderGenericInitialize(ReadableStreamGenericReader* aReader,
|
||||
ReadableStream* aStream,
|
||||
ErrorResult& aRv) {
|
||||
ReadableStream* aStream) {
|
||||
// Step 1.
|
||||
aReader->SetStream(aStream);
|
||||
|
||||
|
@ -121,7 +120,7 @@ ReadableStreamDefaultReader::Constructor(const GlobalObject& aGlobal,
|
|||
|
||||
// Step 2.
|
||||
RefPtr<ReadableStream> streamPtr = &aStream;
|
||||
if (!ReadableStreamReaderGenericInitialize(reader, streamPtr, aRv)) {
|
||||
if (!ReadableStreamReaderGenericInitialize(reader, streamPtr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -407,7 +406,7 @@ void SetUpReadableStreamDefaultReader(ReadableStreamDefaultReader* aReader,
|
|||
}
|
||||
|
||||
// Step 2.
|
||||
if (!ReadableStreamReaderGenericInitialize(aReader, aStream, aRv)) {
|
||||
if (!ReadableStreamReaderGenericInitialize(aReader, aStream)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,7 @@ class ReadableStreamGenericReader : public nsISupports {
|
|||
};
|
||||
|
||||
bool ReadableStreamReaderGenericInitialize(ReadableStreamGenericReader* aReader,
|
||||
ReadableStream* aStream,
|
||||
ErrorResult& aRv);
|
||||
ReadableStream* aStream);
|
||||
|
||||
void ReadableStreamReaderGenericRelease(ReadableStreamGenericReader* aReader,
|
||||
ErrorResult& aRv);
|
||||
|
|
|
@ -538,9 +538,7 @@ void PipeToPump::Finalize(JSContext* aCx,
|
|||
JS::Handle<mozilla::Maybe<JS::Value>> aError) {
|
||||
IgnoredErrorResult rv;
|
||||
// Step 1. Perform ! WritableStreamDefaultWriterRelease(writer).
|
||||
WritableStreamDefaultWriterRelease(aCx, mWriter, rv);
|
||||
NS_WARNING_ASSERTION(!rv.Failed(),
|
||||
"WritableStreamDefaultWriterRelease should not fail.");
|
||||
WritableStreamDefaultWriterRelease(aCx, mWriter);
|
||||
|
||||
// Step 2. If reader implements ReadableStreamBYOBReader,
|
||||
// perform ! ReadableStreamBYOBReaderRelease(reader).
|
||||
|
|
|
@ -177,7 +177,7 @@ class SetUpTransformWritableMessageEventListener final
|
|||
// Note: This promise field is shared with the sink algorithms.
|
||||
Promise* BackpressurePromise() { return mBackpressurePromise; }
|
||||
|
||||
void CreateBackpressurePromise(ErrorResult& aRv) {
|
||||
void CreateBackpressurePromise() {
|
||||
mBackpressurePromise =
|
||||
Promise::CreateInfallible(mController->GetParentObject());
|
||||
}
|
||||
|
@ -317,10 +317,7 @@ class CrossRealmWritableUnderlyingSinkAlgorithms final
|
|||
// promise resolved with undefined.
|
||||
// Note: This promise field is shared with the message event listener.
|
||||
if (!mListener->BackpressurePromise()) {
|
||||
mListener->CreateBackpressurePromise(aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
mListener->CreateBackpressurePromise();
|
||||
mListener->BackpressurePromise()->MaybeResolveWithUndefined();
|
||||
}
|
||||
|
||||
|
@ -333,11 +330,7 @@ class CrossRealmWritableUnderlyingSinkAlgorithms final
|
|||
MessagePort* aPort,
|
||||
JS::Handle<JS::Value> aChunk) -> already_AddRefed<Promise> {
|
||||
// Step 2.1: Set backpressurePromise to a new promise.
|
||||
aListener->CreateBackpressurePromise(aRv);
|
||||
if (aRv.Failed()) {
|
||||
aPort->Close();
|
||||
return nullptr;
|
||||
}
|
||||
aListener->CreateBackpressurePromise();
|
||||
|
||||
// Step 2.2: Let result be PackAndPostMessageHandlingError(port,
|
||||
// "chunk", chunk).
|
||||
|
|
|
@ -137,7 +137,7 @@ void TransformStreamErrorWritableAndUnblockWrite(JSContext* aCx,
|
|||
// Step 3: If stream.[[backpressure]] is true, perform !
|
||||
// TransformStreamSetBackpressure(stream, false).
|
||||
if (aStream->Backpressure()) {
|
||||
aStream->SetBackpressure(false, aRv);
|
||||
aStream->SetBackpressure(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ class TransformStreamUnderlyingSourceAlgorithms final
|
|||
MOZ_ASSERT(mStream->BackpressureChangePromise());
|
||||
|
||||
// Step 3: Perform ! TransformStreamSetBackpressure(stream, false).
|
||||
mStream->SetBackpressure(false, aRv);
|
||||
mStream->SetBackpressure(false);
|
||||
|
||||
// Step 4: Return stream.[[backpressureChangePromise]].
|
||||
return do_AddRef(mStream->BackpressureChangePromise());
|
||||
|
@ -506,7 +506,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
|
|||
NS_INTERFACE_MAP_END_INHERITING(UnderlyingSourceAlgorithmsBase)
|
||||
|
||||
// https://streams.spec.whatwg.org/#transform-stream-set-backpressure
|
||||
void TransformStream::SetBackpressure(bool aBackpressure, ErrorResult& aRv) {
|
||||
void TransformStream::SetBackpressure(bool aBackpressure) {
|
||||
// Step 1. Assert: stream.[[backpressure]] is not backpressure.
|
||||
MOZ_ASSERT(Backpressure() != aBackpressure);
|
||||
|
||||
|
@ -569,7 +569,7 @@ void TransformStream::Initialize(JSContext* aCx, Promise* aStartPromise,
|
|||
mBackpressureChangePromise = nullptr;
|
||||
|
||||
// Step 10. Perform ! TransformStreamSetBackpressure(stream, true).
|
||||
SetBackpressure(true, aRv);
|
||||
SetBackpressure(true);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class TransformStream final : public nsISupports, public nsWrapperCache {
|
|||
// Internal slot accessors
|
||||
bool Backpressure() const { return mBackpressure; }
|
||||
Promise* BackpressureChangePromise() { return mBackpressureChangePromise; }
|
||||
void SetBackpressure(bool aBackpressure, ErrorResult& aRv);
|
||||
void SetBackpressure(bool aBackpressure);
|
||||
MOZ_KNOWN_LIVE TransformStreamDefaultController* Controller() {
|
||||
return mController;
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ void TransformStreamDefaultController::Enqueue(JSContext* aCx,
|
|||
MOZ_ASSERT(backpressure);
|
||||
|
||||
// Step 7.2: Perform ! TransformStreamSetBackpressure(true).
|
||||
stream->SetBackpressure(true, aRv);
|
||||
stream->SetBackpressure(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -392,10 +392,7 @@ void WritableStream::StartErroring(JSContext* aCx,
|
|||
// Step 8. If writer is not undefined, perform !
|
||||
// WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason).
|
||||
if (writer) {
|
||||
WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, aReason, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, aReason);
|
||||
}
|
||||
|
||||
// Step 9. If ! WritableStreamHasOperationMarkedInFlight(stream) is false
|
||||
|
@ -407,7 +404,7 @@ void WritableStream::StartErroring(JSContext* aCx,
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-update-backpressure
|
||||
void WritableStream::UpdateBackpressure(bool aBackpressure, ErrorResult& aRv) {
|
||||
void WritableStream::UpdateBackpressure(bool aBackpressure) {
|
||||
// Step 1. Assert: stream.[[state]] is "writable".
|
||||
MOZ_ASSERT(mState == WriterState::Writable);
|
||||
// Step 2. Assert: ! WritableStreamCloseQueuedOrInFlight(stream) is false.
|
||||
|
@ -723,8 +720,8 @@ already_AddRefed<WritableStreamDefaultWriter> WritableStream::GetWriter(
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-add-write-request
|
||||
already_AddRefed<Promise> WritableStreamAddWriteRequest(WritableStream* aStream,
|
||||
ErrorResult& aRv) {
|
||||
already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
||||
WritableStream* aStream) {
|
||||
// Step 1. Assert: ! IsWritableStreamLocked(stream) is true.
|
||||
MOZ_ASSERT(IsWritableStreamLocked(aStream));
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ class WritableStream : public nsISupports, public nsWrapperCache {
|
|||
ErrorResult& aRv);
|
||||
|
||||
// WritableStreamUpdateBackpressure
|
||||
void UpdateBackpressure(bool aBackpressure, ErrorResult& aRv);
|
||||
void UpdateBackpressure(bool aBackpressure);
|
||||
|
||||
// [Transferable]
|
||||
// https://html.spec.whatwg.org/multipage/structured-data.html#transfer-steps
|
||||
|
@ -237,8 +237,8 @@ MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> WritableStreamAbort(
|
|||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> WritableStreamClose(
|
||||
JSContext* aCx, WritableStream* aStream, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> WritableStreamAddWriteRequest(WritableStream* aStream,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
||||
WritableStream* aStream);
|
||||
|
||||
already_AddRefed<WritableStreamDefaultWriter>
|
||||
AcquireWritableStreamDefaultWriter(WritableStream* aStream, ErrorResult& aRv);
|
||||
|
|
|
@ -168,10 +168,7 @@ void SetUpWritableStreamDefaultController(
|
|||
bool backpressure = aController->GetBackpressure();
|
||||
|
||||
// Step 14. Perform ! WritableStreamUpdateBackpressure(stream, backpressure).
|
||||
aStream->UpdateBackpressure(backpressure, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
aStream->UpdateBackpressure(backpressure);
|
||||
|
||||
// Step 15. Let startResult be the result of performing startAlgorithm. (This
|
||||
// may throw an exception.)
|
||||
|
@ -342,10 +339,7 @@ MOZ_CAN_RUN_SCRIPT static void WritableStreamDefaultControllerProcessWrite(
|
|||
bool backpressure = aController->GetBackpressure();
|
||||
// Step 4.5.2. Perform ! WritableStreamUpdateBackpressure(stream,
|
||||
// backpressure).
|
||||
stream->UpdateBackpressure(backpressure, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
stream->UpdateBackpressure(backpressure);
|
||||
}
|
||||
|
||||
// Step 4.6. Perform !
|
||||
|
@ -483,10 +477,7 @@ void WritableStreamDefaultControllerWrite(
|
|||
|
||||
// Step 4.2. Perform ! WritableStreamUpdateBackpressure(stream,
|
||||
// backpressure).
|
||||
stream->UpdateBackpressure(backpressure, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
stream->UpdateBackpressure(backpressure);
|
||||
}
|
||||
|
||||
// Step 5. Perform
|
||||
|
|
|
@ -206,8 +206,7 @@ already_AddRefed<Promise> WritableStreamDefaultWriter::Close(JSContext* aCx,
|
|||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-release
|
||||
void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
||||
WritableStreamDefaultWriter* aWriter,
|
||||
ErrorResult& aRv) {
|
||||
WritableStreamDefaultWriter* aWriter) {
|
||||
// Step 1. Let stream be writer.[[stream]].
|
||||
RefPtr<WritableStream> stream = aWriter->GetStream();
|
||||
|
||||
|
@ -229,20 +228,13 @@ void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
|||
// Step 5. Perform !
|
||||
// WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer,
|
||||
// releasedError).
|
||||
WritableStreamDefaultWriterEnsureReadyPromiseRejected(aWriter, releasedError,
|
||||
aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
WritableStreamDefaultWriterEnsureReadyPromiseRejected(aWriter, releasedError);
|
||||
|
||||
// Step 6. Perform !
|
||||
// WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer,
|
||||
// releasedError).
|
||||
WritableStreamDefaultWriterEnsureClosedPromiseRejected(aWriter, releasedError,
|
||||
aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
WritableStreamDefaultWriterEnsureClosedPromiseRejected(aWriter,
|
||||
releasedError);
|
||||
|
||||
// Step 7. Set stream.[[writer]] to undefined.
|
||||
stream->SetWriter(nullptr);
|
||||
|
@ -252,8 +244,7 @@ void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#default-writer-release-lock
|
||||
void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx,
|
||||
ErrorResult& aRv) {
|
||||
void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx) {
|
||||
// Step 1. Let stream be this.[[stream]].
|
||||
RefPtr<WritableStream> stream = mStream;
|
||||
|
||||
|
@ -267,7 +258,7 @@ void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx,
|
|||
|
||||
// Step 4. Perform ! WritableStreamDefaultWriterRelease(this).
|
||||
RefPtr<WritableStreamDefaultWriter> thisRefPtr = this;
|
||||
return WritableStreamDefaultWriterRelease(aCx, thisRefPtr, aRv);
|
||||
return WritableStreamDefaultWriterRelease(aCx, thisRefPtr);
|
||||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-write
|
||||
|
@ -329,10 +320,7 @@ already_AddRefed<Promise> WritableStreamDefaultWriterWrite(
|
|||
MOZ_ASSERT(state == WritableStream::WriterState::Writable);
|
||||
|
||||
// Step 11. Let promise be ! WritableStreamAddWriteRequest(stream).
|
||||
RefPtr<Promise> promise = WritableStreamAddWriteRequest(stream, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<Promise> promise = WritableStreamAddWriteRequest(stream);
|
||||
|
||||
// Step 12. Perform ! WritableStreamDefaultControllerWrite(controller, chunk,
|
||||
// chunkSize).
|
||||
|
@ -469,8 +457,7 @@ void SetUpWritableStreamDefaultWriter(WritableStreamDefaultWriter* aWriter,
|
|||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-ensure-closed-promise-rejected
|
||||
void WritableStreamDefaultWriterEnsureClosedPromiseRejected(
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv) {
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError) {
|
||||
RefPtr<Promise> closedPromise = aWriter->ClosedPromise();
|
||||
// Step 1. If writer.[[closedPromise]].[[PromiseState]] is "pending", reject
|
||||
// writer.[[closedPromise]] with error.
|
||||
|
@ -490,8 +477,7 @@ void WritableStreamDefaultWriterEnsureClosedPromiseRejected(
|
|||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-ensure-ready-promise-rejected
|
||||
void WritableStreamDefaultWriterEnsureReadyPromiseRejected(
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv) {
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError) {
|
||||
RefPtr<Promise> readyPromise = aWriter->ReadyPromise();
|
||||
// Step 1. If writer.[[readyPromise]].[[PromiseState]] is "pending", reject
|
||||
// writer.[[readyPromise]] with error.
|
||||
|
|
|
@ -66,7 +66,7 @@ class WritableStreamDefaultWriter final : public nsISupports,
|
|||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Close(JSContext* aCx,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void ReleaseLock(JSContext* aCx, ErrorResult& aRv);
|
||||
void ReleaseLock(JSContext* aCx);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Write(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
|
||||
|
@ -84,19 +84,16 @@ void SetUpWritableStreamDefaultWriter(WritableStreamDefaultWriter* aWriter,
|
|||
ErrorResult& aRv);
|
||||
|
||||
void WritableStreamDefaultWriterEnsureClosedPromiseRejected(
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError);
|
||||
|
||||
void WritableStreamDefaultWriterEnsureReadyPromiseRejected(
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
WritableStreamDefaultWriter* aWriter, JS::Handle<JS::Value> aError);
|
||||
|
||||
Nullable<double> WritableStreamDefaultWriterGetDesiredSize(
|
||||
WritableStreamDefaultWriter* aWriter);
|
||||
|
||||
void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
||||
WritableStreamDefaultWriter* aWriter,
|
||||
ErrorResult& aRv);
|
||||
WritableStreamDefaultWriter* aWriter);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> WritableStreamDefaultWriterWrite(
|
||||
JSContext* aCx, WritableStreamDefaultWriter* aWriter,
|
||||
|
|
|
@ -22,7 +22,6 @@ interface WritableStreamDefaultWriter {
|
|||
[NewObject]
|
||||
Promise<undefined> close();
|
||||
|
||||
[Throws]
|
||||
undefined releaseLock();
|
||||
|
||||
[NewObject]
|
||||
|
|
Загрузка…
Ссылка в новой задаче