Bug 1477512: Part 0 - Remove unused nsThread::mEventObservers array. r?erahm draft
authorKris Maglione <maglione.k@gmail.com>
Sat, 21 Jul 2018 13:21:12 -0700
changeset 821175 4ec9098805e2e855b2ecfe6c25f38be947ea7edd
parent 821174 03ed414139161d95ab139a5da453c56847bbd6e5
child 821176 dcd928484f504d5b783c8b9e5c512ba446391106
child 821280 2474c4c1da450770c82ed2dcfd6b10457136d49d
push id117030
push usermaglione.k@gmail.com
push dateSat, 21 Jul 2018 23:02:46 +0000
reviewerserahm
bugs1477512
milestone63.0a1
Bug 1477512: Part 0 - Remove unused nsThread::mEventObservers array. r?erahm MozReview-Commit-ID: BOhykHyIEPp
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
xpcom/threads/nsThreadManager.cpp
--- 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);
 }