Bug 1620594 - Part 1: Rework NS_ReleaseOnMainThreadSystemGroup. r=nika

To be able to remove SystemGroup, NS_ReleaseOnMainThreadSystemGroup
needs to have its dependency on SystemGroup removed. Since all
releases using SystemGroup would've released on the main thread anyway
we can safely replace NS_ReleaseOnMainThreadSystemGroup with
NS_ReleaseOnMainThread.

Depends on D64390

Differential Revision: https://phabricator.services.mozilla.com/D67631

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Farre 2020-04-07 15:16:23 +00:00
parent 3b813ea957
commit 63e21eec70
57 changed files with 175 additions and 231 deletions

View File

@ -467,8 +467,7 @@ void nsDOMDataChannel::DontKeepAliveAnyMore() {
void nsDOMDataChannel::ReleaseSelf() { void nsDOMDataChannel::ReleaseSelf() {
// release our self-reference (safely) by putting it in an event (always) // release our self-reference (safely) by putting it in an event (always)
NS_ReleaseOnMainThreadSystemGroup("nsDOMDataChannel::mSelfRef", NS_ReleaseOnMainThread("nsDOMDataChannel::mSelfRef", mSelfRef.forget(), true);
mSelfRef.forget(), true);
} }
void nsDOMDataChannel::EventListenerAdded(nsAtom* aType) { void nsDOMDataChannel::EventListenerAdded(nsAtom* aType) {

View File

@ -61,8 +61,7 @@ ManagerId::~ManagerId() {
// The PBackground worker thread shouldn't be running after the main thread // The PBackground worker thread shouldn't be running after the main thread
// is stopped. So main thread is guaranteed to exist here. // is stopped. So main thread is guaranteed to exist here.
NS_ReleaseOnMainThreadSystemGroup("ManagerId::mPrincipal", NS_ReleaseOnMainThread("ManagerId::mPrincipal", mPrincipal.forget());
mPrincipal.forget());
} }
} // namespace cache } // namespace cache

View File

@ -235,10 +235,10 @@ class MainThreadConsoleData final {
private: private:
~MainThreadConsoleData() { ~MainThreadConsoleData() {
NS_ReleaseOnMainThreadSystemGroup("MainThreadConsoleData::mStorage", NS_ReleaseOnMainThread("MainThreadConsoleData::mStorage",
mStorage.forget()); mStorage.forget());
NS_ReleaseOnMainThreadSystemGroup("MainThreadConsoleData::mSandbox", NS_ReleaseOnMainThread("MainThreadConsoleData::mSandbox",
mSandbox.forget()); mSandbox.forget());
} }
// All members, except for mRefCnt, are accessed only on the main thread, // All members, except for mRefCnt, are accessed only on the main thread,

View File

@ -537,8 +537,8 @@ GetFilesHelperParent::GetFilesHelperParent(const nsID& aUUID,
mUUID(aUUID) {} mUUID(aUUID) {}
GetFilesHelperParent::~GetFilesHelperParent() { GetFilesHelperParent::~GetFilesHelperParent() {
NS_ReleaseOnMainThreadSystemGroup("GetFilesHelperParent::mContentParent", NS_ReleaseOnMainThread("GetFilesHelperParent::mContentParent",
mContentParent.forget()); mContentParent.forget());
} }
/* static */ /* static */

View File

@ -267,7 +267,7 @@ already_AddRefed<Promise> DOMMediaStream::CountUnderlyingStreams(
// In case of shutdown, Run() does not run, so we dispatch mPromise to be // In case of shutdown, Run() does not run, so we dispatch mPromise to be
// released on main thread here. // released on main thread here.
void RunDuringShutdown() override { void RunDuringShutdown() override {
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"DOMMediaStream::CountUnderlyingStreams::Counter::RunDuringShutdown", "DOMMediaStream::CountUnderlyingStreams::Counter::RunDuringShutdown",
mPromise.forget()); mPromise.forget());
} }

View File

@ -21,7 +21,6 @@
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_media.h" #include "mozilla/StaticPrefs_media.h"
#include "mozilla/SystemGroup.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsINetworkLinkService.h" #include "nsINetworkLinkService.h"
@ -737,10 +736,7 @@ void MediaCache::Flush() {
AutoLock lock(self->mMonitor); AutoLock lock(self->mMonitor);
self->FlushInternal(lock); self->FlushInternal(lock);
// Ensure MediaCache is deleted on the main thread. // Ensure MediaCache is deleted on the main thread.
NS_ProxyRelease( NS_ReleaseOnMainThread("MediaCache::Flush", self.forget());
"MediaCache::Flush",
SystemGroup::EventTargetFor(mozilla::TaskCategory::Other),
self.forget());
}); });
sThread->Dispatch(r.forget()); sThread->Dispatch(r.forget());
} }
@ -759,10 +755,8 @@ void MediaCache::CloseStreamsForPrivateBrowsing() {
} }
} }
// Ensure MediaCache is deleted on the main thread. // Ensure MediaCache is deleted on the main thread.
NS_ProxyRelease( NS_ReleaseOnMainThread("MediaCache::CloseStreamsForPrivateBrowsing",
"MediaCache::CloseStreamsForPrivateBrowsing", self.forget());
SystemGroup::EventTargetFor(mozilla::TaskCategory::Other),
self.forget());
})); }));
} }
@ -1597,9 +1591,7 @@ class UpdateEvent : public Runnable {
NS_IMETHOD Run() override { NS_IMETHOD Run() override {
mMediaCache->Update(); mMediaCache->Update();
// Ensure MediaCache is deleted on the main thread. // Ensure MediaCache is deleted on the main thread.
NS_ProxyRelease("UpdateEvent::mMediaCache", NS_ReleaseOnMainThread("UpdateEvent::mMediaCache", mMediaCache.forget());
SystemGroup::EventTargetFor(mozilla::TaskCategory::Other),
mMediaCache.forget());
return NS_OK; return NS_OK;
} }

View File

@ -1753,9 +1753,9 @@ void MediaTrackGraphImpl::RunInStableState(bool aSourceIsMTG) {
// It's not safe to Shutdown() a thread from StableState, and // It's not safe to Shutdown() a thread from StableState, and
// releasing this may shutdown a SystemClockDriver thread. // releasing this may shutdown a SystemClockDriver thread.
// Proxy the release to outside of StableState. // Proxy the release to outside of StableState.
NS_ReleaseOnMainThreadSystemGroup("MediaTrackGraphImpl::CurrentDriver", NS_ReleaseOnMainThread("MediaTrackGraphImpl::CurrentDriver",
driver.forget(), driver.forget(),
true); // always proxy true); // always proxy
} }
if (LifecycleStateRef() == LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP && if (LifecycleStateRef() == LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP &&

View File

@ -2024,10 +2024,10 @@ nsresult ScriptLoader::ProcessOffThreadRequest(ScriptLoadRequest* aRequest) {
NotifyOffThreadScriptLoadCompletedRunnable:: NotifyOffThreadScriptLoadCompletedRunnable::
~NotifyOffThreadScriptLoadCompletedRunnable() { ~NotifyOffThreadScriptLoadCompletedRunnable() {
if (MOZ_UNLIKELY(mRequest || mLoader) && !NS_IsMainThread()) { if (MOZ_UNLIKELY(mRequest || mLoader) && !NS_IsMainThread()) {
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"NotifyOffThreadScriptLoadCompletedRunnable::mRequest", "NotifyOffThreadScriptLoadCompletedRunnable::mRequest",
mRequest.forget()); mRequest.forget());
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"NotifyOffThreadScriptLoadCompletedRunnable::mLoader", "NotifyOffThreadScriptLoadCompletedRunnable::mLoader",
mLoader.forget()); mLoader.forget());
} }

View File

@ -210,9 +210,8 @@ void ServiceWorkerJob::Finish(ErrorResult& aRv) {
// Async release this object to ensure that our caller methods complete // Async release this object to ensure that our caller methods complete
// as well. // as well.
NS_ReleaseOnMainThreadSystemGroup("ServiceWorkerJobProxyRunnable", NS_ReleaseOnMainThread("ServiceWorkerJobProxyRunnable",
kungFuDeathGrip.forget(), kungFuDeathGrip.forget(), true /* always proxy */);
true /* always proxy */);
} }
void ServiceWorkerJob::Finish(nsresult aRv) { void ServiceWorkerJob::Finish(nsresult aRv) {

View File

@ -579,10 +579,8 @@ void WebSocketImpl::Disconnect() {
rv.SuppressException(); rv.SuppressException();
} }
NS_ReleaseOnMainThreadSystemGroup("WebSocketImpl::mChannel", NS_ReleaseOnMainThread("WebSocketImpl::mChannel", mChannel.forget());
mChannel.forget()); NS_ReleaseOnMainThread("WebSocketImpl::mService", mService.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketImpl::mService",
mService.forget());
mWebSocket->DontKeepAliveAnyMore(); mWebSocket->DontKeepAliveAnyMore();
mWebSocket->mImpl = nullptr; mWebSocket->mImpl = nullptr;

View File

@ -179,8 +179,8 @@ WorkerDebugger::~WorkerDebugger() {
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
for (size_t index = 0; index < mListeners.Length(); ++index) { for (size_t index = 0; index < mListeners.Length(); ++index) {
NS_ReleaseOnMainThreadSystemGroup("WorkerDebugger::mListeners", NS_ReleaseOnMainThread("WorkerDebugger::mListeners",
mListeners[index].forget()); mListeners[index].forget());
} }
} }
} }

View File

@ -25,6 +25,7 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/BasePrincipal.h" #include "mozilla/BasePrincipal.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/SchedulerGroup.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "mozilla/ScopeExit.h" #include "mozilla/ScopeExit.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
@ -189,10 +190,8 @@ class ReleaseWorkerRunnable final : public WorkerRunnable {
mWeakRef = nullptr; mWeakRef = nullptr;
nsCOMPtr<nsIEventTarget> target = NS_ReleaseOnMainThread("ReleaseWorkerRunnable::mWorkerPrivate",
SystemGroup::EventTargetFor(TaskCategory::Other); mWorkerPrivate.forget());
NS_ProxyRelease("ReleaseWorkerRunnable::mWorkerPrivate", target,
mWorkerPrivate.forget());
} }
RefPtr<WorkerPrivate> mWorkerPrivate; RefPtr<WorkerPrivate> mWorkerPrivate;
@ -300,7 +299,8 @@ void RemoteWorkerChild::ExecWorker(const RemoteWorkerData& aData) {
} }
}); });
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget())); MOZ_ALWAYS_SUCCEEDS(
SchedulerGroup::Dispatch(TaskCategory::Other, r.forget()));
} }
nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) { nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
@ -698,10 +698,8 @@ RemoteWorkerChild::WorkerPrivateAccessibleState::
return; return;
} }
nsCOMPtr<nsIEventTarget> target = NS_ReleaseOnMainThread(
SystemGroup::EventTargetFor(TaskCategory::Other); "RemoteWorkerChild::WorkerPrivateAccessibleState::mWorkerPrivate",
NS_ProxyRelease(
"RemoteWorkerChild::WorkerPrivateAccessibleState::mWorkerPrivate", target,
mWorkerPrivate.forget()); mWorkerPrivate.forget());
} }
@ -726,8 +724,8 @@ RemoteWorkerChild::Running::~Running() {
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
dispatchWorkerRunnableRunnable->Run(); dispatchWorkerRunnableRunnable->Run();
} else { } else {
SystemGroup::Dispatch(TaskCategory::Other, SchedulerGroup::Dispatch(TaskCategory::Other,
dispatchWorkerRunnableRunnable.forget()); dispatchWorkerRunnableRunnable.forget());
} }
} }
@ -862,7 +860,8 @@ class RemoteWorkerChild::SharedWorkerOp : public RemoteWorkerChild::Op {
self->Exec(owner); self->Exec(owner);
}); });
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget())); MOZ_ALWAYS_SUCCEEDS(
SchedulerGroup::Dispatch(TaskCategory::Other, r.forget()));
#ifdef DEBUG #ifdef DEBUG
mStarted = true; mStarted = true;

View File

@ -109,8 +109,8 @@ void RemoteWorkerManager::RegisterActor(RemoteWorkerServiceParent* aActor) {
RefPtr<ContentParent> contentParent = RefPtr<ContentParent> contentParent =
BackgroundParent::GetContentParent(aActor->Manager()); BackgroundParent::GetContentParent(aActor->Manager());
auto scopeExit = MakeScopeExit( auto scopeExit =
[&] { NS_ReleaseOnMainThreadSystemGroup(contentParent.forget()); }); MakeScopeExit([&] { NS_ReleaseOnMainThread(contentParent.forget()); });
const auto& remoteType = contentParent->GetRemoteType(); const auto& remoteType = contentParent->GetRemoteType();
if (!mPendings.IsEmpty()) { if (!mPendings.IsEmpty()) {

View File

@ -62,11 +62,8 @@ void RemoteWorkerParent::Initialize(bool aAlreadyRegistered) {
parent->RegisterRemoteWorkerActor(); parent->RegisterRemoteWorkerActor();
} }
nsCOMPtr<nsIEventTarget> target = NS_ReleaseOnMainThread("RemoteWorkerParent::Initialize ContentParent",
SystemGroup::EventTargetFor(TaskCategory::Other); parent.forget());
NS_ProxyRelease("RemoteWorkerParent::Initialize ContentParent", target,
parent.forget());
} }
} }

View File

@ -52,11 +52,8 @@ SharedWorkerManager::SharedWorkerManager(
} }
SharedWorkerManager::~SharedWorkerManager() { SharedWorkerManager::~SharedWorkerManager() {
nsCOMPtr<nsIEventTarget> target = NS_ReleaseOnMainThread("SharedWorkerManager::mLoadingPrincipal",
SystemGroup::EventTargetFor(TaskCategory::Other); mLoadingPrincipal.forget());
NS_ProxyRelease("SharedWorkerManager::mLoadingPrincipal", target,
mLoadingPrincipal.forget());
NS_ProxyRelease("SharedWorkerManager::mRemoteWorkerController", NS_ProxyRelease("SharedWorkerManager::mRemoteWorkerController",
mPBackgroundEventTarget, mRemoteWorkerController.forget()); mPBackgroundEventTarget, mRemoteWorkerController.forget());
} }
@ -291,8 +288,8 @@ SharedWorkerManagerWrapper::SharedWorkerManagerWrapper(
} }
SharedWorkerManagerWrapper::~SharedWorkerManagerWrapper() { SharedWorkerManagerWrapper::~SharedWorkerManagerWrapper() {
NS_ReleaseOnMainThreadSystemGroup("SharedWorkerManagerWrapper::mHolder", NS_ReleaseOnMainThread("SharedWorkerManagerWrapper::mHolder",
mHolder.forget()); mHolder.forget());
} }
} // namespace dom } // namespace dom

View File

@ -61,9 +61,8 @@ class mozPersonalDictionaryLoader final : public mozilla::Runnable {
mDict->SyncLoad(); mDict->SyncLoad();
// Release the dictionary on the main thread // Release the dictionary on the main thread
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("mozPersonalDictionaryLoader::mDict",
"mozPersonalDictionaryLoader::mDict", mDict.forget().downcast<mozIPersonalDictionary>());
mDict.forget().downcast<mozIPersonalDictionary>());
return NS_OK; return NS_OK;
} }
@ -133,9 +132,8 @@ class mozPersonalDictionarySave final : public mozilla::Runnable {
} }
// Release the dictionary on the main thread. // Release the dictionary on the main thread.
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("mozPersonalDictionarySave::mDict",
"mozPersonalDictionarySave::mDict", mDict.forget().downcast<mozIPersonalDictionary>());
mDict.forget().downcast<mozIPersonalDictionary>());
return NS_OK; return NS_OK;
} }

View File

@ -234,8 +234,8 @@ void PaintThread::AsyncPaintTask(CompositorBridgeChild* aBridge,
// UnscaledFont objects, gets destroyed on the main thread (See bug // UnscaledFont objects, gets destroyed on the main thread (See bug
// 1404742). This assumes (unflushed) target DrawTargets do not themselves // 1404742). This assumes (unflushed) target DrawTargets do not themselves
// hold on to UnscaledFonts. // hold on to UnscaledFonts.
NS_ReleaseOnMainThreadSystemGroup("PaintTask::DrawTargetCapture", NS_ReleaseOnMainThread("PaintTask::DrawTargetCapture",
aTask->mCapture.forget()); aTask->mCapture.forget());
} }
if (aBridge->NotifyFinishedAsyncWorkerPaint(aTask)) { if (aBridge->NotifyFinishedAsyncWorkerPaint(aTask)) {

View File

@ -187,8 +187,8 @@ void UiCompositorControllerChild::Destroy() {
// Dispatch mWidget to main thread to prevent it from being destructed by // Dispatch mWidget to main thread to prevent it from being destructed by
// the ui thread. // the ui thread.
RefPtr<nsIWidget> widget = std::move(mWidget); RefPtr<nsIWidget> widget = std::move(mWidget);
NS_ReleaseOnMainThreadSystemGroup("UiCompositorControllerChild::mWidget", NS_ReleaseOnMainThread("UiCompositorControllerChild::mWidget",
widget.forget()); widget.forget());
} }
if (mIsOpen) { if (mIsOpen) {

View File

@ -21,8 +21,8 @@ gfxFontSrcPrincipal::gfxFontSrcPrincipal(nsIPrincipal* aPrincipal) {
} }
gfxFontSrcPrincipal::~gfxFontSrcPrincipal() { gfxFontSrcPrincipal::~gfxFontSrcPrincipal() {
NS_ReleaseOnMainThreadSystemGroup("gfxFontSrcPrincipal::mPrincipal", NS_ReleaseOnMainThread("gfxFontSrcPrincipal::mPrincipal",
mPrincipal.forget()); mPrincipal.forget());
} }
bool gfxFontSrcPrincipal::Equals(gfxFontSrcPrincipal* aOther) { bool gfxFontSrcPrincipal::Equals(gfxFontSrcPrincipal* aOther) {

View File

@ -33,7 +33,7 @@ gfxFontSrcURI::gfxFontSrcURI(nsIURI* aURI) {
// We know that nsSimpleURI::From returns us a pointer to the same object, // We know that nsSimpleURI::From returns us a pointer to the same object,
// and we hold a strong reference to the object in mURI, so no need to // and we hold a strong reference to the object in mURI, so no need to
// hold it strongly here as well. (And we'd have to // hold it strongly here as well. (And we'd have to
// NS_ReleaseOnMainThreadSystemGroup it in our destructor anyway.) // NS_ReleaseOnMainThread it in our destructor anyway.)
RefPtr<mozilla::net::nsSimpleURI> simpleURI = RefPtr<mozilla::net::nsSimpleURI> simpleURI =
mozilla::net::nsSimpleURI::From(aURI); mozilla::net::nsSimpleURI::From(aURI);
mSimpleURI = simpleURI; mSimpleURI = simpleURI;
@ -56,7 +56,7 @@ gfxFontSrcURI::gfxFontSrcURI(nsIURI* aURI) {
} }
gfxFontSrcURI::~gfxFontSrcURI() { gfxFontSrcURI::~gfxFontSrcURI() {
NS_ReleaseOnMainThreadSystemGroup("gfxFontSrcURI::mURI", mURI.forget()); NS_ReleaseOnMainThread("gfxFontSrcURI::mURI", mURI.forget());
} }
bool gfxFontSrcURI::Equals(gfxFontSrcURI* aOther) { bool gfxFontSrcURI::Equals(gfxFontSrcURI* aOther) {

View File

@ -58,8 +58,7 @@ void AnimationSurfaceProvider::DropImageReference() {
} }
// RasterImage objects need to be destroyed on the main thread. // RasterImage objects need to be destroyed on the main thread.
NS_ReleaseOnMainThreadSystemGroup("AnimationSurfaceProvider::mImage", NS_ReleaseOnMainThread("AnimationSurfaceProvider::mImage", mImage.forget());
mImage.forget());
} }
void AnimationSurfaceProvider::Reset() { void AnimationSurfaceProvider::Reset() {

View File

@ -43,7 +43,7 @@ void DecodedSurfaceProvider::DropImageReference() {
// get evicted is holding the surface cache lock, causing deadlock. // get evicted is holding the surface cache lock, causing deadlock.
RefPtr<RasterImage> image = mImage; RefPtr<RasterImage> image = mImage;
mImage = nullptr; mImage = nullptr;
NS_ReleaseOnMainThreadSystemGroup(image.forget(), /* aAlwaysProxy = */ true); NS_ReleaseOnMainThread(image.forget(), /* aAlwaysProxy = */ true);
} }
DrawableFrameRef DecodedSurfaceProvider::DrawableRef(size_t aFrame) { DrawableFrameRef DecodedSurfaceProvider::DrawableRef(size_t aFrame) {

View File

@ -85,7 +85,7 @@ Decoder::~Decoder() {
if (mImage && !NS_IsMainThread()) { if (mImage && !NS_IsMainThread()) {
// Dispatch mImage to main thread to prevent it from being destructed by the // Dispatch mImage to main thread to prevent it from being destructed by the
// decode thread. // decode thread.
NS_ReleaseOnMainThreadSystemGroup(mImage.forget()); NS_ReleaseOnMainThread(mImage.forget());
} }
} }

View File

@ -37,7 +37,9 @@ using namespace mozilla;
nsIconChannel::nsIconChannel() {} nsIconChannel::nsIconChannel() {}
nsIconChannel::~nsIconChannel() { nsIconChannel::~nsIconChannel() {
NS_ReleaseOnMainThreadSystemGroup("nsIconChannel::mLoadInfo", mLoadInfo.forget()); if (mLoadInfo) {
NS_ReleaseOnMainThread("nsIconChannel::mLoadInfo", mLoadInfo.forget());
}
} }
NS_IMPL_ISUPPORTS(nsIconChannel, nsIChannel, nsIRequest, nsIRequestObserver, nsIStreamListener) NS_IMPL_ISUPPORTS(nsIconChannel, nsIChannel, nsIRequest, nsIRequestObserver, nsIStreamListener)

View File

@ -165,11 +165,11 @@ nsIconChannel::IconSyncOpenTask::Run() {
nsIconChannel::nsIconChannel() {} nsIconChannel::nsIconChannel() {}
nsIconChannel::~nsIconChannel() { nsIconChannel::~nsIconChannel() {
NS_ReleaseOnMainThreadSystemGroup("nsIconChannel::mLoadInfo", if (mLoadInfo) {
mLoadInfo.forget()); NS_ReleaseOnMainThread("nsIconChannel::mLoadInfo", mLoadInfo.forget());
}
if (mLoadGroup) { if (mLoadGroup) {
NS_ReleaseOnMainThreadSystemGroup("nsIconChannel::mLoadGroup", NS_ReleaseOnMainThread("nsIconChannel::mLoadGroup", mLoadGroup.forget());
mLoadGroup.forget());
} }
} }

View File

@ -282,10 +282,8 @@ class ImageDecoderHelper final : public Runnable,
private: private:
~ImageDecoderHelper() { ~ImageDecoderHelper() {
NS_ReleaseOnMainThreadSystemGroup("ImageDecoderHelper::mImage", NS_ReleaseOnMainThread("ImageDecoderHelper::mImage", mImage.forget());
mImage.forget()); NS_ReleaseOnMainThread("ImageDecoderHelper::mCallback", mCallback.forget());
NS_ReleaseOnMainThreadSystemGroup("ImageDecoderHelper::mCallback",
mCallback.forget());
} }
RefPtr<image::Image> mImage; RefPtr<image::Image> mImage;

View File

@ -579,7 +579,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPFileCreatorConstructor(
isFileRemoteType = true; isFileRemoteType = true;
} else { } else {
isFileRemoteType = parent->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE); isFileRemoteType = parent->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
NS_ReleaseOnMainThreadSystemGroup("ContentParent release", parent.forget()); NS_ReleaseOnMainThread("ContentParent release", parent.forget());
} }
dom::FileCreatorParent* actor = static_cast<dom::FileCreatorParent*>(aActor); dom::FileCreatorParent* actor = static_cast<dom::FileCreatorParent*>(aActor);

View File

@ -283,7 +283,7 @@ MainThreadHandoff::Release() {
// main thread right now, so we send a reference to ourselves to the main // main thread right now, so we send a reference to ourselves to the main
// thread to be re-released there. // thread to be re-released there.
RefPtr<MainThreadHandoff> self = this; RefPtr<MainThreadHandoff> self = this;
NS_ReleaseOnMainThreadSystemGroup("MainThreadHandoff", self.forget()); NS_ReleaseOnMainThread("MainThreadHandoff", self.forget());
} }
} }
return newRefCnt; return newRefCnt;

View File

@ -153,7 +153,7 @@ WeakReferenceSupport::Release() {
// main thread right now, so we send a reference to ourselves to the main // main thread right now, so we send a reference to ourselves to the main
// thread to be re-released there. // thread to be re-released there.
RefPtr<WeakReferenceSupport> self = this; RefPtr<WeakReferenceSupport> self = this;
NS_ReleaseOnMainThreadSystemGroup("WeakReferenceSupport", self.forget()); NS_ReleaseOnMainThread("WeakReferenceSupport", self.forget());
} }
} }
return newRefCnt; return newRefCnt;

View File

@ -435,7 +435,7 @@ function ignoreContents(entry)
/mozalloc_handle_oom/, /mozalloc_handle_oom/,
/^NS_Log/, /log_print/, /LazyLogModule::operator/, /^NS_Log/, /log_print/, /LazyLogModule::operator/,
/SprintfLiteral/, "PR_smprintf", "PR_smprintf_free", /SprintfLiteral/, "PR_smprintf", "PR_smprintf_free",
/NS_DispatchToMainThread/, /NS_ReleaseOnMainThreadSystemGroup/, /NS_DispatchToMainThread/, /NS_ReleaseOnMainThread/,
/NS_NewRunnableFunction/, /NS_Atomize/, /NS_NewRunnableFunction/, /NS_Atomize/,
/nsCSSValue::BufferFromString/, /nsCSSValue::BufferFromString/,
/NS_xstrdup/, /NS_xstrdup/,

View File

@ -29,8 +29,7 @@ void URLExtraData::ReleaseDummy() { sDummy = nullptr; }
URLExtraData::~URLExtraData() { URLExtraData::~URLExtraData() {
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
NS_ReleaseOnMainThreadSystemGroup("URLExtraData::mPrincipal", NS_ReleaseOnMainThread("URLExtraData::mPrincipal", mPrincipal.forget());
mPrincipal.forget());
} }
} }

View File

@ -1020,7 +1020,7 @@ bool WebrtcVideoConduit::SetRemoteSSRCLocked(unsigned int ssrc) {
"WebrtcVideoConduit::WaitingForInitialSsrcNoMore", "WebrtcVideoConduit::WaitingForInitialSsrcNoMore",
[this, self = RefPtr<WebrtcVideoConduit>(this)]() mutable { [this, self = RefPtr<WebrtcVideoConduit>(this)]() mutable {
mWaitingForInitialSsrc = false; mWaitingForInitialSsrc = false;
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"WebrtcVideoConduit::WaitingForInitialSsrcNoMore", self.forget()); "WebrtcVideoConduit::WaitingForInitialSsrcNoMore", self.forget());
})); }));
// On the next StartReceiving() or ConfigureRecvMediaCodec, force // On the next StartReceiving() or ConfigureRecvMediaCodec, force
@ -1141,8 +1141,8 @@ void WebrtcVideoConduit::PollStats() {
for (const auto& runnable : runnables) { for (const auto& runnable : runnables) {
runnable->Run(); runnable->Run();
} }
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("WebrtcVideoConduit::UpdateStreamStatistics",
"WebrtcVideoConduit::UpdateStreamStatistics", self.forget()); self.forget());
})); }));
} }
@ -1157,8 +1157,8 @@ void WebrtcVideoConduit::UpdateVideoStatsTimer() {
receiving]() mutable { receiving]() mutable {
mSendStreamStats.SetActive(transmitting); mSendStreamStats.SetActive(transmitting);
mRecvStreamStats.SetActive(receiving); mRecvStreamStats.SetActive(receiving);
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("WebrtcVideoConduit::SetSendStreamStatsActive",
"WebrtcVideoConduit::SetSendStreamStatsActive", self.forget()); self.forget());
})); }));
bool shouldBeActive = transmitting || receiving; bool shouldBeActive = transmitting || receiving;
@ -1956,8 +1956,8 @@ MediaConduitErrorCode WebrtcVideoConduit::SendVideoFrame(
"SendStreamStatistics::FrameDeliveredToEncoder", "SendStreamStatistics::FrameDeliveredToEncoder",
[self = RefPtr<WebrtcVideoConduit>(this), this]() mutable { [self = RefPtr<WebrtcVideoConduit>(this), this]() mutable {
mSendStreamStats.FrameDeliveredToEncoder(); mSendStreamStats.FrameDeliveredToEncoder();
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("SendStreamStatistics::FrameDeliveredToEncoder",
"SendStreamStatistics::FrameDeliveredToEncoder", self.forget()); self.forget());
})); }));
return kMediaConduitNoError; return kMediaConduitNoError;
} }
@ -2031,7 +2031,7 @@ MediaConduitErrorCode WebrtcVideoConduit::ReceivedRTPPacket(const void* data,
return; return;
} }
mRtpPacketQueue.DequeueAll(this); mRtpPacketQueue.DequeueAll(this);
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"WebrtcVideoConduit::QueuedPacketsHandler", "WebrtcVideoConduit::QueuedPacketsHandler",
self.forget()); self.forget());
})); }));

View File

@ -223,8 +223,7 @@ class AudioProxyThread {
// Conduits must be released on MainThread, and we might have the last // Conduits must be released on MainThread, and we might have the last
// reference We don't need to worry about runnables still trying to access // reference We don't need to worry about runnables still trying to access
// the conduit, since the runnables hold a ref to AudioProxyThread. // the conduit, since the runnables hold a ref to AudioProxyThread.
NS_ReleaseOnMainThreadSystemGroup("AudioProxyThread::mConduit", NS_ReleaseOnMainThread("AudioProxyThread::mConduit", mConduit.forget());
mConduit.forget());
MOZ_COUNT_DTOR(AudioProxyThread); MOZ_COUNT_DTOR(AudioProxyThread);
} }
@ -271,8 +270,7 @@ MediaPipeline::MediaPipeline(const std::string& aPc,
MediaPipeline::~MediaPipeline() { MediaPipeline::~MediaPipeline() {
MOZ_LOG(gMediaPipelineLog, LogLevel::Info, MOZ_LOG(gMediaPipelineLog, LogLevel::Info,
("Destroying MediaPipeline: %s", mDescription.c_str())); ("Destroying MediaPipeline: %s", mDescription.c_str()));
NS_ReleaseOnMainThreadSystemGroup("MediaPipeline::mConduit", NS_ReleaseOnMainThread("MediaPipeline::mConduit", mConduit.forget());
mConduit.forget());
} }
void MediaPipeline::Shutdown_m() { void MediaPipeline::Shutdown_m() {
@ -680,8 +678,7 @@ class MediaPipelineTransmit::PipelineListener
mDirectConnect(false) {} mDirectConnect(false) {}
~PipelineListener() { ~PipelineListener() {
NS_ReleaseOnMainThreadSystemGroup("MediaPipeline::mConduit", NS_ReleaseOnMainThread("MediaPipeline::mConduit", mConduit.forget());
mConduit.forget());
if (mConverter) { if (mConverter) {
mConverter->Shutdown(); mConverter->Shutdown();
} }
@ -1436,8 +1433,7 @@ class MediaPipelineReceiveAudio::PipelineListener
private: private:
~PipelineListener() { ~PipelineListener() {
NS_ReleaseOnMainThreadSystemGroup("MediaPipeline::mConduit", NS_ReleaseOnMainThread("MediaPipeline::mConduit", mConduit.forget());
mConduit.forget());
} }
void NotifyPullImpl(TrackTime aDesiredTime) { void NotifyPullImpl(TrackTime aDesiredTime) {

View File

@ -470,7 +470,7 @@ void PeerConnectionMedia::AddIceCandidate(const std::string& aCandidate,
self->mStunAddrsRequest->SendQueryMDNSHostname( self->mStunAddrsRequest->SendQueryMDNSHostname(
nsCString(nsAutoCString(addr.c_str()))); nsCString(nsAutoCString(addr.c_str())));
} }
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"PeerConnectionMedia::SendQueryMDNSHostname", "PeerConnectionMedia::SendQueryMDNSHostname",
self.forget()); self.forget());
})); }));

View File

@ -184,16 +184,11 @@ nsJARChannel::~nsJARChannel() {
} }
// Proxy release the following members to main thread. // Proxy release the following members to main thread.
NS_ReleaseOnMainThreadSystemGroup("nsJARChannel::mLoadInfo", NS_ReleaseOnMainThread("nsJARChannel::mLoadInfo", mLoadInfo.forget());
mLoadInfo.forget()); NS_ReleaseOnMainThread("nsJARChannel::mCallbacks", mCallbacks.forget());
NS_ReleaseOnMainThreadSystemGroup("nsJARChannel::mCallbacks", NS_ReleaseOnMainThread("nsJARChannel::mProgressSink", mProgressSink.forget());
mCallbacks.forget()); NS_ReleaseOnMainThread("nsJARChannel::mLoadGroup", mLoadGroup.forget());
NS_ReleaseOnMainThreadSystemGroup("nsJARChannel::mProgressSink", NS_ReleaseOnMainThread("nsJARChannel::mListener", mListener.forget());
mProgressSink.forget());
NS_ReleaseOnMainThreadSystemGroup("nsJARChannel::mLoadGroup",
mLoadGroup.forget());
NS_ReleaseOnMainThreadSystemGroup("nsJARChannel::mListener",
mListener.forget());
} }
NS_IMPL_ISUPPORTS_INHERITED(nsJARChannel, nsHashPropertyBag, nsIRequest, NS_IMPL_ISUPPORTS_INHERITED(nsJARChannel, nsHashPropertyBag, nsIRequest,

View File

@ -285,8 +285,8 @@ TLSServerConnectionInfo::~TLSServerConnectionInfo() {
} }
if (observer) { if (observer) {
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("TLSServerConnectionInfo::mSecurityObserver",
"TLSServerConnectionInfo::mSecurityObserver", observer.forget()); observer.forget());
} }
} }

View File

@ -70,8 +70,7 @@ nsBaseChannel::nsBaseChannel()
} }
nsBaseChannel::~nsBaseChannel() { nsBaseChannel::~nsBaseChannel() {
NS_ReleaseOnMainThreadSystemGroup("nsBaseChannel::mLoadInfo", NS_ReleaseOnMainThread("nsBaseChannel::mLoadInfo", mLoadInfo.forget());
mLoadInfo.forget());
} }
nsresult nsBaseChannel::Redirect(nsIChannel* newChannel, uint32_t redirectFlags, nsresult nsBaseChannel::Redirect(nsIChannel* newChannel, uint32_t redirectFlags,

View File

@ -141,23 +141,23 @@ class nsAsyncResolveRequest final : public nsIRunnable,
// callbacks called normally they will all be null and this is a nop // callbacks called normally they will all be null and this is a nop
if (mChannel) { if (mChannel) {
NS_ReleaseOnMainThreadSystemGroup("nsAsyncResolveRequest::mChannel", NS_ReleaseOnMainThread("nsAsyncResolveRequest::mChannel",
mChannel.forget()); mChannel.forget());
} }
if (mCallback) { if (mCallback) {
NS_ReleaseOnMainThreadSystemGroup("nsAsyncResolveRequest::mCallback", NS_ReleaseOnMainThread("nsAsyncResolveRequest::mCallback",
mCallback.forget()); mCallback.forget());
} }
if (mProxyInfo) { if (mProxyInfo) {
NS_ReleaseOnMainThreadSystemGroup("nsAsyncResolveRequest::mProxyInfo", NS_ReleaseOnMainThread("nsAsyncResolveRequest::mProxyInfo",
mProxyInfo.forget()); mProxyInfo.forget());
} }
if (mXPComPPS) { if (mXPComPPS) {
NS_ReleaseOnMainThreadSystemGroup("nsAsyncResolveRequest::mXPComPPS", NS_ReleaseOnMainThread("nsAsyncResolveRequest::mXPComPPS",
mXPComPPS.forget()); mXPComPPS.forget());
} }
} }
} }
@ -655,8 +655,8 @@ class AsyncGetPACURIRequest final : public nsIRunnable {
private: private:
~AsyncGetPACURIRequest() { ~AsyncGetPACURIRequest() {
NS_ReleaseOnMainThreadSystemGroup("AsyncGetPACURIRequest::mServiceHolder", NS_ReleaseOnMainThread("AsyncGetPACURIRequest::mServiceHolder",
mServiceHolder.forget()); mServiceHolder.forget());
} }
bool mIsMainThreadOnly; bool mIsMainThreadOnly;

View File

@ -1231,8 +1231,8 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable {
mSize(0) {} mSize(0) {}
virtual ~DiskConsumptionObserver() { virtual ~DiskConsumptionObserver() {
if (mObserver && !NS_IsMainThread()) { if (mObserver && !NS_IsMainThread()) {
NS_ReleaseOnMainThreadSystemGroup("DiskConsumptionObserver::mObserver", NS_ReleaseOnMainThread("DiskConsumptionObserver::mObserver",
mObserver.forget()); mObserver.forget());
} }
} }

View File

@ -580,8 +580,7 @@ nsGIOInputStream::Close() {
} }
if (mChannel) { if (mChannel) {
NS_ReleaseOnMainThreadSystemGroup("nsGIOInputStream::mChannel", NS_ReleaseOnMainThread("nsGIOInputStream::mChannel", dont_AddRef(mChannel));
dont_AddRef(mChannel));
mChannel = nullptr; mChannel = nullptr;
} }

View File

@ -93,12 +93,11 @@ ClassifierDummyChannel::ClassifierDummyChannel(nsIURI* aURI,
} }
ClassifierDummyChannel::~ClassifierDummyChannel() { ClassifierDummyChannel::~ClassifierDummyChannel() {
NS_ReleaseOnMainThreadSystemGroup("ClassifierDummyChannel::mLoadInfo", NS_ReleaseOnMainThread("ClassifierDummyChannel::mLoadInfo",
mLoadInfo.forget()); mLoadInfo.forget());
NS_ReleaseOnMainThreadSystemGroup("ClassifierDummyChannel::mURI", NS_ReleaseOnMainThread("ClassifierDummyChannel::mURI", mURI.forget());
mURI.forget()); NS_ReleaseOnMainThread("ClassifierDummyChannel::mTopWindowURI",
NS_ReleaseOnMainThreadSystemGroup("ClassifierDummyChannel::mTopWindowURI", mTopWindowURI.forget());
mTopWindowURI.forget());
} }
void ClassifierDummyChannel::AddClassificationFlags( void ClassifierDummyChannel::AddClassificationFlags(

View File

@ -590,8 +590,8 @@ class nsCompleteUpgradeData : public ARefBase {
private: private:
virtual ~nsCompleteUpgradeData() { virtual ~nsCompleteUpgradeData() {
NS_ReleaseOnMainThreadSystemGroup("nsCompleteUpgradeData.mUpgradeListener", NS_ReleaseOnMainThread("nsCompleteUpgradeData.mUpgradeListener",
mUpgradeListener.forget()); mUpgradeListener.forget());
} }
}; };

View File

@ -355,10 +355,10 @@ BaseWebSocketChannel::ListenerAndContextContainer::
~ListenerAndContextContainer() { ~ListenerAndContextContainer() {
MOZ_ASSERT(mListener); MOZ_ASSERT(mListener);
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"BaseWebSocketChannel::ListenerAndContextContainer::mListener", "BaseWebSocketChannel::ListenerAndContextContainer::mListener",
mListener.forget()); mListener.forget());
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread(
"BaseWebSocketChannel::ListenerAndContextContainer::mContext", "BaseWebSocketChannel::ListenerAndContextContainer::mContext",
mContext.forget()); mContext.forget());
} }

View File

@ -1164,12 +1164,9 @@ WebSocketChannel::~WebSocketChannel() {
mListenerMT = nullptr; mListenerMT = nullptr;
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mLoadGroup", NS_ReleaseOnMainThread("WebSocketChannel::mLoadGroup", mLoadGroup.forget());
mLoadGroup.forget()); NS_ReleaseOnMainThread("WebSocketChannel::mLoadInfo", mLoadInfo.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mLoadInfo", NS_ReleaseOnMainThread("WebSocketChannel::mService", mService.forget());
mLoadInfo.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mService",
mService.forget());
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -2252,14 +2249,11 @@ void WebSocketChannel::DoStopSession(nsresult reason) {
if (!mOpenedHttpChannel) { if (!mOpenedHttpChannel) {
// The HTTP channel information will never be used in this case // The HTTP channel information will never be used in this case
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mChannel", NS_ReleaseOnMainThread("WebSocketChannel::mChannel", mChannel.forget());
mChannel.forget()); NS_ReleaseOnMainThread("WebSocketChannel::mHttpChannel",
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mHttpChannel", mHttpChannel.forget());
mHttpChannel.forget()); NS_ReleaseOnMainThread("WebSocketChannel::mLoadGroup", mLoadGroup.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mLoadGroup", NS_ReleaseOnMainThread("WebSocketChannel::mCallbacks", mCallbacks.forget());
mLoadGroup.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketChannel::mCallbacks",
mCallbacks.forget());
} }
if (mCloseTimer) { if (mCloseTimer) {

View File

@ -2851,8 +2851,7 @@ void DataChannelConnection::ReadBlob(
// Bug 966602: Doesn't return an error to the caller via onerror. // Bug 966602: Doesn't return an error to the caller via onerror.
// We must release DataChannelConnection on MainThread to avoid issues (bug // We must release DataChannelConnection on MainThread to avoid issues (bug
// 876167) aThis is now owned by the runnable; release it there // 876167) aThis is now owned by the runnable; release it there
NS_ReleaseOnMainThreadSystemGroup("DataChannelBlobSendRunnable", NS_ReleaseOnMainThread("DataChannelBlobSendRunnable", runnable.forget());
runnable.forget());
return; return;
} }
aBlob->Close(); aBlob->Close();

View File

@ -115,9 +115,7 @@ nsresult URIData::Create(nsIURI* aURI, nsIURI* aInnermostURI,
URIData::URIData() { MOZ_ASSERT(NS_IsMainThread()); } URIData::URIData() { MOZ_ASSERT(NS_IsMainThread()); }
URIData::~URIData() { URIData::~URIData() { NS_ReleaseOnMainThread("URIData:mURI", mURI.forget()); }
NS_ReleaseOnMainThreadSystemGroup("URIData:mURI", mURI.forget());
}
bool URIData::IsEqual(nsIURI* aURI) const { bool URIData::IsEqual(nsIURI* aURI) const {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
@ -297,7 +295,7 @@ class FeatureData {
FeatureData::FeatureData() : mState(eUnclassified) {} FeatureData::FeatureData() : mState(eUnclassified) {}
FeatureData::~FeatureData() { FeatureData::~FeatureData() {
NS_ReleaseOnMainThreadSystemGroup("FeatureData:mFeature", mFeature.forget()); NS_ReleaseOnMainThread("FeatureData:mFeature", mFeature.forget());
} }
nsresult FeatureData::Initialize(FeatureTask* aTask, nsIChannel* aChannel, nsresult FeatureData::Initialize(FeatureTask* aTask, nsIChannel* aChannel,
@ -584,9 +582,9 @@ FeatureTask::FeatureTask(nsIChannel* aChannel,
} }
FeatureTask::~FeatureTask() { FeatureTask::~FeatureTask() {
NS_ReleaseOnMainThreadSystemGroup("FeatureTask::mChannel", mChannel.forget()); NS_ReleaseOnMainThread("FeatureTask::mChannel", mChannel.forget());
NS_ReleaseOnMainThreadSystemGroup("FeatureTask::mCallbackHolder", NS_ReleaseOnMainThread("FeatureTask::mCallbackHolder",
mCallbackHolder.forget()); mCallbackHolder.forget());
} }
nsresult FeatureTask::GetOrCreateURIData( nsresult FeatureTask::GetOrCreateURIData(

View File

@ -351,10 +351,10 @@ class AsyncCloseConnection final : public Runnable {
} }
~AsyncCloseConnection() override { ~AsyncCloseConnection() override {
NS_ReleaseOnMainThreadSystemGroup("AsyncCloseConnection::mConnection", NS_ReleaseOnMainThread("AsyncCloseConnection::mConnection",
mConnection.forget()); mConnection.forget());
NS_ReleaseOnMainThreadSystemGroup("AsyncCloseConnection::mCallbackEvent", NS_ReleaseOnMainThread("AsyncCloseConnection::mCallbackEvent",
mCallbackEvent.forget()); mCallbackEvent.forget());
} }
private: private:

View File

@ -474,16 +474,15 @@ class AsyncInitDatabase final : public Runnable {
} }
~AsyncInitDatabase() { ~AsyncInitDatabase() {
NS_ReleaseOnMainThreadSystemGroup("AsyncInitDatabase::mStorageFile", NS_ReleaseOnMainThread("AsyncInitDatabase::mStorageFile",
mStorageFile.forget()); mStorageFile.forget());
NS_ReleaseOnMainThreadSystemGroup("AsyncInitDatabase::mConnection", NS_ReleaseOnMainThread("AsyncInitDatabase::mConnection",
mConnection.forget()); mConnection.forget());
// Generally, the callback will be released by CallbackComplete. // Generally, the callback will be released by CallbackComplete.
// However, if for some reason Run() is not executed, we still // However, if for some reason Run() is not executed, we still
// need to ensure that it is released here. // need to ensure that it is released here.
NS_ReleaseOnMainThreadSystemGroup("AsyncInitDatabase::mCallback", NS_ReleaseOnMainThread("AsyncInitDatabase::mCallback", mCallback.forget());
mCallback.forget());
} }
RefPtr<Connection> mConnection; RefPtr<Connection> mConnection;

View File

@ -42,8 +42,8 @@ class StatementData {
// We need to ensure that mParamsArray is released on the main thread, // We need to ensure that mParamsArray is released on the main thread,
// as the binding arguments may be XPConnect values, which are safe // as the binding arguments may be XPConnect values, which are safe
// to release only on the main thread. // to release only on the main thread.
NS_ReleaseOnMainThreadSystemGroup("StatementData::mParamsArray", NS_ReleaseOnMainThread("StatementData::mParamsArray",
mParamsArray.forget()); mParamsArray.forget());
} }
/** /**

View File

@ -1039,8 +1039,8 @@ NS_IMPL_ISUPPORTS(ChannelWrapper::RequestListener, nsIStreamListener,
nsIRequestObserver, nsIThreadRetargetableStreamListener) nsIRequestObserver, nsIThreadRetargetableStreamListener)
ChannelWrapper::RequestListener::~RequestListener() { ChannelWrapper::RequestListener::~RequestListener() {
NS_ReleaseOnMainThreadSystemGroup("RequestListener::mChannelWrapper", NS_ReleaseOnMainThread("RequestListener::mChannelWrapper",
mChannelWrapper.forget()); mChannelWrapper.forget());
} }
nsresult ChannelWrapper::RequestListener::Init() { nsresult ChannelWrapper::RequestListener::Init() {

View File

@ -101,14 +101,11 @@ StreamFilterParent::StreamFilterParent()
mState(State::Uninitialized) {} mState(State::Uninitialized) {}
StreamFilterParent::~StreamFilterParent() { StreamFilterParent::~StreamFilterParent() {
NS_ReleaseOnMainThreadSystemGroup("StreamFilterParent::mChannel", NS_ReleaseOnMainThread("StreamFilterParent::mChannel", mChannel.forget());
mChannel.forget()); NS_ReleaseOnMainThread("StreamFilterParent::mLoadGroup", mLoadGroup.forget());
NS_ReleaseOnMainThreadSystemGroup("StreamFilterParent::mLoadGroup", NS_ReleaseOnMainThread("StreamFilterParent::mOrigListener",
mLoadGroup.forget()); mOrigListener.forget());
NS_ReleaseOnMainThreadSystemGroup("StreamFilterParent::mOrigListener", NS_ReleaseOnMainThread("StreamFilterParent::mContext", mContext.forget());
mOrigListener.forget());
NS_ReleaseOnMainThreadSystemGroup("StreamFilterParent::mContext",
mContext.forget());
} }
bool StreamFilterParent::Create(dom::ContentParent* aContentParent, bool StreamFilterParent::Create(dom::ContentParent* aContentParent,

View File

@ -557,8 +557,8 @@ class AbstractDoEvent : public Runnable {
// Last ditch attempt to release on the main thread - some of // Last ditch attempt to release on the main thread - some of
// the members of event are not thread-safe, so letting the // the members of event are not thread-safe, so letting the
// pointer go out of scope would cause a crash. // pointer go out of scope would cause a crash.
NS_ReleaseOnMainThreadSystemGroup("AbstractDoEvent::OSFileErrorEvent", NS_ReleaseOnMainThread("AbstractDoEvent::OSFileErrorEvent",
event.forget()); event.forget());
} }
} }
@ -574,8 +574,7 @@ class AbstractDoEvent : public Runnable {
// Last ditch attempt to release on the main thread - some of // Last ditch attempt to release on the main thread - some of
// the members of event are not thread-safe, so letting the // the members of event are not thread-safe, so letting the
// pointer go out of scope would cause a crash. // pointer go out of scope would cause a crash.
NS_ReleaseOnMainThreadSystemGroup("AbstractDoEvent::SuccessEvent", NS_ReleaseOnMainThread("AbstractDoEvent::SuccessEvent", event.forget());
event.forget());
} }
} }
@ -763,8 +762,8 @@ class DoReadToTypedArrayEvent final : public AbstractReadEvent {
if (!mResult) { if (!mResult) {
return; return;
} }
NS_ReleaseOnMainThreadSystemGroup("DoReadToTypedArrayEvent::mResult", NS_ReleaseOnMainThread("DoReadToTypedArrayEvent::mResult",
mResult.forget()); mResult.forget());
} }
protected: protected:
@ -801,8 +800,7 @@ class DoReadToStringEvent final : public AbstractReadEvent {
if (!mResult) { if (!mResult) {
return; return;
} }
NS_ReleaseOnMainThreadSystemGroup("DoReadToStringEvent::mResult", NS_ReleaseOnMainThread("DoReadToStringEvent::mResult", mResult.forget());
mResult.forget());
} }
protected: protected:
@ -910,8 +908,7 @@ class DoWriteAtomicEvent : public AbstractDoEvent {
if (!mResult) { if (!mResult) {
return; return;
} }
NS_ReleaseOnMainThreadSystemGroup("DoWriteAtomicEvent::mResult", NS_ReleaseOnMainThread("DoWriteAtomicEvent::mResult", mResult.forget());
mResult.forget());
} }
NS_IMETHODIMP Run() override { NS_IMETHODIMP Run() override {

View File

@ -229,11 +229,11 @@ class nsUrlClassifierDBService::FeatureHolder final {
~FeatureHolder() { ~FeatureHolder() {
for (FeatureData& featureData : mFeatureData) { for (FeatureData& featureData : mFeatureData) {
NS_ReleaseOnMainThreadSystemGroup("FeatureHolder:mFeatureData", NS_ReleaseOnMainThread("FeatureHolder:mFeatureData",
featureData.mFeature.forget()); featureData.mFeature.forget());
} }
NS_ReleaseOnMainThreadSystemGroup("FeatureHolder:mURI", mURI.forget()); NS_ReleaseOnMainThread("FeatureHolder:mURI", mURI.forget());
} }
TableData* GetOrCreateTableData(const nsACString& aTable) { TableData* GetOrCreateTableData(const nsACString& aTable) {
@ -1187,8 +1187,8 @@ NS_IMPL_ISUPPORTS(nsUrlClassifierLookupCallback, nsIUrlClassifierLookupCallback,
nsUrlClassifierLookupCallback::~nsUrlClassifierLookupCallback() { nsUrlClassifierLookupCallback::~nsUrlClassifierLookupCallback() {
if (mCallback) { if (mCallback) {
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("nsUrlClassifierLookupCallback::mCallback",
"nsUrlClassifierLookupCallback::mCallback", mCallback.forget()); mCallback.forget());
} }
} }

View File

@ -114,8 +114,8 @@ void RemoveProfileFiles(nsIToolkitProfile* aProfile, bool aInBackground) {
lock->Unlock(); lock->Unlock();
// nsIProfileLock is not threadsafe so release our reference to it on // nsIProfileLock is not threadsafe so release our reference to it on
// the main thread. // the main thread.
NS_ReleaseOnMainThreadSystemGroup( NS_ReleaseOnMainThread("nsToolkitProfile::RemoveProfileFiles::Unlock",
"nsToolkitProfile::RemoveProfileFiles::Unlock", lock.forget()); lock.forget());
rv = rootDir->Remove(true); rv = rootDir->Remove(true);
NS_ENSURE_SUCCESS_VOID(rv); NS_ENSURE_SUCCESS_VOID(rv);

View File

@ -22,7 +22,7 @@ namespace mozilla {
// to create cycles that keep alive the holder. // to create cycles that keep alive the holder.
// //
// JSObjectHolder is ISupports to make it usable with // JSObjectHolder is ISupports to make it usable with
// NS_ReleaseOnMainThreadSystemGroup. // NS_ReleaseOnMainThread.
class JSObjectHolder final : public nsISupports { class JSObjectHolder final : public nsISupports {
public: public:
JSObjectHolder(JSContext* aCx, JSObject* aObject) : mJSObject(aCx, aObject) {} JSObjectHolder(JSContext* aCx, JSObject* aObject) : mJSObject(aCx, aObject) {}

View File

@ -397,8 +397,8 @@ nsresult nsConsoleService::LogMessageWithMode(
// Release |retiredMessage| on the main thread in case it is an instance of // Release |retiredMessage| on the main thread in case it is an instance of
// a mainthread-only class like nsScriptErrorWithStack and we're off the // a mainthread-only class like nsScriptErrorWithStack and we're off the
// main thread. // main thread.
NS_ReleaseOnMainThreadSystemGroup("nsConsoleService::retiredMessage", NS_ReleaseOnMainThread("nsConsoleService::retiredMessage",
retiredMessage.forget()); retiredMessage.forget());
} }
if (r) { if (r) {

View File

@ -141,41 +141,37 @@ inline NS_HIDDEN_(void)
* @param aDoomed * @param aDoomed
* the doomed object; the object to be released on the main thread. * the doomed object; the object to be released on the main thread.
* @param aAlwaysProxy * @param aAlwaysProxy
* normally, if NS_ReleaseOnMainThreadSystemGroup is called on the main * normally, if NS_ReleaseOnMainThread is called on the main
* thread, then the doomed object will be released directly. However, if * thread, then the doomed object will be released directly. However, if
* this parameter is true, then an event will always be posted to the * this parameter is true, then an event will always be posted to the
* main thread for asynchronous release. * main thread for asynchronous release.
*/ */
template <class T> template <class T>
inline NS_HIDDEN_(void) inline NS_HIDDEN_(void)
NS_ReleaseOnMainThreadSystemGroup(const char* aName, NS_ReleaseOnMainThread(const char* aName, already_AddRefed<T> aDoomed,
already_AddRefed<T> aDoomed, bool aAlwaysProxy = false) {
bool aAlwaysProxy = false) {
// NS_ProxyRelease treats a null event target as "the current thread". So a // NS_ProxyRelease treats a null event target as "the current thread". So a
// handle on the main thread is only necessary when we're not already on the // handle on the main thread is only necessary when we're not already on the
// main thread or the release must happen asynchronously. // main thread or the release must happen asynchronously.
nsCOMPtr<nsIEventTarget> systemGroupEventTarget; nsCOMPtr<nsIEventTarget> target;
if (!NS_IsMainThread() || aAlwaysProxy) { if (!NS_IsMainThread() || aAlwaysProxy) {
systemGroupEventTarget = target = mozilla::GetMainThreadSerialEventTarget();
mozilla::SystemGroup::EventTargetFor(mozilla::TaskCategory::Other);
if (!systemGroupEventTarget) { if (!target) {
MOZ_ASSERT_UNREACHABLE("Could not get main thread; leaking an object!"); MOZ_ASSERT_UNREACHABLE("Could not get main thread; leaking an object!");
mozilla::Unused << aDoomed.take(); mozilla::Unused << aDoomed.take();
return; return;
} }
} }
NS_ProxyRelease(aName, systemGroupEventTarget, std::move(aDoomed), NS_ProxyRelease(aName, target, std::move(aDoomed), aAlwaysProxy);
aAlwaysProxy);
} }
template <class T> template <class T>
inline NS_HIDDEN_(void) inline NS_HIDDEN_(void) NS_ReleaseOnMainThread(already_AddRefed<T> aDoomed,
NS_ReleaseOnMainThreadSystemGroup(already_AddRefed<T> aDoomed, bool aAlwaysProxy = false) {
bool aAlwaysProxy = false) { NS_ReleaseOnMainThread("NS_ReleaseOnMainThread", std::move(aDoomed),
NS_ReleaseOnMainThreadSystemGroup("NS_ReleaseOnMainThreadSystemGroup", aAlwaysProxy);
std::move(aDoomed), aAlwaysProxy);
} }
/** /**