Bug 1477512: Part 0 - Remove unused nsThread::mEventObservers array. r?erahm
MozReview-Commit-ID: BOhykHyIEPp
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -879,21 +879,16 @@ nsThread::ShutdownComplete(NotNull<nsThr
return;
}
// Now, it should be safe to join without fear of dead-locking.
PR_JoinThread(mThread);
mThread = nullptr;
- // We hold strong references to our event observers, and once the thread is
- // shut down the observers can't easily unregister themselves. Do it here
- // to avoid leaking.
- ClearObservers();
-
#ifdef DEBUG
nsCOMPtr<nsIThreadObserver> obs = mEvents->GetObserver();
MOZ_ASSERT(!obs, "Should have been cleared at shutdown!");
#endif
// Delete aContext.
MOZ_ALWAYS_TRUE(
aContext->mJoiningThread->mRequestedShutdownContexts.RemoveElement(aContext));
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -84,22 +84,16 @@ public:
// If this flag is true, then the nsThread was created using
// nsIThreadManager::NewThread.
bool ShutdownRequired()
{
return mShutdownRequired;
}
- // Clear the observer list.
- void ClearObservers()
- {
- mEventObservers.Clear();
- }
-
void
SetScriptObserver(mozilla::CycleCollectedJSContext* aScriptObserver);
uint32_t
RecursionDepth() const;
void ShutdownComplete(NotNull<struct nsThreadShutdownContext*> aContext);
@@ -176,19 +170,16 @@ protected:
static mozilla::OffTheBooksMutex& ThreadListMutex();
static mozilla::LinkedList<nsThread>& ThreadList();
RefPtr<mozilla::SynchronizedEventQueue> mEvents;
RefPtr<mozilla::ThreadEventTarget> mEventTarget;
mozilla::CycleCollectedJSContext* mScriptObserver;
- // Only accessed on the target thread.
- nsAutoTObserverArray<NotNull<nsCOMPtr<nsIThreadObserver>>, 2> mEventObservers;
-
int32_t mPriority;
uint32_t mThreadId;
PRThread* mThread;
uint32_t mNestedEventLoopDepth;
uint32_t mStackSize;
void* mStackBase = nullptr;
// The shutdown context for ourselves.
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -349,17 +349,16 @@ nsThreadManager::Shutdown()
OffTheBooksMutexAutoLock lock(mLock);
mThreadsByPRThread.Clear();
}
// Normally thread shutdown clears the observer for the thread, but since the
// main thread is special we do it manually here after we're sure all events
// have been processed.
mMainThread->SetObserver(nullptr);
- mMainThread->ClearObservers();
// Release main thread object.
mMainThread = nullptr;
// Remove the TLS entry for the main thread.
PR_SetThreadPrivate(mCurThreadIndex, nullptr);
}