1999-05-05 03:35:47 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-05-05 03:35:47 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-05-05 03:35:47 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 06:43:54 +03:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-12-01 03:21:53 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1999-05-05 03:35:47 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "prmon.h"
|
|
|
|
#include "nsIEventQueue.h"
|
1999-10-18 18:59:57 +04:00
|
|
|
#include "nsPIEventQueueChain.h"
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
class nsEventQueueImpl : public nsIEventQueue,
|
|
|
|
public nsPIEventQueueChain
|
1999-05-05 03:35:47 +04:00
|
|
|
{
|
|
|
|
public:
|
1999-05-30 02:50:25 +04:00
|
|
|
nsEventQueueImpl();
|
|
|
|
virtual ~nsEventQueueImpl();
|
1999-05-05 03:35:47 +04:00
|
|
|
|
|
|
|
// nsISupports interface...
|
1999-05-30 02:50:25 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
1999-05-05 03:35:47 +04:00
|
|
|
|
|
|
|
// nsIEventQueue interface...
|
1999-10-18 18:59:57 +04:00
|
|
|
NS_IMETHOD_(PRStatus) PostEvent(PLEvent* aEvent);
|
|
|
|
NS_IMETHOD PostSynchronousEvent(PLEvent* aEvent, void** aResult);
|
1999-05-06 03:55:10 +04:00
|
|
|
|
1999-05-30 02:50:25 +04:00
|
|
|
NS_IMETHOD ProcessPendingEvents();
|
1999-10-18 18:59:57 +04:00
|
|
|
NS_IMETHOD EventLoop();
|
1999-05-06 03:55:10 +04:00
|
|
|
|
1999-05-30 02:50:25 +04:00
|
|
|
NS_IMETHOD EventAvailable(PRBool& aResult);
|
1999-10-18 18:59:57 +04:00
|
|
|
NS_IMETHOD GetEvent(PLEvent** aResult);
|
1999-06-04 19:02:27 +04:00
|
|
|
NS_IMETHOD HandleEvent(PLEvent* aEvent);
|
1999-11-16 19:04:14 +03:00
|
|
|
|
|
|
|
NS_IMETHOD WaitForEvent();
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-05-30 02:50:25 +04:00
|
|
|
NS_IMETHOD_(PRInt32) GetEventQueueSelectFD();
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
NS_IMETHOD Init();
|
|
|
|
NS_IMETHOD InitFromPLQueue(PLEventQueue* aQueue);
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-05-30 02:50:25 +04:00
|
|
|
NS_IMETHOD EnterMonitor();
|
|
|
|
NS_IMETHOD ExitMonitor();
|
|
|
|
|
|
|
|
NS_IMETHOD RevokeEvents(void* owner);
|
|
|
|
|
|
|
|
NS_IMETHOD GetPLEventQueue(PLEventQueue** aEventQueue);
|
1999-06-15 00:20:33 +04:00
|
|
|
|
|
|
|
NS_IMETHOD IsQueueOnCurrentThread(PRBool *aResult);
|
1999-05-30 02:50:25 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
NS_IMETHOD StopAcceptingEvents();
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
// Helpers
|
|
|
|
static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
static const nsCID& CID() { static nsCID cid = NS_EVENTQUEUE_CID; return cid; }
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
// nsPIEventQueueChain interface
|
|
|
|
NS_IMETHOD AppendQueue(nsIEventQueue *aQueue);
|
|
|
|
NS_IMETHOD Unlink();
|
|
|
|
NS_IMETHOD GetYoungest(nsIEventQueue **aQueue);
|
|
|
|
NS_IMETHOD GetYoungestActive(nsIEventQueue **aQueue);
|
|
|
|
NS_IMETHOD SetYounger(nsPIEventQueueChain *aQueue);
|
|
|
|
NS_IMETHOD SetElder(nsPIEventQueueChain *aQueue);
|
1999-05-05 03:35:47 +04:00
|
|
|
|
1999-10-18 18:59:57 +04:00
|
|
|
private:
|
|
|
|
PLEventQueue *mEventQueue;
|
|
|
|
PRBool mAcceptingEvents, // accept new events or pass them on?
|
|
|
|
mCouldHaveEvents; // accepting new ones, or still have old ones?
|
|
|
|
nsPIEventQueueChain *mYoungerQueue,
|
|
|
|
*mElderQueue;
|
|
|
|
|
|
|
|
void NotifyObservers(const char *aTopic);
|
|
|
|
|
|
|
|
void CheckForDeactivation() {
|
|
|
|
if (mCouldHaveEvents && !mAcceptingEvents && !PL_EventAvailable(mEventQueue)) {
|
|
|
|
mCouldHaveEvents = PR_FALSE;
|
|
|
|
Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
1999-05-05 03:35:47 +04:00
|
|
|
|