summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-09-29 09:25:52 -0500
committerBrian Smith <brian@dbsoft.org>2023-09-29 09:25:52 -0500
commit7d55641d43923a71df7275abb1cf564dc04eda3c (patch)
tree15c5b33fcfb2028267770d595e7a8043bc35c6e8
parent3f799def4da3bf91fc1b3ec94fbe67dc3bd2bedb (diff)
downloaduxp-7d55641d43923a71df7275abb1cf564dc04eda3c.tar.gz
Issue #1442 - Part 20 - FetchStream should not have an extra JS::Heap<ReadableStream>.
https://bugzilla.mozilla.org/show_bug.cgi?id=1390717
-rw-r--r--dom/fetch/Fetch.h9
-rw-r--r--dom/fetch/FetchStream.cpp7
-rw-r--r--dom/fetch/FetchStream.h2
3 files changed, 11 insertions, 7 deletions
diff --git a/dom/fetch/Fetch.h b/dom/fetch/Fetch.h
index 839d003833..0f79a63021 100644
--- a/dom/fetch/Fetch.h
+++ b/dom/fetch/Fetch.h
@@ -100,6 +100,8 @@ public:
NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
virtual void NullifyStream() = 0;
+
+ virtual JSObject* ReadableStreamBody() = 0;
};
/*
@@ -228,6 +230,13 @@ public:
mFetchStreamReader = nullptr;
}
+ JSObject*
+ ReadableStreamBody() override
+ {
+ MOZ_ASSERT(mReadableStreamBody);
+ return mReadableStreamBody;
+ }
+
virtual AbortSignal*
GetSignal() const = 0;
diff --git a/dom/fetch/FetchStream.cpp b/dom/fetch/FetchStream.cpp
index ec224e1c8d..63e6f150b9 100644
--- a/dom/fetch/FetchStream.cpp
+++ b/dom/fetch/FetchStream.cpp
@@ -161,8 +161,6 @@ FetchStream::Create(JSContext* aCx, FetchStreamHolder* aStreamHolder,
return;
}
- stream->mReadableStream = body;
-
// This will be released in FetchStream::FinalizeCallback(). We are
// guaranteed the jsapi will call FinalizeCallback when ReadableStream
// js object is finalized.
@@ -371,7 +369,6 @@ FetchStream::FetchStream(nsIGlobalObject* aGlobal,
, mStreamHolder(aStreamHolder)
, mOriginalInputStream(aInputStream)
, mOwningEventTarget(nullptr)
- , mReadableStream(nullptr)
{
MOZ_DIAGNOSTIC_ASSERT(aInputStream);
MOZ_DIAGNOSTIC_ASSERT(aStreamHolder);
@@ -428,7 +425,7 @@ FetchStream::OnInputStreamReady(nsIAsyncInputStream* aStream)
}
JSContext* cx = jsapi.cx();
- JS::Rooted<JSObject*> stream(cx, mReadableStream);
+ JS::Rooted<JSObject*> stream(cx, mStreamHolder->ReadableStreamBody());
uint64_t size = 0;
nsresult rv = mInputStream->Available(&size);
@@ -494,7 +491,7 @@ FetchStream::Close()
}
JSContext* cx = jsapi.cx();
- JS::Rooted<JSObject*> stream(cx, mReadableStream);
+ JS::Rooted<JSObject*> stream(cx, mStreamHolder->ReadableStreamBody());
CloseAndReleaseObjects(cx, stream);
}
diff --git a/dom/fetch/FetchStream.h b/dom/fetch/FetchStream.h
index 4562b3f351..80d120616d 100644
--- a/dom/fetch/FetchStream.h
+++ b/dom/fetch/FetchStream.h
@@ -125,8 +125,6 @@ private:
nsCOMPtr<nsIAsyncInputStream> mInputStream;
UniquePtr<workers::WorkerHolder> mWorkerHolder;
-
- JS::Heap<JSObject*> mReadableStream;
};
} // dom namespace