api change to nsIProxy* interfaces. You can no longer pass in straight PLEventQueues, you now need to pass in nsIEventQueue interfaces (see mozilla/xpcom/threads)

This commit is contained in:
valeski%netscape.com 1999-06-04 22:46:20 +00:00
Родитель aec6c9f440
Коммит e3d7ebc134
8 изменённых файлов: 60 добавлений и 58 удалений

Просмотреть файл

@ -71,8 +71,8 @@ class nsProxyObject : public nsISupports
NS_DECL_ISUPPORTS
nsProxyObject();
nsProxyObject(PLEventQueue *destQueue, ProxyType proxyType, nsISupports *realObject);
nsProxyObject(PLEventQueue *destQueue, ProxyType proxyType, const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID);
nsProxyObject(nsIEventQueue *destQueue, ProxyType proxyType, nsISupports *realObject);
nsProxyObject(nsIEventQueue *destQueue, ProxyType proxyType, const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID);
virtual ~nsProxyObject();
@ -131,14 +131,14 @@ private:
#define NS_DECL_PROXY(_class, _interface) \
public: \
_class(PLEventQueue *, _interface *); \
_class(nsIEventQueue *, _interface *); \
private: \
nsProxyObject mProxyObject;\
public:
#define NS_IMPL_PROXY(_class, _interface)\
_class::_class(PLEventQueue *eventQueue, _interface *realObject) \
_class::_class(nsIEventQueue *eventQueue, _interface *realObject) \
: mProxyObject(eventQueue, realObject) \
{\
}\

Просмотреть файл

@ -22,10 +22,10 @@
#include "nscore.h"
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIEventQueue.h"
#include "nsHashtable.h"
#include "plevent.h"
#include "xptcall.h" // defines nsXPTCVariant
#include "nsProxyEvent.h"
@ -87,13 +87,13 @@ class nsIProxyObjectManager : public nsISupports
{
public:
NS_IMETHOD GetProxyObject(PLEventQueue *destQueue,
NS_IMETHOD GetProxyObject(nsIEventQueue *destQueue,
REFNSIID aIID,
nsISupports* aObj,
ProxyType proxyType,
void** aProxyObject) = 0;
NS_IMETHOD GetProxyObject(PLEventQueue *destQueue,
NS_IMETHOD GetProxyObject(nsIEventQueue *destQueue,
const nsCID &aClass,
nsISupports *aDelegate,
const nsIID &aIID,

Просмотреть файл

@ -52,8 +52,6 @@ nsProxyObjectCallInfo::~nsProxyObjectCallInfo()
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_IMPL_ISUPPORTS(nsProxyObject, kISupportsIID)
static NS_DEFINE_IID(kIEventQIID, NS_IEVENTQUEUE_IID);
nsProxyObject::nsProxyObject()
{
NS_INIT_REFCNT();
@ -66,7 +64,7 @@ nsProxyObject::nsProxyObject()
}
nsProxyObject::nsProxyObject(PLEventQueue *destQueue, ProxyType proxyType, nsISupports *realObject)
nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, ProxyType proxyType, nsISupports *realObject)
{
NS_INIT_REFCNT();
NS_ADDREF_THIS();
@ -74,29 +72,23 @@ nsProxyObject::nsProxyObject(PLEventQueue *destQueue, ProxyType proxyType, nsISu
mRealObjectOwned = PR_FALSE;
mRealObject = realObject;
mProxyType = proxyType;
mDestQueue = destQueue;
mRealObject->AddRef();
nsresult rv = nsComponentManager::CreateInstance(NS_EVENTQUEUE_PROGID,
nsnull,
kIEventQIID,
(void **)&mDestQueue);
if (NS_SUCCEEDED(rv))
{
mDestQueue->InitFromPLQueue(destQueue);
}
NS_ADDREF(mRealObject);
NS_ADDREF(mDestQueue);
}
nsProxyObject::nsProxyObject(PLEventQueue *destQueue, ProxyType proxyType, const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID)
nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, ProxyType proxyType, const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID)
{
NS_INIT_REFCNT();
NS_ADDREF_THIS();
mRealObjectOwned = PR_TRUE;
mProxyType = proxyType;
mDestQueue = destQueue;
NS_ADDREF(mDestQueue);
nsresult rv = nsComponentManager::CreateInstance(aClass,
aDelegate,
@ -108,17 +100,6 @@ nsProxyObject::nsProxyObject(PLEventQueue *destQueue, ProxyType proxyType, const
mRealObjectOwned = PR_FALSE;
mRealObject = nsnull;
}
rv = nsComponentManager::CreateInstance(NS_EVENTQUEUE_PROGID,
nsnull,
kIEventQIID,
(void **)&mDestQueue);
if (NS_SUCCEEDED(rv))
{
mDestQueue->InitFromPLQueue(destQueue);
}
}
nsProxyObject::~nsProxyObject()
@ -130,7 +111,7 @@ nsProxyObject::~nsProxyObject()
if(mRealObject != nsnull)
{
if (!mRealObjectOwned)
mRealObject->Release();
NS_RELEASE(mRealObject);
else
NS_RELEASE(mRealObject);
}
@ -210,7 +191,7 @@ void DestroyHandler(PLEvent *self)
}
// decrement once since we increased it during the Post()
proxyObject->Release();
NS_RELEASE(proxyObject);
}
void* EventHandler(PLEvent *self)

Просмотреть файл

@ -201,9 +201,7 @@ nsProxyEventClass::CallQueryInterfaceOnProxy(nsProxyEventObject* self, REFNSIID
if (rv == NS_OK)
{
PLEventQueue* aEventQueue;
self->GetQueue()->GetPLEventQueue(&aEventQueue);
nsIEventQueue* aEventQueue = self->GetQueue();
if (aEventQueue != nsnull)
{

Просмотреть файл

@ -36,7 +36,7 @@
nsProxyEventObject*
nsProxyEventObject::GetNewOrUsedProxy(PLEventQueue *destQueue,
nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
ProxyType proxyType,
nsISupports *aObj,
REFNSIID aIID)
@ -147,7 +147,7 @@ return_wrapper:
nsProxyEventObject::nsProxyEventObject(PLEventQueue *destQueue,
nsProxyEventObject::nsProxyEventObject(nsIEventQueue *destQueue,
ProxyType proxyType,
nsISupports* aObj,
nsProxyEventClass* aClass,

Просмотреть файл

@ -83,7 +83,7 @@ public:
nsXPTCMiniVariant* params);
static nsProxyEventObject* GetNewOrUsedProxy(PLEventQueue *destQueue,
static nsProxyEventObject* GetNewOrUsedProxy(nsIEventQueue *destQueue,
ProxyType proxyType,
nsISupports *aObj,
REFNSIID aIID);
@ -103,7 +103,7 @@ public:
private:
nsProxyEventObject(); // not implemented
nsProxyEventObject(PLEventQueue *destQueue,
nsProxyEventObject(nsIEventQueue *destQueue,
ProxyType proxyType,
nsISupports* aObj,
nsProxyEventClass* aClass,
@ -131,13 +131,13 @@ public:
NS_DECL_ISUPPORTS
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPROXYEVENT_MANAGER_IID);
NS_IMETHOD GetProxyObject(PLEventQueue *destQueue,
NS_IMETHOD GetProxyObject(nsIEventQueue *destQueue,
REFNSIID aIID,
nsISupports* aObj,
ProxyType proxyType,
void** aProxyObject);
NS_IMETHOD GetProxyObject(PLEventQueue *destQueue,
NS_IMETHOD GetProxyObject(nsIEventQueue *destQueue,
const nsCID &aClass,
nsISupports *aDelegate,
const nsIID &aIID,

Просмотреть файл

@ -27,8 +27,6 @@
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "plevent.h"
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
@ -136,7 +134,7 @@ nsProxyObjectManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInst
NS_IMETHODIMP
nsProxyObjectManager::GetProxyObject(PLEventQueue *destQueue, REFNSIID aIID, nsISupports* aObj, ProxyType proxyType, void** aProxyObject)
nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue, REFNSIID aIID, nsISupports* aObj, ProxyType proxyType, void** aProxyObject)
{
*aProxyObject = nsnull;
@ -153,7 +151,7 @@ nsProxyObjectManager::GetProxyObject(PLEventQueue *destQueue, REFNSIID aIID, nsI
NS_IMETHODIMP
nsProxyObjectManager::GetProxyObject(PLEventQueue *destQueue,
nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue,
const nsCID &aClass,
nsISupports *aDelegate,
const nsIID &aIID,

Просмотреть файл

@ -66,7 +66,6 @@ class nsITestXPCFoo : public nsISupports {
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
static NS_DEFINE_IID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
/***************************************************************************/
/* Setup nsIAllocator */
/***************************************************************************/
@ -218,7 +217,7 @@ NS_IMETHODIMP nsTestXPCFoo2::Test2()
typedef struct _ArgsStruct
{
PLEventQueue* queue;
nsIEventQueue* queue;
PRInt32 threadNumber;
}ArgsStruct;
@ -359,30 +358,55 @@ static void PR_CALLBACK ProxyTest( void *arg )
TestCase_TwoClassesOneInterface(arg);
// TestCase_2(arg);
NS_RELEASE( ((ArgsStruct*) arg)->queue);
free((void*) arg);
}
PLEventQueue *gEventQueue = nsnull;
#include "nsIEventQueueService.h"
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
nsIEventQueue *gEventQueue = nsnull;
static void PR_CALLBACK EventLoop( void *arg )
{
nsresult rv;
printf("Creating EventQueue...\n");
gEventQueue = PL_CreateEventQueue("mainqueue", PR_GetCurrentThread());
nsIEventQueue* eventQ;
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &eventQ);
if (NS_FAILED(rv))
rv = eventQService->CreateThreadEventQueue();
if (NS_FAILED(rv))
return;
else
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(), &eventQ);
}
if (NS_FAILED(rv)) return;
rv = eventQ->QueryInterface(nsIEventQueue::GetIID(), (void**)&gEventQueue);
if (NS_FAILED(rv)) return;
printf("Looping for events.\n");
PLEvent* event = nsnull;
while ( PR_SUCCESS == PR_Sleep( PR_MillisecondsToInterval(1)) )
{
PL_HandleEvent(PL_GetEvent(gEventQueue));
rv = gEventQueue->GetEvent(&event);
if (NS_FAILED(rv))
return;
gEventQueue->HandleEvent(event);
}
PL_ProcessPendingEvents(gEventQueue);
gEventQueue->ProcessPendingEvents();
printf("Closing down Event Queue.\n");
PL_DestroyEventQueue( gEventQueue );
delete gEventQueue;
gEventQueue = nsnull;
printf("End looping for events.\n\n");
}
@ -412,7 +436,7 @@ main(int argc, char **argv)
PR_Sleep(PR_MillisecondsToInterval(1000));
PR_ASSERT(gEventQueue); // BAD BAD BAD. EVENT THREAD DID NOT CREATE QUEUE. This may be a timing issue, set the
NS_ASSERTION(gEventQueue, "no main event queue"); // BAD BAD BAD. EVENT THREAD DID NOT CREATE QUEUE. This may be a timing issue, set the
// sleep about longer, and try again.
printf("Spawn Threads:\n");
@ -422,6 +446,7 @@ main(int argc, char **argv)
ArgsStruct *args = (ArgsStruct *) malloc (sizeof(ArgsStruct));
args->queue = gEventQueue;
NS_ADDREF(args->queue);
args->threadNumber = spawn;
threads[spawn] = PR_CreateThread(PR_USER_THREAD,