зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1748728 - Correctly annotate WritableStreams implementation with CAN_RUN_SCRIPT r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D135228
This commit is contained in:
Родитель
1b1fa5ea28
Коммит
a923f6b2ae
|
@ -91,27 +91,26 @@ class WritableStream final : public nsISupports, public nsWrapperCache {
|
|||
}
|
||||
|
||||
// WritableStreamDealWithRejection
|
||||
void DealWithRejection(JSContext* aCx, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void DealWithRejection(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// WritableStreamFinishErroring
|
||||
void FinishErroring(JSContext* aCx, ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void FinishErroring(JSContext* aCx, ErrorResult& aRv);
|
||||
|
||||
// WritableStreamFinishInFlightClose
|
||||
void FinishInFlightClose();
|
||||
|
||||
// WritableStreamFinishInFlightCloseWithError
|
||||
void FinishInFlightCloseWithError(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void FinishInFlightCloseWithError(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aError, ErrorResult& aRv);
|
||||
|
||||
// WritableStreamFinishInFlightWrite
|
||||
void FinishInFlightWrite();
|
||||
|
||||
// WritableStreamFinishInFlightWriteWithError
|
||||
void FinishInFlightWriteWithError(JSContext* aCX,
|
||||
JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aR);
|
||||
MOZ_CAN_RUN_SCRIPT void FinishInFlightWriteWithError(
|
||||
JSContext* aCX, JS::Handle<JS::Value> aError, ErrorResult& aR);
|
||||
|
||||
// WritableStreamHasOperationMarkedInFlight
|
||||
bool HasOperationMarkedInFlight() const {
|
||||
|
@ -128,8 +127,9 @@ class WritableStream final : public nsISupports, public nsWrapperCache {
|
|||
void RejectCloseAndClosedPromiseIfNeeded();
|
||||
|
||||
// WritableStreamStartErroring
|
||||
void StartErroring(JSContext* aCx, JS::Handle<JS::Value> aReason,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void StartErroring(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aReason,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// WritableStreamUpdateBackpressure
|
||||
void UpdateBackpressure(bool aBackpressure, ErrorResult& aRv);
|
||||
|
@ -182,13 +182,12 @@ inline bool IsWritableStreamLocked(WritableStream* aStream) {
|
|||
return aStream->Locked();
|
||||
}
|
||||
|
||||
extern already_AddRefed<Promise> WritableStreamAbort(
|
||||
MOZ_CAN_RUN_SCRIPT extern already_AddRefed<Promise> WritableStreamAbort(
|
||||
JSContext* aCx, WritableStream* aStream, JS::Handle<JS::Value> aReason,
|
||||
ErrorResult& aRv);
|
||||
|
||||
extern already_AddRefed<Promise> WritableStreamClose(JSContext* aCx,
|
||||
WritableStream* aStream,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT extern already_AddRefed<Promise> WritableStreamClose(
|
||||
JSContext* aCx, WritableStream* aStream, ErrorResult& aRv);
|
||||
|
||||
extern already_AddRefed<Promise> WritableStreamAddWriteRequest(
|
||||
WritableStream* aStream, ErrorResult& aRv);
|
||||
|
|
|
@ -120,13 +120,15 @@ void WritableStreamDefaultController::SetSignal(AbortSignal* aSignal) {
|
|||
mSignal = aSignal;
|
||||
}
|
||||
|
||||
void WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
MOZ_CAN_RUN_SCRIPT static void
|
||||
WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
ErrorResult& aRv);
|
||||
|
||||
class WritableStartPromiseNativeHandler final : public PromiseNativeHandler {
|
||||
~WritableStartPromiseNativeHandler() = default;
|
||||
|
||||
// Virtually const, but cycle collected
|
||||
RefPtr<WritableStreamDefaultController> mController;
|
||||
|
||||
public:
|
||||
|
@ -137,7 +139,8 @@ class WritableStartPromiseNativeHandler final : public PromiseNativeHandler {
|
|||
WritableStreamDefaultController* aController)
|
||||
: PromiseNativeHandler(), mController(aController) {}
|
||||
|
||||
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
MOZ_CAN_RUN_SCRIPT void ResolvedCallback(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller
|
||||
// Step 17. Upon fulfillment of startPromise,
|
||||
// Step 17.1. Assert: stream.[[state]] is "writable" or "erroring".
|
||||
|
@ -150,13 +153,15 @@ class WritableStartPromiseNativeHandler final : public PromiseNativeHandler {
|
|||
// Step 17.3 Perform
|
||||
// ! WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller).
|
||||
IgnoredErrorResult rv;
|
||||
WritableStreamDefaultControllerAdvanceQueueIfNeeded(aCx, mController, rv);
|
||||
WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
aCx, MOZ_KnownLive(mController), rv);
|
||||
if (rv.MaybeSetPendingException(aCx)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
MOZ_CAN_RUN_SCRIPT void RejectedCallback(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
// https://streams.spec.whatwg.org/#set-up-writable-stream-default-controller
|
||||
RefPtr<WritableStream> stream = mController->Stream();
|
||||
// Step 18. Upon rejection of startPromise with reason r,
|
||||
|
@ -331,7 +336,8 @@ class SinkCloseNativePromiseHandler final : public PromiseNativeHandler {
|
|||
stream->FinishInFlightClose();
|
||||
}
|
||||
|
||||
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
MOZ_CAN_RUN_SCRIPT void RejectedCallback(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close
|
||||
RefPtr<WritableStream> stream = mController->Stream();
|
||||
// Step 8. Upon rejection of sinkClosePromise with reason reason,
|
||||
|
@ -355,7 +361,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SinkCloseNativePromiseHandler)
|
|||
NS_INTERFACE_MAP_END
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-close
|
||||
void WritableStreamDefaultControllerProcessClose(
|
||||
MOZ_CAN_RUN_SCRIPT static void WritableStreamDefaultControllerProcessClose(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
ErrorResult& aRv) {
|
||||
// Step 1. Let stream be controller.[[stream]].
|
||||
|
@ -395,6 +401,7 @@ void WritableStreamDefaultControllerProcessClose(
|
|||
class SinkWriteNativePromiseHandler final : public PromiseNativeHandler {
|
||||
~SinkWriteNativePromiseHandler() = default;
|
||||
|
||||
// Virtually const, but is cycle collected
|
||||
RefPtr<WritableStreamDefaultController> mController;
|
||||
|
||||
public:
|
||||
|
@ -405,7 +412,8 @@ class SinkWriteNativePromiseHandler final : public PromiseNativeHandler {
|
|||
WritableStreamDefaultController* aController)
|
||||
: PromiseNativeHandler(), mController(aController) {}
|
||||
|
||||
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
MOZ_CAN_RUN_SCRIPT void ResolvedCallback(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write
|
||||
RefPtr<WritableStream> stream = mController->Stream();
|
||||
|
||||
|
@ -441,14 +449,16 @@ class SinkWriteNativePromiseHandler final : public PromiseNativeHandler {
|
|||
// Step 4.6. Perform !
|
||||
// WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller).
|
||||
IgnoredErrorResult rv;
|
||||
WritableStreamDefaultControllerAdvanceQueueIfNeeded(aCx, mController, rv);
|
||||
WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
aCx, MOZ_KnownLive(mController), rv);
|
||||
// XXX Not Sure How To Handle Errors Inside Native Callbacks,
|
||||
NS_WARNING_ASSERTION(
|
||||
!rv.Failed(),
|
||||
"WritableStreamDefaultControllerAdvanceQueueIfNeeded failed");
|
||||
}
|
||||
|
||||
void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
MOZ_CAN_RUN_SCRIPT void RejectedCallback(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aValue) override {
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write
|
||||
RefPtr<WritableStream> stream = mController->Stream();
|
||||
|
||||
|
@ -476,7 +486,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SinkWriteNativePromiseHandler)
|
|||
NS_INTERFACE_MAP_END
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-controller-process-write
|
||||
void WritableStreamDefaultControllerProcessWrite(
|
||||
MOZ_CAN_RUN_SCRIPT static void WritableStreamDefaultControllerProcessWrite(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
JS::Handle<JS::Value> aChunk, ErrorResult& aRv) {
|
||||
// Step 1. Let stream be controller.[[stream]].
|
||||
|
@ -511,7 +521,7 @@ void WritableStreamDefaultControllerProcessWrite(
|
|||
constexpr JSWhyMagic CLOSE_SENTINEL = JS_GENERIC_MAGIC;
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-controller-advance-queue-if-needed
|
||||
void WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
static void WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
ErrorResult& aRv) {
|
||||
// Step 1. Let stream be controller.[[stream]].
|
||||
|
|
|
@ -51,12 +51,12 @@ class WritableStreamDefaultController final : public nsISupports,
|
|||
|
||||
AbortSignal* Signal() { return mSignal; }
|
||||
|
||||
void Error(JSContext* aCx, JS::Handle<JS::Value> aError, ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT void Error(JSContext* aCx, JS::Handle<JS::Value> aError,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// [[AbortSteps]]
|
||||
virtual already_AddRefed<Promise> AbortSteps(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aReason,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT virtual already_AddRefed<Promise> AbortSteps(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv);
|
||||
|
||||
// [[ErrorSteps]]
|
||||
virtual void ErrorSteps();
|
||||
|
@ -169,23 +169,23 @@ extern void SetUpWritableStreamDefaultControllerFromUnderlyingSink(
|
|||
UnderlyingSink& aUnderlyingSinkDict, double aHighWaterMark,
|
||||
QueuingStrategySize* aSizeAlgorithm, ErrorResult& aRv);
|
||||
|
||||
extern void WritableStreamDefaultControllerClose(
|
||||
MOZ_CAN_RUN_SCRIPT extern void WritableStreamDefaultControllerClose(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
ErrorResult& aRv);
|
||||
|
||||
extern void WritableStreamDefaultControllerWrite(
|
||||
MOZ_CAN_RUN_SCRIPT extern void WritableStreamDefaultControllerWrite(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
JS::Handle<JS::Value> aChunk, double chunkSize, ErrorResult& aRv);
|
||||
|
||||
extern void WritableStreamDefaultControllerError(
|
||||
MOZ_CAN_RUN_SCRIPT extern void WritableStreamDefaultControllerError(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
JS::Handle<JS::Value> aError, ErrorResult& aRv);
|
||||
|
||||
extern void WritableStreamDefaultControllerErrorIfNeeded(
|
||||
MOZ_CAN_RUN_SCRIPT extern void WritableStreamDefaultControllerErrorIfNeeded(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
JS::Handle<JS::Value> aError, ErrorResult& aRv);
|
||||
|
||||
extern double WritableStreamDefaultControllerGetChunkSize(
|
||||
MOZ_CAN_RUN_SCRIPT extern double WritableStreamDefaultControllerGetChunkSize(
|
||||
JSContext* aCx, WritableStreamDefaultController* aController,
|
||||
JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ Nullable<double> WritableStreamDefaultWriter::GetDesiredSize(ErrorResult& aRv) {
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-abort
|
||||
already_AddRefed<Promise> WritableStreamDefaultWriterAbort(
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> WritableStreamDefaultWriterAbort(
|
||||
JSContext* aCx, WritableStreamDefaultWriter* aWriter,
|
||||
JS::Handle<JS::Value> aReason, ErrorResult& aRv) {
|
||||
// Step 1. Let stream be writer.[[stream]].
|
||||
|
@ -164,8 +164,10 @@ already_AddRefed<Promise> WritableStreamDefaultWriter::Abort(
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-close
|
||||
already_AddRefed<Promise> WritableStreamDefaultWriterClose(
|
||||
JSContext* aCx, WritableStreamDefaultWriter* aWriter, ErrorResult& aRv) {
|
||||
MOZ_CAN_RUN_SCRIPT static already_AddRefed<Promise>
|
||||
WritableStreamDefaultWriterClose(JSContext* aCx,
|
||||
WritableStreamDefaultWriter* aWriter,
|
||||
ErrorResult& aRv) {
|
||||
// Step 1. Let stream be writer.[[stream]].
|
||||
RefPtr<WritableStream> stream = aWriter->GetStream();
|
||||
|
||||
|
@ -268,9 +270,11 @@ void WritableStreamDefaultWriter::ReleaseLock(JSContext* aCx,
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#writable-stream-default-writer-write
|
||||
already_AddRefed<Promise> WritableStreamDefaultWriterWrite(
|
||||
JSContext* aCx, WritableStreamDefaultWriter* aWriter,
|
||||
JS::Handle<JS::Value> aChunk, ErrorResult& aRv) {
|
||||
MOZ_CAN_RUN_SCRIPT static already_AddRefed<Promise>
|
||||
WritableStreamDefaultWriterWrite(JSContext* aCx,
|
||||
WritableStreamDefaultWriter* aWriter,
|
||||
JS::Handle<JS::Value> aChunk,
|
||||
ErrorResult& aRv) {
|
||||
// Step 1. Let stream be writer.[[stream]].
|
||||
RefPtr<WritableStream> stream = aWriter->GetStream();
|
||||
|
||||
|
|
|
@ -64,15 +64,16 @@ class WritableStreamDefaultWriter final : public nsISupports,
|
|||
|
||||
Nullable<double> GetDesiredSize(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Abort(JSContext* aCx, JS::Handle<JS::Value> aReason,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Abort(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aReason, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Close(JSContext* aCx, ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Close(JSContext* aCx,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void ReleaseLock(JSContext* aCx, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Write(JSContext* aCx, JS::Handle<JS::Value> aChunk,
|
||||
ErrorResult& aRv);
|
||||
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Write(
|
||||
JSContext* aCx, JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
|
||||
|
||||
// Internal Slots:
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче