Bug 1755594 - Part 2: Apply NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS to dom/streams/ r=mgaudet,smaug

Depends on D138903

Differential Revision: https://phabricator.services.mozilla.com/D138869
This commit is contained in:
Kagami Sascha Rosylight 2022-02-23 13:44:01 +00:00
parent ed9bb84c5d
commit 12776d464b
6 changed files with 36 additions and 183 deletions

View File

@ -71,22 +71,11 @@ inline void ImplCycleCollectionUnlink(
namespace mozilla::dom {
// Only needed for refcounted objects.
NS_IMPL_CYCLE_COLLECTION_CLASS(ReadableStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ReadableStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mController, mReader,
mErrorAlgorithm, mNativeUnderlyingSource)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->mStoredError.setNull();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ReadableStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal, mController, mReader,
mErrorAlgorithm, mNativeUnderlyingSource)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ReadableStream)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mStoredError)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(ReadableStream,
(mGlobal, mController,
mReader, mErrorAlgorithm,
mNativeUnderlyingSource),
(mStoredError))
NS_IMPL_CYCLE_COLLECTING_ADDREF(ReadableStream)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ReadableStream)

View File

@ -29,24 +29,13 @@ ReadableStreamBYOBRequest::~ReadableStreamBYOBRequest() {
mozilla::DropJSObjects(this);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(ReadableStreamBYOBRequest)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ReadableStreamBYOBRequest)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mController)
tmp->mView = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ReadableStreamBYOBRequest)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal, mController)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(ReadableStreamBYOBRequest,
(mGlobal, mController),
(mView))
NS_IMPL_CYCLE_COLLECTING_ADDREF(ReadableStreamBYOBRequest)
NS_IMPL_CYCLE_COLLECTING_RELEASE(ReadableStreamBYOBRequest)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ReadableStreamBYOBRequest)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mView)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ReadableStreamBYOBRequest)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)

View File

@ -12,40 +12,21 @@
#include "mozilla/dom/ReadableStreamTee.h"
#include "mozilla/dom/Promise.h"
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(TeeState)
using ::ImplCycleCollectionUnlink;
NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS(TeeState,
(mStream, mReader, mBranch1, mBranch2,
mCancelPromise, mPullAlgorithm),
(mReason1, mReason2))
NS_IMPL_CYCLE_COLLECTING_ADDREF(TeeState)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TeeState)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TeeState)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TeeState)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBranch1)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBranch2)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCancelPromise)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPullAlgorithm)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(TeeState)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mReader)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBranch1)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mBranch2)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCancelPromise)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPullAlgorithm)
tmp->mReason1.setNull();
tmp->mReason2.setNull();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(TeeState)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mReason1)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mReason2)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
TeeState::TeeState(JSContext* aCx, ReadableStream* aStream,
bool aCloneForBranch2)
: mStream(aStream),

View File

@ -9,20 +9,8 @@
using namespace mozilla::dom;
// UnderlyingSinkStartCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(UnderlyingSinkStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(UnderlyingSinkStartCallbackHelper)
tmp->mUnderlyingSink = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(UnderlyingSinkStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSinkStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mUnderlyingSink)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS(UnderlyingSinkStartCallbackHelper,
(mCallback), (mUnderlyingSink))
NS_IMPL_CYCLE_COLLECTING_ADDREF(UnderlyingSinkStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTING_RELEASE(UnderlyingSinkStartCallbackHelper)
@ -42,20 +30,8 @@ void UnderlyingSinkStartCallbackHelper::StartCallback(
}
// UnderlyingSinkWriteCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(UnderlyingSinkWriteCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(UnderlyingSinkWriteCallbackHelper)
tmp->mUnderlyingSink = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(UnderlyingSinkWriteCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSinkWriteCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mUnderlyingSink)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS(UnderlyingSinkWriteCallbackHelper,
(mCallback), (mUnderlyingSink))
NS_IMPL_CYCLE_COLLECTING_ADDREF(UnderlyingSinkWriteCallbackHelper)
NS_IMPL_CYCLE_COLLECTING_RELEASE(UnderlyingSinkWriteCallbackHelper)
@ -76,20 +52,8 @@ already_AddRefed<Promise> UnderlyingSinkWriteCallbackHelper::WriteCallback(
}
// UnderlyingSinkCloseCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(UnderlyingSinkCloseCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(UnderlyingSinkCloseCallbackHelper)
tmp->mUnderlyingSink = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(UnderlyingSinkCloseCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSinkCloseCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mUnderlyingSink)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS(UnderlyingSinkCloseCallbackHelper,
(mCallback), (mUnderlyingSink))
NS_IMPL_CYCLE_COLLECTING_ADDREF(UnderlyingSinkCloseCallbackHelper)
NS_IMPL_CYCLE_COLLECTING_RELEASE(UnderlyingSinkCloseCallbackHelper)
@ -109,20 +73,8 @@ already_AddRefed<Promise> UnderlyingSinkCloseCallbackHelper::CloseCallback(
}
// UnderlyingSinkAbortCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(UnderlyingSinkAbortCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(UnderlyingSinkAbortCallbackHelper)
tmp->mUnderlyingSink = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(UnderlyingSinkAbortCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSinkAbortCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mUnderlyingSink)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS(UnderlyingSinkAbortCallbackHelper,
(mCallback), (mUnderlyingSink))
NS_IMPL_CYCLE_COLLECTING_ADDREF(UnderlyingSinkAbortCallbackHelper)
NS_IMPL_CYCLE_COLLECTING_RELEASE(UnderlyingSinkAbortCallbackHelper)

View File

@ -12,20 +12,8 @@
namespace mozilla::dom {
// UnderlyingSourceStartCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(UnderlyingSourceStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(UnderlyingSourceStartCallbackHelper)
tmp->mThisObj.set(nullptr);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(UnderlyingSourceStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSourceStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mThisObj)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WITH_JS_MEMBERS(UnderlyingSourceStartCallbackHelper,
(mCallback), (mThisObj))
NS_IMPL_CYCLE_COLLECTING_ADDREF(UnderlyingSourceStartCallbackHelper)
NS_IMPL_CYCLE_COLLECTING_RELEASE(UnderlyingSourceStartCallbackHelper)
@ -46,23 +34,9 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSourcePullCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
// IDLUnderlyingSourcePullCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(IDLUnderlyingSourcePullCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
IDLUnderlyingSourcePullCallbackHelper, UnderlyingSourcePullCallbackHelper)
tmp->mThisObj.set(nullptr);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
IDLUnderlyingSourcePullCallbackHelper, UnderlyingSourcePullCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(
IDLUnderlyingSourcePullCallbackHelper, UnderlyingSourcePullCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mThisObj)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_INHERITED_WITH_JS_MEMBERS(
IDLUnderlyingSourcePullCallbackHelper, UnderlyingSourcePullCallbackHelper,
(mCallback), (mThisObj))
NS_IMPL_ADDREF_INHERITED(IDLUnderlyingSourcePullCallbackHelper,
UnderlyingSourcePullCallbackHelper)
@ -97,26 +71,9 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(UnderlyingSourceCancelCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
// IDLUnderlyingSourceCancelCallbackHelper
NS_IMPL_CYCLE_COLLECTION_CLASS(IDLUnderlyingSourceCancelCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(
NS_IMPL_CYCLE_COLLECTION_INHERITED_WITH_JS_MEMBERS(
IDLUnderlyingSourceCancelCallbackHelper,
UnderlyingSourceCancelCallbackHelper)
tmp->mThisObj.set(nullptr);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(
IDLUnderlyingSourceCancelCallbackHelper,
UnderlyingSourceCancelCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(
IDLUnderlyingSourceCancelCallbackHelper,
UnderlyingSourceCancelCallbackHelper)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mThisObj)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
UnderlyingSourceCancelCallbackHelper, (mCallback), (mThisObj))
NS_IMPL_ADDREF_INHERITED(IDLUnderlyingSourceCancelCallbackHelper,
UnderlyingSourceCancelCallbackHelper)

View File

@ -35,27 +35,12 @@
namespace mozilla::dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(WritableStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WritableStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal, mCloseRequest, mController,
mInFlightWriteRequest, mInFlightCloseRequest,
mPendingAbortRequestPromise, mWriter,
mWriteRequests)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->mPendingAbortRequestReason.setNull();
tmp->mStoredError.setNull();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WritableStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(
mGlobal, mCloseRequest, mController, mInFlightWriteRequest,
mInFlightCloseRequest, mWriter, mWriteRequests)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(WritableStream)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mPendingAbortRequestReason)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mStoredError)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WITH_JS_MEMBERS(
WritableStream,
(mGlobal, mCloseRequest, mController, mInFlightWriteRequest,
mInFlightCloseRequest, mPendingAbortRequestPromise, mWriter,
mWriteRequests),
(mPendingAbortRequestReason, mStoredError))
NS_IMPL_CYCLE_COLLECTING_ADDREF(WritableStream)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WritableStream)