Switching over to nsIEventQueues.

This commit is contained in:
hyatt%netscape.com 1999-05-04 23:31:07 +00:00
Родитель b1ed61a68a
Коммит 2f4053dbab
4 изменённых файлов: 32 добавлений и 20 удалений

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

@ -172,7 +172,7 @@ public:
NS_IMETHOD OnStartRunningUrl(nsIURL * aUrl);
NS_IMETHOD OnStopRunningUrl(nsIURL * aUrl, nsresult aExitCode);
nsMailboxTestDriver(PLEventQueue *queue, nsIStreamListener * aMailboxParser);
nsMailboxTestDriver(nsIEventQueue *queue, nsIStreamListener * aMailboxParser);
virtual ~nsMailboxTestDriver();
// run driver initializes the instance, lists the commands, runs the command and when
@ -194,7 +194,7 @@ public:
nsresult OnExit();
protected:
PLEventQueue *m_eventQueue;
nsIEventQueue *m_eventQueue;
char m_urlSpec[200]; // "sockstub://hostname:port" it does not include the command specific data...
char m_urlString[800]; // string representing the current url being run. Includes host AND command specific data.
char m_userData[500]; // generic string buffer for storing the current user entered data...
@ -241,7 +241,7 @@ nsresult nsMailboxTestDriver::OnStopRunningUrl(nsIURL * aUrl, nsresult aExitCode
NS_IMPL_ISUPPORTS(nsMailboxTestDriver, nsIUrlListener::GetIID())
nsMailboxTestDriver::nsMailboxTestDriver(PLEventQueue *queue, nsIStreamListener * aMailboxParser) : m_folderSpec("")
nsMailboxTestDriver::nsMailboxTestDriver(nsIEventQueue *queue, nsIStreamListener * aMailboxParser) : m_folderSpec("")
{
NS_INIT_REFCNT();
m_urlSpec[0] = '\0';
@ -250,6 +250,7 @@ nsMailboxTestDriver::nsMailboxTestDriver(PLEventQueue *queue, nsIStreamListener
m_runningURL = PR_FALSE;
m_runTestHarness = PR_TRUE;
m_eventQueue = queue;
NS_IF_ADDREF(queue);
InitializeTestDriver(); // prompts user for initialization information...
@ -265,6 +266,7 @@ nsMailboxTestDriver::nsMailboxTestDriver(PLEventQueue *queue, nsIStreamListener
nsMailboxTestDriver::~nsMailboxTestDriver()
{
NS_IF_RELEASE(m_mailboxParser);
NS_IF_RELEASE(m_eventQueue);
}
nsresult nsMailboxTestDriver::RunDriver()
@ -535,7 +537,7 @@ nsresult nsMailboxTestDriver::OpenMailbox()
int main()
{
nsINetService * pNetService;
PLEventQueue *queue;
nsCOMPtr<nsIEventQueue> queue;
nsresult result;
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
@ -562,7 +564,7 @@ int main()
return 1;
}
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),&queue);
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),getter_AddRefs(queue));
if (NS_FAILED(result) || !queue) {
printf("unable to get event queue.\n");
return 1;

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

@ -19,6 +19,8 @@
#include <stdio.h>
#include <assert.h>
#include "nsCOMPtr.h"
#ifdef XP_PC
#include <windows.h>
#endif
@ -92,7 +94,7 @@ static NS_DEFINE_IID(kFileLocatorCID, NS_FILELOCATOR_CID);
class nsPop3TestDriver : public nsIUrlListener
{
public:
nsPop3TestDriver(nsINetService * pService, PLEventQueue *queue);
nsPop3TestDriver(nsINetService * pService, nsIEventQueue *queue);
virtual ~nsPop3TestDriver();
NS_DECL_ISUPPORTS
@ -122,7 +124,7 @@ public:
nsresult OnIdentityCheck();
protected:
PLEventQueue *m_eventQueue;
nsIEventQueue *m_eventQueue;
char m_urlSpec[200]; // "sockstub://hostname:port" it does not include the command specific data...
char m_urlString[500]; // string representing the current url being run. Includes host AND command specific data.
char m_userData[250]; // generic string buffer for storing the current user entered data...
@ -134,7 +136,7 @@ protected:
NS_IMPL_ISUPPORTS(nsPop3TestDriver, nsIUrlListener::GetIID())
nsPop3TestDriver::nsPop3TestDriver(nsINetService * pNetService,
PLEventQueue *queue)
nsIEventQueue *queue)
{
NS_INIT_REFCNT();
m_urlSpec[0] = '\0';
@ -142,12 +144,14 @@ nsPop3TestDriver::nsPop3TestDriver(nsINetService * pNetService,
m_runningURL = PR_FALSE;
m_runTestHarness = PR_TRUE;
m_eventQueue = queue;
NS_IF_ADDREF(queue);
InitializeTestDriver(); // prompts user for initialization information...
}
nsPop3TestDriver::~nsPop3TestDriver()
{
NS_IF_RELEASE(m_eventQueue);
}
nsresult nsPop3TestDriver::OnStartRunningUrl(nsIURL * aUrl)
@ -192,7 +196,7 @@ nsresult nsPop3TestDriver::RunDriver()
} // if running url
#ifdef XP_UNIX
printf(".");
PL_ProcessPendingEvents(m_eventQueue);
m_eventQueue->ProcessPendingEvents();
#endif
#ifdef XP_PC
MSG msg;
@ -463,7 +467,7 @@ nsresult nsPop3TestDriver::OnGet()
int main()
{
PLEventQueue *queue;
nsCOMPtr<nsIEventQueue> queue;
nsINetService * pNetService;
nsresult result;
@ -497,7 +501,7 @@ int main()
return 1;
}
result = pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),&queue);
result = pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),getter_AddRefs(queue));
if (NS_FAILED(result) || !queue) {
printf("unable to get event queue.\n");
return 1;

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

@ -35,6 +35,8 @@
#include <windows.h>
#endif
#include "nsCOMPtr.h"
#include "plstr.h"
#include "plevent.h"
@ -169,7 +171,7 @@ static void strip_nonprintable(char *string) {
class nsNntpTestDriver : public nsIUrlListener
{
public:
nsNntpTestDriver(nsINetService * pService, PLEventQueue *queue);
nsNntpTestDriver(nsINetService * pService, nsIEventQueue *queue);
virtual ~nsNntpTestDriver();
NS_DECL_ISUPPORTS
@ -202,7 +204,7 @@ public:
nsresult OnRunURL();
nsresult OnExit();
protected:
PLEventQueue *m_eventQueue;
nsIEventQueue *m_eventQueue;
char m_urlSpec[200]; // "sockstub://hostname:port" it does not include the command specific data...
char m_urlString[500]; // string representing the current url being run. Includes host AND command specific data.
char m_userData[250]; // generic string buffer for storing the current user entered data...
@ -224,7 +226,7 @@ protected:
};
nsNntpTestDriver::nsNntpTestDriver(nsINetService * pNetService,
PLEventQueue *queue)
nsIEventQueue *queue)
{
NS_INIT_REFCNT();
@ -235,6 +237,7 @@ nsNntpTestDriver::nsNntpTestDriver(nsINetService * pNetService,
m_runTestHarness = PR_TRUE;
m_runningURL = PR_FALSE;
m_eventQueue = queue;
NS_IF_ADDREF(queue);
InitializeTestDriver(); // prompts user for initialization information...
@ -276,6 +279,8 @@ nsNntpTestDriver::InitializeProtocol(const char * urlString)
nsNntpTestDriver::~nsNntpTestDriver()
{
NS_IF_RELEASE(m_eventQueue);
if (m_url)
m_url->UnRegisterListener(this);
@ -316,7 +321,7 @@ nsresult nsNntpTestDriver::RunDriver()
// if running url
#ifdef XP_UNIX
PL_ProcessPendingEvents(m_eventQueue);
m_eventQueue->ProcessPendingEvents();
#endif
#ifdef XP_PC
@ -784,7 +789,7 @@ nsresult nsNntpTestDriver::SetupUrl(char *groupname)
int main()
{
nsINetService * pNetService;
PLEventQueue *queue;
nsCOMPtr<nsIEventQueue> queue;
nsresult result;
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
@ -817,7 +822,7 @@ int main()
}
result =
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),&queue);
pEventQService->GetThreadEventQueue(PR_GetCurrentThread(),getter_AddRefs(queue));
if (NS_FAILED(result) || !queue) {
printf("unable to get event queue.\n");
return 1;

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

@ -243,16 +243,17 @@ nsJVMManager::PostEvent(PRUint32 threadID, nsIRunnable* runnable, PRBool async)
nsIEventQueueService* eventService = NULL;
nsresult rv = theServiceManager->GetService(kEventQueueServiceCID, kIEventQueueServiceIID, (nsISupports **)&eventService);
if (NS_SUCCEEDED(rv)) {
PLEventQueue* eventQueue = NULL;
nsIEventQueue* eventQueue = NULL;
rv = eventService->GetThreadEventQueue((PRThread*)threadID, &eventQueue);
theServiceManager->ReleaseService(kEventQueueServiceCID, eventService);
if (NS_SUCCEEDED(rv) && eventQueue != NULL) {
RunnableEvent* runnableEvent = new RunnableEvent(runnable);
if (async)
PL_PostEvent(eventQueue, runnableEvent);
eventQueue->PostEvent(runnableEvent);
else
PL_PostSynchronousEvent(eventQueue, runnableEvent);
eventQueue->PostSynchronousEvent(runnableEvent);
}
NS_IF_RELEASE(eventQueue);
}
return rv;
}