Bug 665579: Merge nsIThreadInternal and nsIThreadInternal2. r=bsmedberg

This commit is contained in:
Ben Turner 2011-06-24 14:12:54 -07:00
parent 8daedc7313
commit 257389646e
4 changed files with 26 additions and 41 deletions

View File

@ -104,7 +104,7 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
} }
if (!aDispatchDelayed) { if (!aDispatchDelayed) {
nsCOMPtr<nsIThreadInternal2> thread = nsCOMPtr<nsIThreadInternal> thread =
do_QueryInterface(NS_GetCurrentThread()); do_QueryInterface(NS_GetCurrentThread());
NS_ENSURE_TRUE(thread, nsnull); NS_ENSURE_TRUE(thread, nsnull);
@ -899,10 +899,7 @@ IDBTransaction::AfterProcessNextEvent(nsIThreadInternal* aThread,
} }
// No longer need to observe thread events. // No longer need to observe thread events.
nsCOMPtr<nsIThreadInternal2> thread = do_QueryInterface(aThread); if(NS_FAILED(aThread->RemoveObserver(this))) {
NS_ASSERTION(thread, "This must never fail!");
if(NS_FAILED(thread->RemoveObserver(this))) {
NS_ERROR("Failed to remove observer!"); NS_ERROR("Failed to remove observer!");
} }
} }

View File

@ -45,7 +45,7 @@ interface nsIThreadEventFilter;
* The XPCOM thread object implements this interface, which allows a consumer * The XPCOM thread object implements this interface, which allows a consumer
* to observe dispatch activity on the thread. * to observe dispatch activity on the thread.
*/ */
[scriptable, uuid(f89b5063-b06d-42f8-bf23-4dfcf2d80d6a)] [scriptable, uuid(e0d35c22-53d5-4b48-8627-93e05b94cf2c)]
interface nsIThreadInternal : nsIThread interface nsIThreadInternal : nsIThread
{ {
/** /**
@ -76,6 +76,28 @@ interface nsIThreadInternal : nsIThread
* events remaining in the queue are appended to the elder queue. * events remaining in the queue are appended to the elder queue.
*/ */
void popEventQueue(); 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);
}; };
/** /**
@ -166,32 +188,3 @@ interface nsIThreadEventFilter : nsISupports
*/ */
[notxpcom] boolean acceptEvent(in nsIRunnable event); [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);
};

View File

@ -159,7 +159,6 @@ NS_IMPL_THREADSAFE_RELEASE(nsThread)
NS_INTERFACE_MAP_BEGIN(nsThread) NS_INTERFACE_MAP_BEGIN(nsThread)
NS_INTERFACE_MAP_ENTRY(nsIThread) NS_INTERFACE_MAP_ENTRY(nsIThread)
NS_INTERFACE_MAP_ENTRY(nsIThreadInternal) NS_INTERFACE_MAP_ENTRY(nsIThreadInternal)
NS_INTERFACE_MAP_ENTRY(nsIThreadInternal2)
NS_INTERFACE_MAP_ENTRY(nsIEventTarget) NS_INTERFACE_MAP_ENTRY(nsIEventTarget)
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority) NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread)
@ -745,9 +744,6 @@ nsThread::nsChainedEventQueue::PutEvent(nsIRunnable *event)
return val; return val;
} }
//-----------------------------------------------------------------------------
// nsIThreadInternal2
NS_IMETHODIMP NS_IMETHODIMP
nsThread::GetRecursionDepth(PRUint32 *depth) nsThread::GetRecursionDepth(PRUint32 *depth)
{ {

View File

@ -48,14 +48,13 @@
#include "nsTObserverArray.h" #include "nsTObserverArray.h"
// A native thread // A native thread
class nsThread : public nsIThreadInternal2, public nsISupportsPriority class nsThread : public nsIThreadInternal, public nsISupportsPriority
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIEVENTTARGET NS_DECL_NSIEVENTTARGET
NS_DECL_NSITHREAD NS_DECL_NSITHREAD
NS_DECL_NSITHREADINTERNAL NS_DECL_NSITHREADINTERNAL
NS_DECL_NSITHREADINTERNAL2
NS_DECL_NSISUPPORTSPRIORITY NS_DECL_NSISUPPORTSPRIORITY
nsThread(); nsThread();