Bug 199200 Make Networking Tests XP friendly by using the eventqueueservice

sr=heikki
This commit is contained in:
timeless%mozdev.org 2003-04-08 22:01:40 +00:00
parent acf475c8a5
commit 82fedfaf09
2 changed files with 34 additions and 74 deletions

View File

@ -255,51 +255,31 @@ PageGrabber::Grab(const nsAFlatCString& aURL)
rv = ioService->NewChannelFromURI(url, &channel); rv = ioService->NewChannelFromURI(url, &channel);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
PRBool error = PR_FALSE;
// Start the URL load... // Start the URL load...
StreamToFile* copier = new StreamToFile(fp); StreamToFile* copier = new StreamToFile(fp);
if(copier) { if (!copier)
NS_ADDREF(copier); return NS_ERROR_OUT_OF_MEMORY;
rv = channel->AsyncOpen(copier, nsnull); NS_ADDREF(copier);
if (NS_FAILED(rv)) { rv = channel->AsyncOpen(copier, nsnull);
NS_RELEASE(copier);
return rv;
}
// Enter the message pump to allow the URL load to proceed.
#ifdef XP_WIN
MSG msg;
while ( !copier->IsDone() ) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
#endif
#ifdef XP_OS2
QMSG qmsg;
while ( !copier->IsDone() ) {
if (WinPeekMsg(0, &qmsg, NULL, 0, 0, PM_REMOVE)) {
WinDispatchMsg(0, &qmsg);
}
}
#endif
#ifdef XP_UNIX
while ( !copier->IsDone() ) {
PLEvent *gEvent;
gEventQ->WaitForEvent(&gEvent);
gEventQ->HandleEvent(gEvent);
}
#endif
error = copier->HaveError(); if (NS_FAILED(rv)) {
NS_RELEASE(copier); NS_RELEASE(copier);
return rv;
}
// Enter the message pump to allow the URL load to proceed.
while ( !copier->IsDone() ) {
PLEvent *gEvent;
gEventQ->WaitForEvent(&gEvent);
gEventQ->HandleEvent(gEvent);
} }
return error ? NS_ERROR_OUT_OF_MEMORY : NS_OK; rv = copier->HaveError() ? NS_ERROR_FAILURE : NS_OK;
NS_RELEASE(copier);
return rv;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -255,51 +255,31 @@ PageGrabber::Grab(const nsAFlatCString& aURL)
rv = ioService->NewChannelFromURI(url, &channel); rv = ioService->NewChannelFromURI(url, &channel);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
PRBool error = PR_FALSE;
// Start the URL load... // Start the URL load...
StreamToFile* copier = new StreamToFile(fp); StreamToFile* copier = new StreamToFile(fp);
if(copier) { if (!copier)
NS_ADDREF(copier); return NS_ERROR_OUT_OF_MEMORY;
rv = channel->AsyncOpen(copier, nsnull); NS_ADDREF(copier);
if (NS_FAILED(rv)) { rv = channel->AsyncOpen(copier, nsnull);
NS_RELEASE(copier);
return rv;
}
// Enter the message pump to allow the URL load to proceed.
#ifdef XP_WIN
MSG msg;
while ( !copier->IsDone() ) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
#endif
#ifdef XP_OS2
QMSG qmsg;
while ( !copier->IsDone() ) {
if (WinPeekMsg(0, &qmsg, NULL, 0, 0, PM_REMOVE)) {
WinDispatchMsg(0, &qmsg);
}
}
#endif
#ifdef XP_UNIX
while ( !copier->IsDone() ) {
PLEvent *gEvent;
gEventQ->WaitForEvent(&gEvent);
gEventQ->HandleEvent(gEvent);
}
#endif
error = copier->HaveError(); if (NS_FAILED(rv)) {
NS_RELEASE(copier); NS_RELEASE(copier);
return rv;
}
// Enter the message pump to allow the URL load to proceed.
while ( !copier->IsDone() ) {
PLEvent *gEvent;
gEventQ->WaitForEvent(&gEvent);
gEventQ->HandleEvent(gEvent);
} }
return error ? NS_ERROR_OUT_OF_MEMORY : NS_OK; rv = copier->HaveError() ? NS_ERROR_FAILURE : NS_OK;
NS_RELEASE(copier);
return rv;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------