Skip to content

Commit

Permalink
Bug 1350958 - Finish labeling ProxyReleaseEvent, r=billm
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed Jul 14, 2017
1 parent aad387a commit 50f9ea4
Show file tree
Hide file tree
Showing 43 changed files with 128 additions and 111 deletions.
6 changes: 4 additions & 2 deletions dom/base/WebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,10 @@ WebSocketImpl::Disconnect()
rv.SuppressException();
}

NS_ReleaseOnMainThread("WebSocketImpl::mChannel", mChannel.forget());
NS_ReleaseOnMainThread("WebSocketImpl::mService", mService.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketImpl::mChannel",
mChannel.forget());
NS_ReleaseOnMainThreadSystemGroup("WebSocketImpl::mService",
mService.forget());

mWebSocket->DontKeepAliveAnyMore();
mWebSocket->mImpl = nullptr;
Expand Down
16 changes: 12 additions & 4 deletions dom/base/nsDOMDataChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ nsDOMDataChannel::UpdateMustKeepAlive()
}

if (mSelfRef && !shouldKeepAlive) {
// release our self-reference (safely) by putting it in an event (always)
NS_ReleaseOnMainThread("nsDOMDataChannel::mSelfRef", mSelfRef.forget(), true);
ReleaseSelf();
} else if (!mSelfRef && shouldKeepAlive) {
mSelfRef = this;
}
Expand All @@ -590,13 +589,22 @@ nsDOMDataChannel::DontKeepAliveAnyMore()
MOZ_ASSERT(NS_IsMainThread());

if (mSelfRef) {
// Since we're on MainThread, force an eventloop trip to avoid deleting ourselves.
NS_ReleaseOnMainThread("nsDOMDataChannel::mSelfRef", mSelfRef.forget(), true);
// Since we're on MainThread, force an eventloop trip to avoid deleting
// ourselves.
ReleaseSelf();
}

mCheckMustKeepAlive = false;
}

void
nsDOMDataChannel::ReleaseSelf()
{
// release our self-reference (safely) by putting it in an event (always)
NS_ReleaseOnMainThreadSystemGroup("nsDOMDataChannel::mSelfRef",
mSelfRef.forget(), true);
}

void
nsDOMDataChannel::EventListenerAdded(nsIAtom* aType)
{
Expand Down
2 changes: 2 additions & 0 deletions dom/base/nsDOMDataChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class nsDOMDataChannel final : public mozilla::DOMEventTargetHelper,
void Send(nsIInputStream* aMsgStream, const nsACString& aMsgString,
uint32_t aMsgLength, bool aIsBinary, mozilla::ErrorResult& aRv);

void ReleaseSelf();

// to keep us alive while we have listeners
RefPtr<nsDOMDataChannel> mSelfRef;
// Owning reference
Expand Down
2 changes: 1 addition & 1 deletion dom/cache/ManagerId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"ManagerId::mPrincipal", mPrincipal.forget());
}

Expand Down
6 changes: 2 additions & 4 deletions dom/console/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,8 @@ Console::Shutdown()
}
}

NS_ReleaseOnMainThread(
"Console::mStorage", mStorage.forget());
NS_ReleaseOnMainThread(
"Console::mSandbox", mSandbox.forget());
NS_ReleaseOnMainThreadSystemGroup("Console::mStorage", mStorage.forget());
NS_ReleaseOnMainThreadSystemGroup("Console::mSandbox", mSandbox.forget());

mTimerRegistry.Clear();
mCounterRegistry.Clear();
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/GetFilesHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ GetFilesHelperParent::GetFilesHelperParent(const nsID& aUUID,

GetFilesHelperParent::~GetFilesHelperParent()
{
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"GetFilesHelperParent::mContentParent", mContentParent.forget());
}

Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaStreamGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ MediaStreamGraphImpl::RunInStableState(bool aSourceIsMSG)
// 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_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"MediaStreamGraphImpl::CurrentDriver", driver.forget(),
true); // always proxy
}
Expand Down
2 changes: 1 addition & 1 deletion dom/media/webspeech/recognition/SpeechStreamListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SpeechStreamListener::SpeechStreamListener(SpeechRecognition* aRecognition)

SpeechStreamListener::~SpeechStreamListener()
{
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"SpeechStreamListener::mRecognition", mRecognition.forget());
}

Expand Down
8 changes: 4 additions & 4 deletions dom/script/ScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,10 +1557,10 @@ ScriptLoader::ProcessOffThreadRequest(ScriptLoadRequest* aRequest)
NotifyOffThreadScriptLoadCompletedRunnable::~NotifyOffThreadScriptLoadCompletedRunnable()
{
if (MOZ_UNLIKELY(mRequest || mLoader) && !NS_IsMainThread()) {
NS_ReleaseOnMainThread(
"NotifyOffThreadScriptLoadCompletedRunnable::mRequest", mRequest.forget());
NS_ReleaseOnMainThread(
"NotifyOffThreadScriptLoadCompletedRunnable::mLoader", mLoader.forget());
NS_ReleaseOnMainThreadSystemGroup("NotifyOffThreadScriptLoadCompletedRunnable::mRequest",
mRequest.forget());
NS_ReleaseOnMainThreadSystemGroup("NotifyOffThreadScriptLoadCompletedRunnable::mLoader",
mLoader.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/ServiceWorkerJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ ServiceWorkerJob::Finish(ErrorResult& aRv)

// Async release this object to ensure that our caller methods complete
// as well.
NS_ReleaseOnMainThread("ServiceWorkerJob",
NS_ReleaseOnMainThreadSystemGroup("ServiceWorkerJob",
kungFuDeathGrip.forget(), true /* always proxy */);
}

Expand Down
2 changes: 1 addition & 1 deletion dom/workers/WorkerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4135,7 +4135,7 @@ WorkerDebugger::~WorkerDebugger()

if (!NS_IsMainThread()) {
for (size_t index = 0; index < mListeners.Length(); ++index) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"WorkerDebugger::mListeners", mListeners[index].forget());
}
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/spellcheck/src/mozPersonalDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class mozPersonalDictionaryLoader final : public mozilla::Runnable
mDict->SyncLoad();

// Release the dictionary on the main thread
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"mozPersonalDictionaryLoader::mDict",
mDict.forget().downcast<mozIPersonalDictionary>());

Expand Down Expand Up @@ -138,7 +138,7 @@ class mozPersonalDictionarySave final : public mozilla::Runnable
}

// Release the dictionary on the main thread.
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"mozPersonalDictionarySave::mDict",
mDict.forget().downcast<mozIPersonalDictionary>());

Expand Down
4 changes: 2 additions & 2 deletions gfx/thebes/gfxFontSrcPrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ gfxFontSrcPrincipal::gfxFontSrcPrincipal(nsIPrincipal* aPrincipal)

gfxFontSrcPrincipal::~gfxFontSrcPrincipal()
{
NS_ReleaseOnMainThread("gfxFontSrcPrincipal::mPrincipal",
mPrincipal.forget());
NS_ReleaseOnMainThreadSystemGroup("gfxFontSrcPrincipal::mPrincipal",
mPrincipal.forget());
}

bool
Expand Down
6 changes: 3 additions & 3 deletions gfx/thebes/gfxFontSrcURI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ gfxFontSrcURI::gfxFontSrcURI(nsIURI* aURI)
if (scheme.EqualsLiteral("data")) {
// 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_ReleaseOnMainThread
// it in our destructor anyway.)
// hold it strongly here as well. (And we'd have to
// NS_ReleaseOnMainThreadSystemGroup it in our destructor anyway.)
RefPtr<mozilla::net::nsSimpleURI> simpleURI =
mozilla::net::nsSimpleURI::From(aURI);
mSimpleURI = simpleURI;
Expand All @@ -60,7 +60,7 @@ gfxFontSrcURI::gfxFontSrcURI(nsIURI* aURI)

gfxFontSrcURI::~gfxFontSrcURI()
{
NS_ReleaseOnMainThread("gfxFontSrcURI::mURI", mURI.forget());
NS_ReleaseOnMainThreadSystemGroup("gfxFontSrcURI::mURI", mURI.forget());
}

bool
Expand Down
2 changes: 1 addition & 1 deletion image/decoders/icon/mac/nsIconChannelCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
nsIconChannel::~nsIconChannel()
{
if (mLoadInfo) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsIconChannel::mLoadInfo", mLoadInfo.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion image/decoders/icon/win/nsIconChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ nsIconChannel::nsIconChannel()
nsIconChannel::~nsIconChannel()
{
if (mLoadInfo) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsIconChannel::mLoadInfo", mLoadInfo.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion ipc/mscom/MainThreadHandoff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,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_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"MainThreadHandoff", self.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion ipc/mscom/WeakRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,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_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"WeakReferenceSupport", self.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/devtools/rootAnalysis/analyzeHeapWrites.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function ignoreContents(entry)
/mozalloc_handle_oom/,
/^NS_Log/, /log_print/, /LazyLogModule::operator/,
/SprintfLiteral/, "PR_smprintf", "PR_smprintf_free",
/NS_DispatchToMainThread/, /NS_ReleaseOnMainThread/,
/NS_DispatchToMainThread/, /NS_ReleaseOnMainThreadSystemGroup/,
/NS_NewRunnableFunction/, /NS_Atomize/,
/nsCSSValue::BufferFromString/,
/NS_strdup/,
Expand Down
3 changes: 2 additions & 1 deletion js/xpconnect/loader/ScriptPreloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,8 @@ ScriptPreloader::Run()
Unused << NS_WARN_IF(result.isErr());

mSaveComplete = true;
NS_ReleaseOnMainThread("ScriptPreloader::mSaveThread", mSaveThread.forget());
NS_ReleaseOnMainThreadSystemGroup("ScriptPreloader::mSaveThread",
mSaveThread.forget());

mal.NotifyAll();
return NS_OK;
Expand Down
9 changes: 6 additions & 3 deletions layout/style/URLExtraData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ URLExtraData::ReleaseDummy()
URLExtraData::~URLExtraData()
{
if (!NS_IsMainThread()) {
NS_ReleaseOnMainThread("URLExtraData::mBaseURI", mBaseURI.forget());
NS_ReleaseOnMainThread("URLExtraData::mReferrer", mReferrer.forget());
NS_ReleaseOnMainThread("URLExtraData::mPrincipal", mPrincipal.forget());
NS_ReleaseOnMainThreadSystemGroup("URLExtraData::mBaseURI",
mBaseURI.forget());
NS_ReleaseOnMainThreadSystemGroup("URLExtraData::mReferrer",
mReferrer.forget());
NS_ReleaseOnMainThreadSystemGroup("URLExtraData::mPrincipal",
mPrincipal.forget());
}
}

Expand Down
10 changes: 5 additions & 5 deletions layout/style/nsStyleStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3455,8 +3455,8 @@ nsStyleDisplay::~nsStyleDisplay()
// the deallocation of style structs during styling, we need to handle it
// here.
if (mSpecifiedTransform && ServoStyleSet::IsInServoTraversal()) {
// The default behavior of NS_ReleaseOnMainThread is to only proxy the
// release if we're not already on the main thread. This is a nice
// The default behavior of NS_ReleaseOnMainThreadSystemGroup is to only
// proxy the release if we're not already on the main thread. This is a nice
// optimization for the cases we happen to be doing a sequential traversal
// (i.e. a single-core machine), but it trips our assertions which check
// whether we're in a Servo traversal, parallel or not. So we
Expand All @@ -3467,7 +3467,7 @@ nsStyleDisplay::~nsStyleDisplay()
#else
false;
#endif
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsStyleDisplay::mSpecifiedTransform",
mSpecifiedTransform.forget(), alwaysProxy);
}
Expand Down Expand Up @@ -3773,7 +3773,7 @@ nsStyleContentData::~nsStyleContentData()
MOZ_COUNT_DTOR(nsStyleContentData);

if (mType == eStyleContentType_Image) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsStyleContentData::mContent.mImage", dont_AddRef(mContent.mImage));
mContent.mImage = nullptr;
} else if (mType == eStyleContentType_Counter ||
Expand Down Expand Up @@ -4365,7 +4365,7 @@ nsStyleUIReset::~nsStyleUIReset()
#else
false;
#endif
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsStyleUIReset::mSpecifiedWindowTransform",
mSpecifiedWindowTransform.forget(), alwaysProxy);
}
Expand Down
2 changes: 1 addition & 1 deletion media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,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_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"AudioProxyThread::mConduit", mConduit.forget());
MOZ_COUNT_DTOR(AudioProxyThread);
}
Expand Down
3 changes: 2 additions & 1 deletion modules/libjar/nsJARChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ nsJARChannel::nsJARChannel()

nsJARChannel::~nsJARChannel()
{
NS_ReleaseOnMainThread("nsJARChannel::mLoadInfo", mLoadInfo.forget());
NS_ReleaseOnMainThreadSystemGroup("nsJARChannel::mLoadInfo",
mLoadInfo.forget());

// release owning reference to the jar handler
nsJARProtocolHandler *handler = gJarHandler;
Expand Down
2 changes: 1 addition & 1 deletion netwerk/base/TLSServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ TLSServerConnectionInfo::~TLSServerConnectionInfo()
}

if (observer) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"TLSServerConnectionInfo::mSecurityObserver", observer.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion netwerk/base/nsBaseChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ nsBaseChannel::nsBaseChannel()

nsBaseChannel::~nsBaseChannel()
{
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsBaseChannel::mLoadInfo", mLoadInfo.forget());
}

Expand Down
10 changes: 5 additions & 5 deletions netwerk/base/nsProtocolProxyService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,22 @@ class nsAsyncResolveRequest final : public nsIRunnable
// callbacks called normally they will all be null and this is a nop

if (mChannel) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsAsyncResolveRequest::mChannel", mChannel.forget());
}

if (mCallback) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsAsyncResolveRequest::mCallback", mCallback.forget());
}

if (mProxyInfo) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsAsyncResolveRequest::mProxyInfo", mProxyInfo.forget());
}

if (mXPComPPS) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsAsyncResolveRequest::mXPComPPS", mXPComPPS.forget());
}
}
Expand Down Expand Up @@ -366,7 +366,7 @@ class AsyncGetPACURIRequest final : public nsIRunnable
~AsyncGetPACURIRequest()
{
MOZ_ASSERT(NS_IsMainThread() == mIsMainThreadOnly);
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"AsyncGetPACURIRequest::mServiceHolder", mServiceHolder.forget());
}

Expand Down
2 changes: 1 addition & 1 deletion netwerk/cache2/CacheIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ class CacheIndex : public CacheFileIOListener
}
virtual ~DiskConsumptionObserver() {
if (mObserver && !NS_IsMainThread()) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"DiskConsumptionObserver::mObserver", mObserver.forget());
}
}
Expand Down
2 changes: 1 addition & 1 deletion netwerk/protocol/gio/nsGIOProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ nsGIOInputStream::Close()
}

if (mChannel) {
NS_ReleaseOnMainThread(
NS_ReleaseOnMainThreadSystemGroup(
"nsGIOInputStream::mChannel", dont_AddRef(mChannel));

mChannel = nullptr;
Expand Down
Loading

0 comments on commit 50f9ea4

Please sign in to comment.