зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 22933 submitted by jonas.utterstrom@vittran.norrnod.se. r=dougt.
This commit is contained in:
Родитель
4d912e9e34
Коммит
bfc6760bd6
|
@ -22,6 +22,9 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIThread.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsString2.h"
|
||||
|
@ -72,6 +75,31 @@ nsEventQueueImpl::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventQueueImpl::InitFromPRThread(PRThread* thread)
|
||||
{
|
||||
if (thread == NS_CURRENT_THREAD)
|
||||
{
|
||||
thread = PR_GetCurrentThread();
|
||||
}
|
||||
else if (thread == NS_UI_THREAD)
|
||||
{
|
||||
nsCOMPtr<nsIThread> mainIThread;
|
||||
nsresult rv;
|
||||
|
||||
// Get the primordial thread
|
||||
rv = nsIThread::GetMainThread(getter_AddRefs(mainIThread));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mainIThread->GetPRThread(&thread);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", thread);
|
||||
NotifyObservers(gActivatedNotification);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventQueueImpl::InitFromPLQueue(PLEventQueue* aQueue)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD();
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD InitFromPRThread(PRThread* thread);
|
||||
NS_IMETHOD InitFromPLQueue(PLEventQueue* aQueue);
|
||||
|
||||
NS_IMETHOD EnterMonitor();
|
||||
|
|
|
@ -33,11 +33,9 @@ static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
|||
|
||||
// XXX move to nsID.h or nsHashtable.h? (copied from nsComponentManager.cpp)
|
||||
class ThreadKey: public nsHashKey {
|
||||
private:
|
||||
const PRThread* id;
|
||||
|
||||
|
||||
public:
|
||||
ThreadKey(const PRThread* aID) {
|
||||
ThreadKey(PRThread* aID) {
|
||||
id = aID;
|
||||
}
|
||||
|
||||
|
@ -56,6 +54,9 @@ public:
|
|||
nsHashKey *Clone(void) const {
|
||||
return new ThreadKey(id);
|
||||
}
|
||||
|
||||
PRThread* id;
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -77,7 +78,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsIEventQueue* GetEventQueue(void); // addrefs!
|
||||
nsresult MakeNewQueue(nsIEventQueue **aQueue);
|
||||
nsresult MakeNewQueue(PRThread* thread, nsIEventQueue **aQueue);
|
||||
|
||||
nsresult AddQueue(void);
|
||||
void RemoveQueue(nsIEventQueue *aQueue); // queue goes dark, and is released
|
||||
|
@ -106,7 +107,7 @@ EventQueueEntry::EventQueueEntry(nsEventQueueServiceImpl *aService, ThreadKey &a
|
|||
{
|
||||
NS_INIT_REFCNT();
|
||||
mService = aService;
|
||||
MakeNewQueue(&mQueue);
|
||||
MakeNewQueue(aKey.id, &mQueue);
|
||||
NS_ASSERTION(mQueue, "EventQueueEntry constructor failed");
|
||||
if (mService)
|
||||
mService->AddEventQueueEntry(this);
|
||||
|
@ -136,7 +137,7 @@ nsIEventQueue* EventQueueEntry::GetEventQueue(void)
|
|||
return answer;
|
||||
}
|
||||
|
||||
nsresult EventQueueEntry::MakeNewQueue(nsIEventQueue **aQueue)
|
||||
nsresult EventQueueEntry::MakeNewQueue(PRThread* thread, nsIEventQueue **aQueue)
|
||||
{
|
||||
nsIEventQueue *queue = 0;
|
||||
nsresult rv;
|
||||
|
@ -145,7 +146,7 @@ nsresult EventQueueEntry::MakeNewQueue(nsIEventQueue **aQueue)
|
|||
NS_GET_IID(nsIEventQueue), (void**) &queue);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = queue->Init();
|
||||
rv = queue->InitFromPRThread(thread);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(queue);
|
||||
queue = 0; // redundant, but makes me feel better
|
||||
|
@ -161,7 +162,7 @@ nsresult EventQueueEntry::AddQueue(void)
|
|||
nsresult rv = NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (mQueue) {
|
||||
rv = MakeNewQueue(&newQueue);
|
||||
rv = MakeNewQueue(PR_GetCurrentThread(), &newQueue);
|
||||
|
||||
// add it to our chain of queues
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -536,7 +537,6 @@ nsEventQueueServiceImpl::ResolveEventQueue(nsIEventQueue* queueOrConstant, nsIEv
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
// MAC specific. Will go away someday
|
||||
// Bwah ha ha h ha ah aha ha ha
|
||||
|
@ -566,5 +566,3 @@ NS_IMETHODIMP nsEventQueueServiceImpl::ProcessEvents()
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -68,9 +68,10 @@ public:
|
|||
NS_IMETHOD PushThreadEventQueue(nsIEventQueue **aNewQueue);
|
||||
NS_IMETHOD PopThreadEventQueue(nsIEventQueue *aQueue);
|
||||
|
||||
|
||||
#ifdef XP_MAC
|
||||
NS_IMETHOD ProcessEvents();
|
||||
#endif // XP_MAC
|
||||
#endif
|
||||
|
||||
private:
|
||||
NS_IMETHOD CreateEventQueue(PRThread *aThread);
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD() = 0;
|
||||
|
||||
NS_IMETHOD Init() = 0;
|
||||
NS_IMETHOD InitFromPRThread(PRThread* thread) = 0;
|
||||
NS_IMETHOD InitFromPLQueue(PLEventQueue* aQueue) = 0;
|
||||
|
||||
NS_IMETHOD EnterMonitor() = 0;
|
||||
|
|
|
@ -72,9 +72,9 @@ public:
|
|||
NS_IMETHOD ResolveEventQueue(nsIEventQueue* queueOrConstant, nsIEventQueue* *resultQueue) = 0;
|
||||
|
||||
#ifdef XP_MAC
|
||||
// This is ment to be temporary until something better is worked out
|
||||
NS_IMETHOD ProcessEvents() = 0;
|
||||
#endif
|
||||
NS_IMETHOD ProcessEvents() = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIEventQueueService_h___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче