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
Родитель 3b813ea957
Коммит 63e21eec70
57 изменённых файлов: 175 добавлений и 231 удалений

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

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

3
dom/cache/ManagerId.cpp поставляемый
Просмотреть файл

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -33,7 +33,7 @@ gfxFontSrcURI::gfxFontSrcURI(nsIURI* aURI) {
// 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
// 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 =
mozilla::net::nsSimpleURI::From(aURI);
mSimpleURI = simpleURI;
@ -56,7 +56,7 @@ gfxFontSrcURI::gfxFontSrcURI(nsIURI* aURI) {
}
gfxFontSrcURI::~gfxFontSrcURI() {
NS_ReleaseOnMainThreadSystemGroup("gfxFontSrcURI::mURI", mURI.forget());
NS_ReleaseOnMainThread("gfxFontSrcURI::mURI", mURI.forget());
}
bool gfxFontSrcURI::Equals(gfxFontSrcURI* aOther) {

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

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

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

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

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

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

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

@ -37,7 +37,9 @@ using namespace mozilla;
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)

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

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

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

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

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

@ -579,7 +579,7 @@ mozilla::ipc::IPCResult BackgroundParentImpl::RecvPFileCreatorConstructor(
isFileRemoteType = true;
} else {
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);

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

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

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

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

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

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

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

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

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

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

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

@ -223,8 +223,7 @@ class AudioProxyThread {
// 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
// the conduit, since the runnables hold a ref to AudioProxyThread.
NS_ReleaseOnMainThreadSystemGroup("AudioProxyThread::mConduit",
mConduit.forget());
NS_ReleaseOnMainThread("AudioProxyThread::mConduit", mConduit.forget());
MOZ_COUNT_DTOR(AudioProxyThread);
}
@ -271,8 +270,7 @@ MediaPipeline::MediaPipeline(const std::string& aPc,
MediaPipeline::~MediaPipeline() {
MOZ_LOG(gMediaPipelineLog, LogLevel::Info,
("Destroying MediaPipeline: %s", mDescription.c_str()));
NS_ReleaseOnMainThreadSystemGroup("MediaPipeline::mConduit",
mConduit.forget());
NS_ReleaseOnMainThread("MediaPipeline::mConduit", mConduit.forget());
}
void MediaPipeline::Shutdown_m() {
@ -680,8 +678,7 @@ class MediaPipelineTransmit::PipelineListener
mDirectConnect(false) {}
~PipelineListener() {
NS_ReleaseOnMainThreadSystemGroup("MediaPipeline::mConduit",
mConduit.forget());
NS_ReleaseOnMainThread("MediaPipeline::mConduit", mConduit.forget());
if (mConverter) {
mConverter->Shutdown();
}
@ -1436,8 +1433,7 @@ class MediaPipelineReceiveAudio::PipelineListener
private:
~PipelineListener() {
NS_ReleaseOnMainThreadSystemGroup("MediaPipeline::mConduit",
mConduit.forget());
NS_ReleaseOnMainThread("MediaPipeline::mConduit", mConduit.forget());
}
void NotifyPullImpl(TrackTime aDesiredTime) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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