Bug 665579: Merge nsIThreadInternal and nsIThreadInternal2. r=bsmedberg
authorBen Turner <bent.mozilla@gmail.com>
Fri, 24 Jun 2011 14:12:54 -0700
changeset 71763 94a77bde744b11a64b50895c5c34dbd7cc6c24a9
parent 71762 389e9e5cfaee35ba012f0d8090b659cee2d5a0f0
child 71764 74f776d616796e6c399ce0592bd4778f4fc48475
push id20605
push userkhuey@mozilla.com
push dateSat, 25 Jun 2011 17:13:33 +0000
treeherdermozilla-central@82b9558a9eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs665579
milestone7.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 665579: Merge nsIThreadInternal and nsIThreadInternal2. r=bsmedberg
dom/indexedDB/IDBTransaction.cpp
xpcom/threads/nsIThreadInternal.idl
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -99,17 +99,17 @@ IDBTransaction::Create(IDBDatabase* aDat
   }
 
   if (!transaction->mCachedStatements.Init()) {
     NS_ERROR("Failed to initialize hash!");
     return nsnull;
   }
 
   if (!aDispatchDelayed) {
-    nsCOMPtr<nsIThreadInternal2> thread =
+    nsCOMPtr<nsIThreadInternal> thread =
       do_QueryInterface(NS_GetCurrentThread());
     NS_ENSURE_TRUE(thread, nsnull);
 
     // We need the current recursion depth first.
     PRUint32 depth;
     nsresult rv = thread->GetRecursionDepth(&depth);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
@@ -894,20 +894,17 @@ IDBTransaction::AfterProcessNextEvent(ns
       mReadyState = nsIIDBTransaction::DONE;
 
       if (NS_FAILED(CommitOrRollback())) {
         NS_WARNING("Failed to commit!");
       }
     }
 
     // No longer need to observe thread events.
-    nsCOMPtr<nsIThreadInternal2> thread = do_QueryInterface(aThread);
-    NS_ASSERTION(thread, "This must never fail!");
-
-    if(NS_FAILED(thread->RemoveObserver(this))) {
+    if(NS_FAILED(aThread->RemoveObserver(this))) {
       NS_ERROR("Failed to remove observer!");
     }
   }
 
   return NS_OK;
 }
 
 CommitHelper::CommitHelper(IDBTransaction* aTransaction)
--- a/xpcom/threads/nsIThreadInternal.idl
+++ b/xpcom/threads/nsIThreadInternal.idl
@@ -40,17 +40,17 @@
 
 interface nsIThreadObserver;
 interface nsIThreadEventFilter;
 
 /**
  * The XPCOM thread object implements this interface, which allows a consumer
  * to observe dispatch activity on the thread.
  */
-[scriptable, uuid(f89b5063-b06d-42f8-bf23-4dfcf2d80d6a)]
+[scriptable, uuid(e0d35c22-53d5-4b48-8627-93e05b94cf2c)]
 interface nsIThreadInternal : nsIThread
 {
   /**
    * Get/set the current thread observer (may be null).  This attribute may be
    * read from any thread, but must only be set on the thread corresponding to
    * this thread object.  The observer will be released on the thread
    * corresponding to this thread object after all other events have been
    * processed during a call to Shutdown.
@@ -71,16 +71,38 @@ interface nsIThreadInternal : nsIThread
    */
   void pushEventQueue(in nsIThreadEventFilter filter);
 
   /**
    * Revert a call to PushEventQueue.  When an event queue is popped, any
    * events remaining in the queue are appended to the elder queue.
    */
   void popEventQueue();
+
+  /**
+   * The current recursion depth, 0 when no events are running, 1 when a single
+   * event is running, and higher when nested events are running. Must only be
+   * called on the target thread.
+   */
+  readonly attribute unsigned long recursionDepth;
+
+  /**
+   * Add an observer that will *only* receive onProcessNextEvent and
+   * afterProcessNextEvent callbacks. Always called on the target thread, and
+   * the implementation does not have to be threadsafe. Order of callbacks is
+   * not guaranteed (i.e. afterProcessNextEvent may be called first depending on
+   * whether or not the observer is added in a nested loop). Holds a strong ref.
+   */
+  void addObserver(in nsIThreadObserver observer);
+
+  /**
+   * Remove an observer added via the addObserver call. Once removed the
+   * observer will never be called again by the thread.
+   */
+  void removeObserver(in nsIThreadObserver observer);
 };
 
 /**
  * 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;
@@ -161,37 +183,8 @@ interface nsIThreadEventFilter : nsISupp
    *
    * @param event
    *   The event being dispatched.
    *
    * WARNING: This method must not make any calls on the thread object.
    */
   [notxpcom] boolean acceptEvent(in nsIRunnable event);
 };
-
-/**
- * Temporary interface, will be merged into nsIThreadInternal.
- */
-[scriptable, uuid(4531f101-fddc-4d36-80e7-35260a2f3afe)]
-interface nsIThreadInternal2 : nsIThreadInternal
-{
-  /**
-   * The current recursion depth, 0 when no events are running, 1 when a single
-   * event is running, and higher when nested events are running. Must only be
-   * called on the target thread.
-   */
-  readonly attribute unsigned long recursionDepth;
-
-  /**
-   * Add an observer that will *only* receive onProcessNextEvent and
-   * afterProcessNextEvent callbacks. Always called on the target thread, and
-   * the implementation does not have to be threadsafe. Order of callbacks is
-   * not guaranteed (i.e. afterProcessNextEvent may be called first depending on
-   * whether or not the observer is added in a nested loop). Holds a strong ref.
-   */
-  void addObserver(in nsIThreadObserver observer);
-
-  /**
-   * Remove an observer added via the addObserver call. Once removed the
-   * observer will never be called again by the thread.
-   */
-  void removeObserver(in nsIThreadObserver observer);
-};
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -154,17 +154,16 @@ nsThreadClassInfo::GetClassIDNoAlloc(nsC
 
 //-----------------------------------------------------------------------------
 
 NS_IMPL_THREADSAFE_ADDREF(nsThread)
 NS_IMPL_THREADSAFE_RELEASE(nsThread)
 NS_INTERFACE_MAP_BEGIN(nsThread)
   NS_INTERFACE_MAP_ENTRY(nsIThread)
   NS_INTERFACE_MAP_ENTRY(nsIThreadInternal)
-  NS_INTERFACE_MAP_ENTRY(nsIThreadInternal2)
   NS_INTERFACE_MAP_ENTRY(nsIEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread)
   if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
     foundInterface = static_cast<nsIClassInfo*>(&sThreadClassInfo);
   } else
 NS_INTERFACE_MAP_END
 NS_IMPL_CI_INTERFACE_GETTER4(nsThread, nsIThread, nsIThreadInternal,
@@ -740,19 +739,16 @@ nsThread::nsChainedEventQueue::PutEvent(
   if (!mFilter || mFilter->AcceptEvent(event)) {
     val = mQueue.PutEvent(event);
   } else {
     val = mNext->PutEvent(event);
   }
   return val;
 }
 
-//-----------------------------------------------------------------------------
-// nsIThreadInternal2
-
 NS_IMETHODIMP
 nsThread::GetRecursionDepth(PRUint32 *depth)
 {
   NS_ENSURE_ARG_POINTER(depth);
   NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
 
   *depth = mRunningEvent;
   return NS_OK;
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -43,24 +43,23 @@
 #include "nsIThreadInternal.h"
 #include "nsISupportsPriority.h"
 #include "nsEventQueue.h"
 #include "nsThreadUtils.h"
 #include "nsString.h"
 #include "nsTObserverArray.h"
 
 // A native thread
-class nsThread : public nsIThreadInternal2, public nsISupportsPriority
+class nsThread : public nsIThreadInternal, public nsISupportsPriority
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREAD
   NS_DECL_NSITHREADINTERNAL
-  NS_DECL_NSITHREADINTERNAL2
   NS_DECL_NSISUPPORTSPRIORITY
 
   nsThread();
 
   // Initialize this as a wrapper for a new PRThread.
   nsresult Init();
 
   // Initialize this as a wrapper for the current PRThread.