summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2023-09-28 22:17:06 -0500
committerBrian Smith <brian@dbsoft.org>2023-09-28 22:17:06 -0500
commit796863b719fb89775c291196f7880d0aba3f622c (patch)
treec8bf2cc79de1bca44a6777d8d830791c3f0691db
parentaced9bbc9474e158f07944d701b8bf187d7b0c77 (diff)
downloaduxp-796863b719fb89775c291196f7880d0aba3f622c.tar.gz
Issue #1442 - Part 18 - Cycle collect FetchStreamReader.
https://bugzilla.mozilla.org/show_bug.cgi?id=1128959
-rw-r--r--dom/fetch/Fetch.cpp7
-rw-r--r--dom/fetch/FetchStreamReader.cpp22
-rw-r--r--dom/fetch/FetchStreamReader.h3
-rw-r--r--dom/fetch/Response.cpp2
4 files changed, 28 insertions, 6 deletions
diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp
index d53886e96c..5943d60963 100644
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -922,10 +922,9 @@ FetchBody<Derived>::BodyUsed() const
// If this object is disturbed or locked, return false.
if (mReadableStreamBody) {
AutoJSAPI jsapi;
- // If we start tracking ownership, we need something like this.
- //if (!jsapi.Init(mOwner)) {
- // return true;
- //}
+ if (!jsapi.Init(mOwner)) {
+ return true;
+ }
JSContext* cx = jsapi.cx();
diff --git a/dom/fetch/FetchStreamReader.cpp b/dom/fetch/FetchStreamReader.cpp
index 3a24844dd9..702b44a6b6 100644
--- a/dom/fetch/FetchStreamReader.cpp
+++ b/dom/fetch/FetchStreamReader.cpp
@@ -44,7 +44,27 @@ private:
} // anonymous
-NS_IMPL_ISUPPORTS(FetchStreamReader, nsIOutputStreamCallback)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(FetchStreamReader)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(FetchStreamReader)
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(FetchStreamReader)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(FetchStreamReader)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(FetchStreamReader)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(FetchStreamReader)
+ NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mReader)
+NS_IMPL_CYCLE_COLLECTION_TRACE_END
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FetchStreamReader)
+ NS_INTERFACE_MAP_ENTRY(nsIOutputStreamCallback)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIOutputStreamCallback)
+NS_INTERFACE_MAP_END
/* static */ nsresult
FetchStreamReader::Create(JSContext* aCx, nsIGlobalObject* aGlobal,
diff --git a/dom/fetch/FetchStreamReader.h b/dom/fetch/FetchStreamReader.h
index d71021fdc8..6155ee17ff 100644
--- a/dom/fetch/FetchStreamReader.h
+++ b/dom/fetch/FetchStreamReader.h
@@ -23,7 +23,8 @@ class FetchStreamReader final : public nsIOutputStreamCallback
, public PromiseNativeHandler
{
public:
- NS_DECL_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(FetchStreamReader, nsIOutputStreamCallback)
NS_DECL_NSIOUTPUTSTREAMCALLBACK
// This creates a nsIInputStream able to retrieve data from the ReadableStream
diff --git a/dom/fetch/Response.cpp b/dom/fetch/Response.cpp
index 5055db4e24..3ee5e93d4a 100644
--- a/dom/fetch/Response.cpp
+++ b/dom/fetch/Response.cpp
@@ -36,6 +36,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(Response)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Response)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mHeaders)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mFetchStreamReader)
tmp->mReadableStreamBody = nullptr;
tmp->mReadableStreamReader = nullptr;
@@ -46,6 +47,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Response)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mHeaders)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFetchStreamReader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Response)