Bug 939182 - Add 'eventWasProcessed' argument to nsIThreadObserver::afterProcessNextEvent(), r=bsmedberg.

--HG--
extra : transplant_source : %5E%80p%D6%C6A%23%0AZ%06%23%16%155%DB%CE%F5%5CEx
This commit is contained in:
Ben Turner 2013-10-23 05:01:20 -07:00
parent 436bc9d8e6
commit 4d2b15f34c
11 changed files with 47 additions and 28 deletions

View File

@ -2724,7 +2724,8 @@ ContentParent::OnProcessNextEvent(nsIThreadInternal *thread,
/* void afterProcessNextEvent (in nsIThreadInternal thread, in unsigned long recursionDepth); */
NS_IMETHODIMP
ContentParent::AfterProcessNextEvent(nsIThreadInternal *thread,
uint32_t recursionDepth)
uint32_t recursionDepth,
bool eventWasProcessed)
{
return NS_OK;
}

View File

@ -1120,7 +1120,8 @@ nsXPConnect::OnProcessNextEvent(nsIThreadInternal *aThread, bool aMayWait,
NS_IMETHODIMP
nsXPConnect::AfterProcessNextEvent(nsIThreadInternal *aThread,
uint32_t aRecursionDepth)
uint32_t aRecursionDepth,
bool aEventWasProcessed)
{
// Watch out for unpaired events during observer registration.
if (MOZ_UNLIKELY(mEventDepth == 0))

View File

@ -449,7 +449,8 @@ SheetLoadData::OnProcessNextEvent(nsIThreadInternal* aThread,
NS_IMETHODIMP
SheetLoadData::AfterProcessNextEvent(nsIThreadInternal* aThread,
uint32_t aRecursionDepth)
uint32_t aRecursionDepth,
bool aEventWasProcessed)
{
// We want to fire our load even before or after event processing,
// whichever comes first.

View File

@ -631,7 +631,8 @@ nsSocketTransportService::OnProcessNextEvent(nsIThreadInternal *thread,
NS_IMETHODIMP
nsSocketTransportService::AfterProcessNextEvent(nsIThreadInternal* thread,
uint32_t depth)
uint32_t depth,
bool eventWasProcessed)
{
return NS_OK;
}
@ -1128,5 +1129,3 @@ nsSocketTransportService::GetSocketConnections(nsTArray<SocketInfo> *data)
for (uint32_t i = 0; i < mIdleCount; i++)
AnalyzeConnection(data, &mIdleList[i], false);
}

View File

@ -241,7 +241,8 @@ NS_IMETHODIMP CacheIOThread::OnProcessNextEvent(nsIThreadInternal *thread, bool
return NS_OK;
}
NS_IMETHODIMP CacheIOThread::AfterProcessNextEvent(nsIThreadInternal *thread, uint32_t recursionDepth)
NS_IMETHODIMP CacheIOThread::AfterProcessNextEvent(nsIThreadInternal *thread, uint32_t recursionDepth,
bool eventWasProcessed)
{
return NS_OK;
}

View File

@ -70,7 +70,8 @@ public:
NS_IMETHOD OnProcessNextEvent(nsIThreadInternal *aThread, bool aMayWait,
uint32_t aRecursionDepth);
NS_IMETHOD AfterProcessNextEvent(nsIThreadInternal *aThread,
uint32_t aRecursionDepth);
uint32_t aRecursionDepth,
bool aEventWasProcessed);
// public only to be visible to Objective-C code that must call it
void WillTerminate();

View File

@ -840,7 +840,8 @@ nsAppShell::OnProcessNextEvent(nsIThreadInternal *aThread, bool aMayWait,
// public
NS_IMETHODIMP
nsAppShell::AfterProcessNextEvent(nsIThreadInternal *aThread,
uint32_t aRecursionDepth)
uint32_t aRecursionDepth,
bool aEventWasProcessed)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -856,7 +857,8 @@ nsAppShell::AfterProcessNextEvent(nsIThreadInternal *aThread,
::CFArrayRemoveValueAtIndex(mAutoreleasePools, count - 1);
[pool release];
return nsBaseAppShell::AfterProcessNextEvent(aThread, aRecursionDepth);
return nsBaseAppShell::AfterProcessNextEvent(aThread, aRecursionDepth,
aEventWasProcessed);
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}

View File

@ -399,7 +399,8 @@ nsBaseAppShell::ScheduleSyncSection(nsIRunnable* aRunnable, bool aStable)
// Called from the main thread
NS_IMETHODIMP
nsBaseAppShell::AfterProcessNextEvent(nsIThreadInternal *thr,
uint32_t recursionDepth)
uint32_t recursionDepth,
bool eventWasProcessed)
{
// We've just finished running an event, so we're in a stable state.
RunSyncSections(true, recursionDepth);

View File

@ -501,14 +501,17 @@ LazyIdleThread::OnProcessNextEvent(nsIThreadInternal* /* aThread */,
NS_IMETHODIMP
LazyIdleThread::AfterProcessNextEvent(nsIThreadInternal* /* aThread */,
uint32_t /* aRecursionDepth */)
uint32_t /* aRecursionDepth */,
bool aEventWasProcessed)
{
bool shouldNotifyIdle;
{
MutexAutoLock lock(mMutex);
MOZ_ASSERT(mPendingEventCount, "Mismatched calls to observer methods!");
--mPendingEventCount;
if (aEventWasProcessed) {
MOZ_ASSERT(mPendingEventCount, "Mismatched calls to observer methods!");
--mPendingEventCount;
}
if (mThreadIsShuttingDown) {
// We're shutting down, no need to fire any timer.

View File

@ -6,8 +6,8 @@
#include "nsIThread.idl"
interface nsIRunnable;
interface nsIThreadObserver;
interface nsIThreadEventFilter;
/**
* The XPCOM thread object implements this interface, which allows a consumer
@ -33,11 +33,12 @@ interface nsIThreadInternal : nsIThread
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.
* Add an observer that will *only* receive onProcessNextEvent,
* beforeProcessNextEvent. 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);
@ -77,7 +78,7 @@ interface nsIThreadInternal : nsIThread
* afterProcessNextEvent, then another that inherits the first and adds
* onDispatchedEvent.
*/
[scriptable, uuid(81D0B509-F198-4417-8020-08EB4271491F)]
[scriptable, uuid(09b424c3-26b0-4128-9039-d66f85b02c63)]
interface nsIThreadObserver : nsISupports
{
/**
@ -90,8 +91,9 @@ interface nsIThreadObserver : nsISupports
void onDispatchedEvent(in nsIThreadInternal thread);
/**
* This method is called (from nsIThread::ProcessNextEvent) before an event
* is processed. This method is only called on the target thread.
* 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.
@ -107,14 +109,20 @@ interface nsIThreadObserver : nsISupports
/**
* This method is called (from nsIThread::ProcessNextEvent) after an event
* is processed. This method is only called on the target thread.
* is processed. It does not guarantee that an event was actually processed
* (depends on the value of |eventWasProcessed|. This method is only called
* on the target thread.
*
* @param thread
* The thread that processed another event.
* @param recursionDepth
* Indicates the number of calls to ProcessNextEvent on the call stack in
* addition to the current call.
* @param eventWasProcessed
* Indicates whether an event was actually processed. May be false if the
* |mayWait| flag was false when calling nsIThread::ProcessNextEvent().
*/
void afterProcessNextEvent(in nsIThreadInternal thread,
in unsigned long recursionDepth);
in unsigned long recursionDepth,
in bool eventWasProcessed);
};

View File

@ -619,13 +619,14 @@ nsThread::ProcessNextEvent(bool mayWait, bool *result)
--mRunningEvent;
NOTIFY_EVENT_OBSERVERS(AfterProcessNextEvent, (this, mRunningEvent));
NOTIFY_EVENT_OBSERVERS(AfterProcessNextEvent,
(this, mRunningEvent, *result));
if (obs)
obs->AfterProcessNextEvent(this, mRunningEvent);
obs->AfterProcessNextEvent(this, mRunningEvent, *result);
if (notifyMainThreadObserver && sMainThreadObserver)
sMainThreadObserver->AfterProcessNextEvent(this, mRunningEvent);
sMainThreadObserver->AfterProcessNextEvent(this, mRunningEvent, *result);
return rv;
}