mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1809408 - Part 2: Move WritableStream internal algorithms to internal namespace r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D167829
This commit is contained in:
parent
d8983d750a
commit
938c3b15c9
@ -1594,7 +1594,7 @@ bool StructuredCloneHolder::CustomCanTransferHandler(
|
|||||||
// https://streams.spec.whatwg.org/#ref-for-transfer-steps①
|
// https://streams.spec.whatwg.org/#ref-for-transfer-steps①
|
||||||
// Step 1: If ! IsWritableStreamLocked(value) is true, throw a
|
// Step 1: If ! IsWritableStreamLocked(value) is true, throw a
|
||||||
// "DataCloneError" DOMException.
|
// "DataCloneError" DOMException.
|
||||||
return !IsWritableStreamLocked(stream);
|
return !stream->Locked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1605,8 +1605,7 @@ bool StructuredCloneHolder::CustomCanTransferHandler(
|
|||||||
// https://streams.spec.whatwg.org/#ref-for-transfer-steps②
|
// https://streams.spec.whatwg.org/#ref-for-transfer-steps②
|
||||||
// Step 3 + 4: If ! Is{Readable,Writable}StreamLocked(value) is true,
|
// Step 3 + 4: If ! Is{Readable,Writable}StreamLocked(value) is true,
|
||||||
// throw a "DataCloneError" DOMException.
|
// throw a "DataCloneError" DOMException.
|
||||||
return !stream->Readable()->Locked() &&
|
return !stream->Readable()->Locked() && !stream->Writable()->Locked();
|
||||||
!IsWritableStreamLocked(stream->Writable());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@ inline void ImplCycleCollectionUnlink(
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
using namespace streams_abstract;
|
||||||
|
|
||||||
// Only needed for refcounted objects.
|
// Only needed for refcounted objects.
|
||||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(
|
||||||
ReadableStream, (mGlobal, mController, mReader), (mStoredError))
|
ReadableStream, (mGlobal, mController, mReader), (mStoredError))
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
using namespace streams_abstract;
|
||||||
|
|
||||||
struct PipeToReadRequest;
|
struct PipeToReadRequest;
|
||||||
class WriteFinishedPromiseHandler;
|
class WriteFinishedPromiseHandler;
|
||||||
class ShutdownActionFinishedPromiseHandler;
|
class ShutdownActionFinishedPromiseHandler;
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
using namespace streams_abstract;
|
||||||
|
|
||||||
static void PackAndPostMessage(JSContext* aCx, MessagePort* aPort,
|
static void PackAndPostMessage(JSContext* aCx, MessagePort* aPort,
|
||||||
const nsAString& aType,
|
const nsAString& aType,
|
||||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv) {
|
JS::Handle<JS::Value> aValue, ErrorResult& aRv) {
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
using namespace streams_abstract;
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(
|
||||||
WritableStream,
|
WritableStream,
|
||||||
(mGlobal, mCloseRequest, mController, mInFlightWriteRequest,
|
(mGlobal, mCloseRequest, mController, mInFlightWriteRequest,
|
||||||
@ -499,6 +501,7 @@ already_AddRefed<WritableStream> WritableStream::Constructor(
|
|||||||
return writableStream.forget();
|
return writableStream.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
// https://streams.spec.whatwg.org/#writable-stream-abort
|
// https://streams.spec.whatwg.org/#writable-stream-abort
|
||||||
already_AddRefed<Promise> WritableStreamAbort(JSContext* aCx,
|
already_AddRefed<Promise> WritableStreamAbort(JSContext* aCx,
|
||||||
WritableStream* aStream,
|
WritableStream* aStream,
|
||||||
@ -576,6 +579,7 @@ already_AddRefed<Promise> WritableStreamAbort(JSContext* aCx,
|
|||||||
// Step 12. Return promise.
|
// Step 12. Return promise.
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#ws-abort
|
// https://streams.spec.whatwg.org/#ws-abort
|
||||||
already_AddRefed<Promise> WritableStream::Abort(JSContext* aCx,
|
already_AddRefed<Promise> WritableStream::Abort(JSContext* aCx,
|
||||||
@ -593,6 +597,7 @@ already_AddRefed<Promise> WritableStream::Abort(JSContext* aCx,
|
|||||||
return WritableStreamAbort(aCx, thisRefPtr, aReason, aRv);
|
return WritableStreamAbort(aCx, thisRefPtr, aReason, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
// https://streams.spec.whatwg.org/#writable-stream-close
|
// https://streams.spec.whatwg.org/#writable-stream-close
|
||||||
already_AddRefed<Promise> WritableStreamClose(JSContext* aCx,
|
already_AddRefed<Promise> WritableStreamClose(JSContext* aCx,
|
||||||
WritableStream* aStream,
|
WritableStream* aStream,
|
||||||
@ -644,6 +649,7 @@ already_AddRefed<Promise> WritableStreamClose(JSContext* aCx,
|
|||||||
// Step 10. Return promise.
|
// Step 10. Return promise.
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#ws-close
|
// https://streams.spec.whatwg.org/#ws-close
|
||||||
already_AddRefed<Promise> WritableStream::Close(JSContext* aCx,
|
already_AddRefed<Promise> WritableStream::Close(JSContext* aCx,
|
||||||
@ -667,6 +673,8 @@ already_AddRefed<Promise> WritableStream::Close(JSContext* aCx,
|
|||||||
return WritableStreamClose(aCx, thisRefPtr, aRv);
|
return WritableStreamClose(aCx, thisRefPtr, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#acquire-writable-stream-default-writer
|
// https://streams.spec.whatwg.org/#acquire-writable-stream-default-writer
|
||||||
already_AddRefed<WritableStreamDefaultWriter>
|
already_AddRefed<WritableStreamDefaultWriter>
|
||||||
AcquireWritableStreamDefaultWriter(WritableStream* aStream, ErrorResult& aRv) {
|
AcquireWritableStreamDefaultWriter(WritableStream* aStream, ErrorResult& aRv) {
|
||||||
@ -714,11 +722,14 @@ already_AddRefed<WritableStream> CreateWritableStream(
|
|||||||
return stream.forget();
|
return stream.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
already_AddRefed<WritableStreamDefaultWriter> WritableStream::GetWriter(
|
already_AddRefed<WritableStreamDefaultWriter> WritableStream::GetWriter(
|
||||||
ErrorResult& aRv) {
|
ErrorResult& aRv) {
|
||||||
return AcquireWritableStreamDefaultWriter(this, aRv);
|
return AcquireWritableStreamDefaultWriter(this, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
// https://streams.spec.whatwg.org/#writable-stream-add-write-request
|
// https://streams.spec.whatwg.org/#writable-stream-add-write-request
|
||||||
already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
||||||
WritableStream* aStream) {
|
WritableStream* aStream) {
|
||||||
@ -738,6 +749,7 @@ already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
|||||||
// Step 5. Return promise.
|
// Step 5. Return promise.
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#writablestream-set-up
|
// https://streams.spec.whatwg.org/#writablestream-set-up
|
||||||
void WritableStream::SetUpNative(JSContext* aCx,
|
void WritableStream::SetUpNative(JSContext* aCx,
|
||||||
|
@ -243,6 +243,8 @@ class WritableStream : public nsISupports, public nsWrapperCache {
|
|||||||
HoldDropJSObjectsCaller mHoldDropCaller;
|
HoldDropJSObjectsCaller mHoldDropCaller;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<WritableStream> CreateWritableStream(
|
MOZ_CAN_RUN_SCRIPT already_AddRefed<WritableStream> CreateWritableStream(
|
||||||
JSContext* aCx, nsIGlobalObject* aGlobal,
|
JSContext* aCx, nsIGlobalObject* aGlobal,
|
||||||
UnderlyingSinkAlgorithmsBase* aAlgorithms, double aHighWaterMark,
|
UnderlyingSinkAlgorithmsBase* aAlgorithms, double aHighWaterMark,
|
||||||
@ -265,6 +267,8 @@ already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
|||||||
already_AddRefed<WritableStreamDefaultWriter>
|
already_AddRefed<WritableStreamDefaultWriter>
|
||||||
AcquireWritableStreamDefaultWriter(WritableStream* aStream, ErrorResult& aRv);
|
AcquireWritableStreamDefaultWriter(WritableStream* aStream, ErrorResult& aRv);
|
||||||
|
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
||||||
#endif // mozilla_dom_WritableStream_h
|
#endif // mozilla_dom_WritableStream_h
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
using namespace streams_abstract;
|
||||||
|
|
||||||
// Note: Using the individual macros vs NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE
|
// Note: Using the individual macros vs NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE
|
||||||
// because I need to specificy a manual implementation of
|
// because I need to specificy a manual implementation of
|
||||||
// NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN.
|
// NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN.
|
||||||
@ -118,6 +120,8 @@ void WritableStreamDefaultController::SetSignal(AbortSignal* aSignal) {
|
|||||||
mSignal = aSignal;
|
mSignal = aSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT static void
|
MOZ_CAN_RUN_SCRIPT static void
|
||||||
WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||||
@ -555,4 +559,6 @@ double WritableStreamDefaultControllerGetChunkSize(
|
|||||||
return chunkSize;
|
return chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
@ -137,6 +137,8 @@ class WritableStreamDefaultController final : public nsISupports,
|
|||||||
RefPtr<WritableStream> mStream;
|
RefPtr<WritableStream> mStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
|
|
||||||
MOZ_CAN_RUN_SCRIPT void SetUpWritableStreamDefaultController(
|
MOZ_CAN_RUN_SCRIPT void SetUpWritableStreamDefaultController(
|
||||||
JSContext* aCx, WritableStream* aStream,
|
JSContext* aCx, WritableStream* aStream,
|
||||||
WritableStreamDefaultController* aController,
|
WritableStreamDefaultController* aController,
|
||||||
@ -169,6 +171,8 @@ MOZ_CAN_RUN_SCRIPT double WritableStreamDefaultControllerGetChunkSize(
|
|||||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||||
JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
|
JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
|
||||||
|
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
||||||
#endif // mozilla_dom_WritableStreamDefaultController_h
|
#endif // mozilla_dom_WritableStreamDefaultController_h
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
using namespace streams_abstract;
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_CLASS(WritableStreamDefaultWriter)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(WritableStreamDefaultWriter)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WritableStreamDefaultWriter)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WritableStreamDefaultWriter)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mStream, mReadyPromise,
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mStream, mReadyPromise,
|
||||||
@ -97,6 +99,7 @@ already_AddRefed<Promise> WritableStreamDefaultWriter::Ready() {
|
|||||||
return readyPromise.forget();
|
return readyPromise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-get-desired-size
|
// https://streams.spec.whatwg.org/#writable-stream-default-writer-get-desired-size
|
||||||
Nullable<double> WritableStreamDefaultWriterGetDesiredSize(
|
Nullable<double> WritableStreamDefaultWriterGetDesiredSize(
|
||||||
WritableStreamDefaultWriter* aWriter) {
|
WritableStreamDefaultWriter* aWriter) {
|
||||||
@ -121,6 +124,7 @@ Nullable<double> WritableStreamDefaultWriterGetDesiredSize(
|
|||||||
// ! WritableStreamDefaultControllerGetDesiredSize(stream.[[controller]]).
|
// ! WritableStreamDefaultControllerGetDesiredSize(stream.[[controller]]).
|
||||||
return stream->Controller()->GetDesiredSize();
|
return stream->Controller()->GetDesiredSize();
|
||||||
}
|
}
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#default-writer-desired-size
|
// https://streams.spec.whatwg.org/#default-writer-desired-size
|
||||||
Nullable<double> WritableStreamDefaultWriter::GetDesiredSize(ErrorResult& aRv) {
|
Nullable<double> WritableStreamDefaultWriter::GetDesiredSize(ErrorResult& aRv) {
|
||||||
@ -204,6 +208,7 @@ already_AddRefed<Promise> WritableStreamDefaultWriter::Close(JSContext* aCx,
|
|||||||
return WritableStreamDefaultWriterClose(aCx, thisRefPtr, aRv);
|
return WritableStreamDefaultWriterClose(aCx, thisRefPtr, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-release
|
// https://streams.spec.whatwg.org/#writable-stream-default-writer-release
|
||||||
void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
||||||
WritableStreamDefaultWriter* aWriter) {
|
WritableStreamDefaultWriter* aWriter) {
|
||||||
@ -242,6 +247,7 @@ void WritableStreamDefaultWriterRelease(JSContext* aCx,
|
|||||||
// Step 8. Set writer.[[stream]] to undefined.
|
// Step 8. Set writer.[[stream]] to undefined.
|
||||||
aWriter->SetStream(nullptr);
|
aWriter->SetStream(nullptr);
|
||||||
}
|
}
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#default-writer-release-lock
|
// https://streams.spec.whatwg.org/#default-writer-release-lock
|
||||||
void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx) {
|
void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx) {
|
||||||
@ -261,6 +267,7 @@ void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx) {
|
|||||||
return WritableStreamDefaultWriterRelease(aCx, thisRefPtr);
|
return WritableStreamDefaultWriterRelease(aCx, thisRefPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-write
|
// https://streams.spec.whatwg.org/#writable-stream-default-writer-write
|
||||||
already_AddRefed<Promise> WritableStreamDefaultWriterWrite(
|
already_AddRefed<Promise> WritableStreamDefaultWriterWrite(
|
||||||
JSContext* aCx, WritableStreamDefaultWriter* aWriter,
|
JSContext* aCx, WritableStreamDefaultWriter* aWriter,
|
||||||
@ -332,6 +339,7 @@ already_AddRefed<Promise> WritableStreamDefaultWriterWrite(
|
|||||||
// Step 13. Return promise.
|
// Step 13. Return promise.
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#default-writer-write
|
// https://streams.spec.whatwg.org/#default-writer-write
|
||||||
already_AddRefed<Promise> WritableStreamDefaultWriter::Write(
|
already_AddRefed<Promise> WritableStreamDefaultWriter::Write(
|
||||||
@ -347,6 +355,8 @@ already_AddRefed<Promise> WritableStreamDefaultWriter::Write(
|
|||||||
return WritableStreamDefaultWriterWrite(aCx, this, aChunk, aRv);
|
return WritableStreamDefaultWriterWrite(aCx, this, aChunk, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-writer
|
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-writer
|
||||||
void SetUpWritableStreamDefaultWriter(WritableStreamDefaultWriter* aWriter,
|
void SetUpWritableStreamDefaultWriter(WritableStreamDefaultWriter* aWriter,
|
||||||
WritableStream* aStream,
|
WritableStream* aStream,
|
||||||
@ -530,4 +540,6 @@ already_AddRefed<Promise> WritableStreamDefaultWriterCloseWithErrorPropagation(
|
|||||||
return WritableStreamDefaultWriterClose(aCx, aWriter, aRv);
|
return WritableStreamDefaultWriterClose(aCx, aWriter, aRv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
@ -79,6 +79,8 @@ class WritableStreamDefaultWriter final : public nsISupports,
|
|||||||
RefPtr<Promise> mClosedPromise;
|
RefPtr<Promise> mClosedPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace streams_abstract {
|
||||||
|
|
||||||
void SetUpWritableStreamDefaultWriter(WritableStreamDefaultWriter* aWriter,
|
void SetUpWritableStreamDefaultWriter(WritableStreamDefaultWriter* aWriter,
|
||||||
WritableStream* aStream,
|
WritableStream* aStream,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
@ -103,6 +105,8 @@ MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise>
|
|||||||
WritableStreamDefaultWriterCloseWithErrorPropagation(
|
WritableStreamDefaultWriterCloseWithErrorPropagation(
|
||||||
JSContext* aCx, WritableStreamDefaultWriter* aWriter, ErrorResult& aRv);
|
JSContext* aCx, WritableStreamDefaultWriter* aWriter, ErrorResult& aRv);
|
||||||
|
|
||||||
|
} // namespace streams_abstract
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
||||||
#endif // mozilla_dom_WritableStreamDefaultWriter_h
|
#endif // mozilla_dom_WritableStreamDefaultWriter_h
|
||||||
|
Loading…
Reference in New Issue
Block a user