Bug 1385413 - Remove thread parameter from onDispatchedEvent (r=erahm)
authorBill McCloskey <billm@mozilla.com>
Thu, 06 Jul 2017 16:05:28 -0700
changeset 371677 d7a49fecc6b9a164c145ea664015e9792f62d050
parent 371676 ecaae0733ca1dc08db7e8defe5c572f8d708d8a6
child 371678 7521180d3de0017d32bbd22f3bffe5060b45bdc4
push id93138
push userwmccloskey@mozilla.com
push dateFri, 28 Jul 2017 20:28:44 +0000
treeherdermozilla-inbound@fac66a370cf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1385413
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1385413 - Remove thread parameter from onDispatchedEvent (r=erahm) This parameter isn't used by any implementation of onDispatchedEvent, and keeping the parameter makes later refactorings in this bug more difficult. MozReview-Commit-ID: 90VY2vYtwCW
dom/indexedDB/ActorsParent.cpp
dom/storage/StorageDBThread.cpp
dom/workers/WorkerThread.cpp
ipc/glue/MessagePump.cpp
layout/style/Loader.cpp
netwerk/base/nsSocketTransportService2.cpp
netwerk/cache2/CacheIOThread.cpp
widget/android/AndroidUiThread.cpp
widget/nsBaseAppShell.cpp
widget/windows/nsAppShell.cpp
xpcom/threads/LazyIdleThread.cpp
xpcom/threads/nsIThreadInternal.idl
xpcom/threads/nsThread.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -29266,17 +29266,17 @@ PermissionRequestHelper::ActorDestroy(Ac
   mActorDestroyed = true;
 }
 
 #ifdef DEBUG
 
 NS_IMPL_ISUPPORTS(DEBUGThreadSlower, nsIThreadObserver)
 
 NS_IMETHODIMP
-DEBUGThreadSlower::OnDispatchedEvent(nsIThreadInternal* /* aThread */)
+DEBUGThreadSlower::OnDispatchedEvent()
 {
   MOZ_CRASH("Should never be called!");
 }
 
 NS_IMETHODIMP
 DEBUGThreadSlower::OnProcessNextEvent(nsIThreadInternal* /* aThread */,
                                       bool /* aMayWait */)
 {
--- a/dom/storage/StorageDBThread.cpp
+++ b/dom/storage/StorageDBThread.cpp
@@ -422,17 +422,17 @@ StorageDBThread::ThreadFunc()
     threadInternal->SetObserver(nullptr);
   }
 }
 
 
 NS_IMPL_ISUPPORTS(StorageDBThread::ThreadObserver, nsIThreadObserver)
 
 NS_IMETHODIMP
-StorageDBThread::ThreadObserver::OnDispatchedEvent(nsIThreadInternal* aThread)
+StorageDBThread::ThreadObserver::OnDispatchedEvent()
 {
   MonitorAutoLock lock(mMonitor);
   mHasPendingEvents = true;
   lock.Notify();
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/dom/workers/WorkerThread.cpp
+++ b/dom/workers/WorkerThread.cpp
@@ -308,17 +308,17 @@ WorkerThread::RecursionDepth(const Worke
   MOZ_ASSERT(PR_GetCurrentThread() == mThread);
 
   return mNestedEventLoopDepth;
 }
 
 NS_IMPL_ISUPPORTS(WorkerThread::Observer, nsIThreadObserver)
 
 NS_IMETHODIMP
-WorkerThread::Observer::OnDispatchedEvent(nsIThreadInternal* /* aThread */)
+WorkerThread::Observer::OnDispatchedEvent()
 {
   MOZ_CRASH("OnDispatchedEvent() should never be called!");
 }
 
 NS_IMETHODIMP
 WorkerThread::Observer::OnProcessNextEvent(nsIThreadInternal* /* aThread */,
                                            bool aMayWait)
 {
--- a/ipc/glue/MessagePump.cpp
+++ b/ipc/glue/MessagePump.cpp
@@ -433,17 +433,17 @@ MessagePumpForNonMainUIThreads::DoRunLoo
   }
 
   ClearInWait();
 
   ti->SetObserver(nullptr);
 }
 
 NS_IMETHODIMP
-MessagePumpForNonMainUIThreads::OnDispatchedEvent(nsIThreadInternal *thread)
+MessagePumpForNonMainUIThreads::OnDispatchedEvent()
 {
   // If our thread is sleeping in DoRunLoop's call to WaitForWork() and an
   // event posts to the nsIThread event queue - break our thread out of
   // chromium's WaitForWork.
   if (GetInWait()) {
     ScheduleWork();
   }
   return NS_OK;
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -414,17 +414,17 @@ SheetLoadData::~SheetLoadData()
 NS_IMETHODIMP
 SheetLoadData::Run()
 {
   mLoader->HandleLoadEvent(this);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SheetLoadData::OnDispatchedEvent(nsIThreadInternal* aThread)
+SheetLoadData::OnDispatchedEvent()
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SheetLoadData::OnProcessNextEvent(nsIThreadInternal* aThread,
                                   bool aMayWait)
 {
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -785,17 +785,17 @@ nsSocketTransportService::CreateUnixDoma
     if (NS_FAILED(rv))
         return rv;
 
     trans.forget(result);
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSocketTransportService::OnDispatchedEvent(nsIThreadInternal *thread)
+nsSocketTransportService::OnDispatchedEvent()
 {
 #ifndef XP_WIN
     // On windows poll can hang and this became worse when we introduced the
     // patch for bug 698882 (see also bug 1292181), therefore we reverted the
     // behavior on windows to be as before bug 698882, e.g. write to the socket
     // also if an event dispatch is on the socket thread and writing to the
     // socket for each event.
     if (OnSocketThread()) {
--- a/netwerk/cache2/CacheIOThread.cpp
+++ b/netwerk/cache2/CacheIOThread.cpp
@@ -590,17 +590,17 @@ void CacheIOThread::LoopOneLevel(uint32_
     mEventQueue[aLevel].InsertElementsAt(0, events.Elements() + index, length - index);
 }
 
 bool CacheIOThread::EventsPending(uint32_t aLastLevel)
 {
   return mLowestLevelWaiting < aLastLevel || mHasXPCOMEvents;
 }
 
-NS_IMETHODIMP CacheIOThread::OnDispatchedEvent(nsIThreadInternal *thread)
+NS_IMETHODIMP CacheIOThread::OnDispatchedEvent()
 {
   MonitorAutoLock lock(mMonitor);
   mHasXPCOMEvents = true;
   MOZ_ASSERT(mInsideLoop);
   lock.Notify();
   return NS_OK;
 }
 
--- a/widget/android/AndroidUiThread.cpp
+++ b/widget/android/AndroidUiThread.cpp
@@ -98,17 +98,17 @@ public:
 private:
   virtual ~ThreadObserver()
   {}
 };
 
 NS_IMPL_ISUPPORTS(ThreadObserver, nsIThreadObserver)
 
 NS_IMETHODIMP
-ThreadObserver::OnDispatchedEvent(nsIThreadInternal *thread)
+ThreadObserver::OnDispatchedEvent()
 {
   EnqueueTask(NS_NewRunnableFunction("PumpEvents", &PumpEvents), 0);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ThreadObserver::OnProcessNextEvent(nsIThreadInternal *thread, bool mayWait)
 {
--- a/widget/nsBaseAppShell.cpp
+++ b/widget/nsBaseAppShell.cpp
@@ -107,17 +107,17 @@ nsBaseAppShell::NativeEventCallback()
   DecrementEventloopNestingLevel();
 }
 
 // Note, this is currently overidden on windows, see comments in nsAppShell for
 // details.
 void
 nsBaseAppShell::DoProcessMoreGeckoEvents()
 {
-  OnDispatchedEvent(nullptr);
+  OnDispatchedEvent();
 }
 
 
 // Main thread via OnProcessNextEvent below
 bool
 nsBaseAppShell::DoProcessNextNativeEvent(bool mayWait)
 {
   // The next native event to be processed may trigger our NativeEventCallback,
@@ -210,17 +210,17 @@ nsBaseAppShell::GetEventloopNestingLevel
   return NS_OK;
 }
 
 //-------------------------------------------------------------------------
 // nsIThreadObserver methods:
 
 // Called from any thread
 NS_IMETHODIMP
-nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal *thr)
+nsBaseAppShell::OnDispatchedEvent()
 {
   if (mBlockNativeEvent)
     return NS_OK;
 
   if (mNativeEventPending.exchange(true))
     return NS_OK;
 
   // Returns on the main thread in NativeEventCallback above
@@ -236,17 +236,17 @@ nsBaseAppShell::OnProcessNextEvent(nsITh
     if (!mayWait)
       return NS_OK;
     // Hmm, we're in a nested native event loop and would like to get
     // back to it ASAP, but it seems a gecko event has caused us to
     // spin up a nested XPCOM event loop (eg. modal window), so we
     // really must start processing native events here again.
     mBlockNativeEvent = false;
     if (NS_HasPendingEvents(thr))
-      OnDispatchedEvent(thr); // in case we blocked it earlier
+      OnDispatchedEvent(); // in case we blocked it earlier
   }
 
   PRIntervalTime start = PR_IntervalNow();
   PRIntervalTime limit = THREAD_EVENT_STARVATION_LIMIT;
 
   // Unblock outer nested wait loop (below).
   if (mBlockedWait)
     *mBlockedWait = false;
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -310,17 +310,17 @@ nsAppShell::DoProcessMoreGeckoEvents()
 
   // To avoid, don't post native callback messages from NativeEventCallback
   // when we're in a modal loop. This gets us back into the Windows modal
   // dispatch loop dispatching input messages. Once we drop out of the modal
   // loop, we use mNativeCallbackPending to fire off a final NativeEventCallback
   // if we need it, which insures NS_ProcessPendingEvents gets called and all
   // gecko events get processed.
   if (mEventloopNestingLevel < 2) {
-    OnDispatchedEvent(nullptr);
+    OnDispatchedEvent();
     mNativeCallbackPending = false;
   } else {
     mNativeCallbackPending = true;
   }
 }
 
 void
 nsAppShell::ScheduleNativeEventCallback()
--- a/xpcom/threads/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -555,17 +555,17 @@ LazyIdleThread::Notify(nsITimer* aTimer)
 NS_IMETHODIMP
 LazyIdleThread::GetName(nsACString& aName)
 {
   aName.AssignLiteral("LazyIdleThread");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-LazyIdleThread::OnDispatchedEvent(nsIThreadInternal* /*aThread */)
+LazyIdleThread::OnDispatchedEvent()
 {
   MOZ_ASSERT(mOwningEventTarget->IsOnCurrentThread());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 LazyIdleThread::OnProcessNextEvent(nsIThreadInternal* /* aThread */,
                                    bool /* aMayWait */)
--- a/xpcom/threads/nsIThreadInternal.idl
+++ b/xpcom/threads/nsIThreadInternal.idl
@@ -66,17 +66,17 @@ interface nsIThreadInternal : nsIThread
 
 /**
  * This interface provides the observer with hooks to implement a layered
  * event queue.  For example, it is possible to overlay processing events
  * for a GUI toolkit on top of the events for a thread:
  *
  *   var NativeQueue;
  *   Observer = {
- *     onDispatchedEvent(thread) {
+ *     onDispatchedEvent() {
  *       NativeQueue.signal();
  *     }
  *     onProcessNextEvent(thread, mayWait) {
  *       if (NativeQueue.hasNextEvent())
  *         NativeQueue.processNextEvent();
  *       while (mayWait && !thread.hasPendingEvent()) {
  *         NativeQueue.wait();
  *         NativeQueue.processNextEvent();
@@ -94,21 +94,18 @@ interface nsIThreadInternal : nsIThread
  *       onDispatchedEvent.
  */
 [uuid(cc8da053-1776-44c2-9199-b5a629d0a19d)]
 interface nsIThreadObserver : nsISupports
 {
   /**
    * This method is called after an event has been dispatched to the thread.
    * This method may be called from any thread. 
-   *
-   * @param thread
-   *   The thread where the event is being dispatched.
    */
-  void onDispatchedEvent(in nsIThreadInternal thread);
+  void onDispatchedEvent();
 
   /**
    * This method is called when nsIThread::ProcessNextEvent is called.  It does
    * not guarantee that an event is actually going to be processed.  This method
    * is only called on the target thread.
    *
    * @param thread
    *   The thread being asked to process another event.
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -746,17 +746,17 @@ nsThread::PutEvent(already_AddRefed<nsIR
     // Make sure to grab the observer before dropping the lock, otherwise the
     // event that we just placed into the queue could run and eventually delete
     // this nsThread before the calling thread is scheduled again. We would then
     // crash while trying to access a dead nsThread.
     obs = mObserver;
   }
 
   if (obs) {
-    obs->OnDispatchedEvent(this);
+    obs->OnDispatchedEvent();
   }
 
   return NS_OK;
 }
 
 nsresult
 nsThread::DispatchInternal(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags,
                            nsNestedEventTarget* aTarget)