Bug 1753731 - Mark ReadRequest::CloseSteps as MOZ_CAN_RUN_SCRIPT r=mgaudet

Differential Revision: https://phabricator.services.mozilla.com/D137886
This commit is contained in:
Kagami Sascha Rosylight 2022-02-04 20:35:14 +00:00
Родитель f7542880f9
Коммит ef1c1d2562
9 изменённых файлов: 39 добавлений и 30 удалений

Просмотреть файл

@ -166,8 +166,10 @@ class BodyStream final : public nsIInputStreamCallback,
void ErrorPropagation(JSContext* aCx, const MutexAutoLock& aProofOfLock,
ReadableStream* aStream, nsresult aRv);
void CloseAndReleaseObjects(JSContext* aCx, const MutexAutoLock& aProofOfLock,
ReadableStream* aStream);
// TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605)
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects(
JSContext* aCx, const MutexAutoLock& aProofOfLock,
ReadableStream* aStream);
#else
void requestData(JSContext* aCx, JS::HandleObject aStream,
size_t aDesiredSize) override;

Просмотреть файл

@ -26,7 +26,8 @@ struct ReadRequest : public nsISupports,
virtual void ChunkSteps(JSContext* aCx, JS::Handle<JS::Value> aChunk,
ErrorResult& aRv) = 0;
virtual void CloseSteps(JSContext* aCx, ErrorResult& aRv) = 0;
MOZ_CAN_RUN_SCRIPT virtual void CloseSteps(JSContext* aCx,
ErrorResult& aRv) = 0;
virtual void ErrorSteps(JSContext* aCx, JS::Handle<JS::Value> e,
ErrorResult& aRv) = 0;

Просмотреть файл

@ -270,7 +270,7 @@ void ReadableByteStreamControllerClose(
JSContext* aCx, ReadableByteStreamController* aController,
ErrorResult& aRv) {
// Step 1.
ReadableStream* stream = aController->Stream();
RefPtr<ReadableStream> stream = aController->Stream();
// Step 2.
if (aController->CloseRequested() ||
@ -644,7 +644,7 @@ void ReadableByteStreamControllerEnqueue(
aRv.MightThrowJSException();
// Step 1.
ReadableStream* stream = aController->Stream();
RefPtr<ReadableStream> stream = aController->Stream();
// Step 2.
if (aController->CloseRequested() ||
@ -867,7 +867,8 @@ void ReadableByteStreamControllerHandleQueueDrain(
ReadableByteStreamControllerClearAlgorithms(aController);
// Step 2.2
ReadableStreamClose(aCx, aController->Stream(), aRv);
RefPtr<ReadableStream> stream = aController->Stream();
ReadableStreamClose(aCx, stream, aRv);
return;
}

Просмотреть файл

@ -62,7 +62,7 @@ class ReadableByteStreamController final : public ReadableStreamController,
Nullable<double> GetDesiredSize() const;
void Close(JSContext* aCx, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Close(JSContext* aCx, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Enqueue(JSContext* aCx, const ArrayBufferView& aChunk,
ErrorResult& aRv);
@ -364,7 +364,7 @@ ReadableByteStreamControllerGetBYOBRequest(
JSContext* aCx, ReadableByteStreamController* aController,
ErrorResult& aRv);
extern void ReadableByteStreamControllerClose(
MOZ_CAN_RUN_SCRIPT extern void ReadableByteStreamControllerClose(
JSContext* aCx, ReadableByteStreamController* aController,
ErrorResult& aRv);

Просмотреть файл

@ -160,13 +160,13 @@ extern double ReadableStreamGetNumReadRequests(ReadableStream* aStream);
extern void ReadableStreamError(JSContext* aCx, ReadableStream* aStream,
JS::Handle<JS::Value> aValue, ErrorResult& aRv);
extern void ReadableStreamClose(JSContext* aCx, ReadableStream* aStream,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT extern void ReadableStreamClose(JSContext* aCx,
ReadableStream* aStream,
ErrorResult& aRv);
extern void ReadableStreamFulfillReadRequest(JSContext* aCx,
ReadableStream* aStream,
JS::Handle<JS::Value> aChunk,
bool done, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT extern void ReadableStreamFulfillReadRequest(
JSContext* aCx, ReadableStream* aStream, JS::Handle<JS::Value> aChunk,
bool done, ErrorResult& aRv);
extern void ReadableStreamAddReadRequest(ReadableStream* aStream,
ReadRequest* aReadRequest);

Просмотреть файл

@ -207,7 +207,7 @@ void ReadableStreamDefaultControllerClose(
}
// Step 2.
ReadableStream* stream = aController->GetStream();
RefPtr<ReadableStream> stream = aController->GetStream();
// Step 3.
aController->SetCloseRequested(true);
@ -248,7 +248,7 @@ void ReadableStreamDefaultControllerEnqueue(
}
// Step 2.
ReadableStream* stream = aController->GetStream();
RefPtr<ReadableStream> stream = aController->GetStream();
// Step 3.
if (IsReadableStreamLocked(stream) &&
@ -679,7 +679,7 @@ void ReadableStreamDefaultController::PullSteps(JSContext* aCx,
ReadRequest* aReadRequest,
ErrorResult& aRv) {
// Step 1.
ReadableStream* stream = mStream;
RefPtr<ReadableStream> stream = mStream;
// Step 2.
if (!mQueue.isEmpty()) {

Просмотреть файл

@ -60,7 +60,7 @@ class ReadableStreamDefaultController final : public ReadableStreamController,
Nullable<double> GetDesiredSize();
void Close(JSContext* aCx, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Close(JSContext* aCx, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT void Enqueue(JSContext* aCx, JS::Handle<JS::Value> aChunk,
ErrorResult& aRv);
@ -158,7 +158,7 @@ MOZ_CAN_RUN_SCRIPT extern void ReadableStreamDefaultControllerEnqueue(
JSContext* aCx, ReadableStreamDefaultController* aController,
JS::Handle<JS::Value> aChunk, ErrorResult& aRv);
extern void ReadableStreamDefaultControllerClose(
MOZ_CAN_RUN_SCRIPT extern void ReadableStreamDefaultControllerClose(
JSContext* aCx, ReadableStreamDefaultController* aController,
ErrorResult& aRv);

Просмотреть файл

@ -188,8 +188,9 @@ void ReadableStreamDefaultTeeReadRequest::CloseSteps(JSContext* aCx,
// Step 2.
if (!mTeeState->Canceled1()) {
ReadableStreamDefaultControllerClose(
aCx, mTeeState->Branch1()->DefaultController(), aRv);
RefPtr<ReadableStreamDefaultController> controller(
mTeeState->Branch1()->DefaultController());
ReadableStreamDefaultControllerClose(aCx, controller, aRv);
if (aRv.Failed()) {
return;
}
@ -197,8 +198,9 @@ void ReadableStreamDefaultTeeReadRequest::CloseSteps(JSContext* aCx,
// Step 3.
if (!mTeeState->Canceled2()) {
ReadableStreamDefaultControllerClose(
aCx, mTeeState->Branch2()->DefaultController(), aRv);
RefPtr<ReadableStreamDefaultController> controller(
mTeeState->Branch2()->DefaultController());
ReadableStreamDefaultControllerClose(aCx, controller, aRv);
if (aRv.Failed()) {
return;
}
@ -490,8 +492,8 @@ struct PullWithDefaultReaderReadRequest final : public ReadRequest {
CycleCollectedJSContext::Get()->DispatchToMicroTask(task.forget());
}
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseSteps(JSContext* aCx,
ErrorResult& aRv) override {
MOZ_CAN_RUN_SCRIPT void CloseSteps(JSContext* aCx,
ErrorResult& aRv) override {
// Step numbering below is relative to Step 15.2. 'close steps' of
// https://streams.spec.whatwg.org/#abstract-opdef-readablebytestreamtee
@ -803,16 +805,18 @@ class PullWithBYOBReader_ReadIntoRequest final : public ReadIntoRequest {
// Step 4.
if (!byobCanceled) {
ReadableByteStreamControllerClose(aCx, byobBranch->Controller()->AsByte(),
aRv);
RefPtr<ReadableByteStreamController> controller =
byobBranch->Controller()->AsByte();
ReadableByteStreamControllerClose(aCx, controller, aRv);
if (aRv.Failed()) {
return;
}
}
// Step 5.
if (!otherCanceled) {
ReadableByteStreamControllerClose(
aCx, otherBranch->Controller()->AsByte(), aRv);
RefPtr<ReadableByteStreamController> controller =
otherBranch->Controller()->AsByte();
ReadableByteStreamControllerClose(aCx, controller, aRv);
if (aRv.Failed()) {
return;
}

Просмотреть файл

@ -61,7 +61,8 @@ struct ReadableStreamDefaultTeeReadRequest final : public ReadRequest {
virtual void ChunkSteps(JSContext* aCx, JS::Handle<JS::Value> aChunk,
ErrorResult& aRv) override;
virtual void CloseSteps(JSContext* aCx, ErrorResult& aRv) override;
MOZ_CAN_RUN_SCRIPT virtual void CloseSteps(JSContext* aCx,
ErrorResult& aRv) override;
virtual void ErrorSteps(JSContext* aCx, JS::Handle<JS::Value> aError,
ErrorResult& aRv) override;