port webservices

git-svn-id: svn://10.0.0.236/branches/THREADS_20060213_BRANCH@190836 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2006-02-22 16:12:41 +00:00
parent f7a7db8c97
commit 871fa27f37
2 changed files with 7 additions and 30 deletions

View File

@@ -45,14 +45,12 @@
#include "nsIDNSRecord.h"
#include "nsICancelable.h"
#include "nsIRequest.h"
#include "nsEventQueueUtils.h"
#include "nsThreadUtils.h"
#include "nsAutoPtr.h"
#include "nsNetCID.h"
static const char kSecurityProperties[] =
"chrome://global/locale/webservices/security.properties";
static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
class nsDNSListener : public nsIDNSListener
{
@@ -228,7 +226,7 @@ nsWSAUtils::GetOfficialHostName(nsIURI* aServiceURI,
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsCOMPtr<nsIDNSService> dns(do_GetService(kDNSServiceCID, &rv));
nsCOMPtr<nsIDNSService> dns(do_GetService(NS_DNSSERVICE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
@@ -239,36 +237,17 @@ nsWSAUtils::GetOfficialHostName(nsIURI* aServiceURI,
nsRefPtr<nsDNSListener> listener = new nsDNSListener();
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsIEventQueueService> eventQService =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIEventQueue> eventQ;
rv = eventQService->PushThreadEventQueue(getter_AddRefs(eventQ));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
NS_ENSURE_STATE(thread);
nsCOMPtr<nsICancelable> dummy;
rv = dns->AsyncResolve(host, nsIDNSService::RESOLVE_CANONICAL_NAME,
listener, eventQ, getter_AddRefs(dummy));
listener, thread, getter_AddRefs(dummy));
PLEvent *ev;
while (NS_SUCCEEDED(rv) && !listener->mLookupFinished) {
rv = eventQ->WaitForEvent(&ev);
NS_ASSERTION(NS_SUCCEEDED(rv), "WaitForEvent failed");
if (NS_SUCCEEDED(rv)) {
rv = eventQ->HandleEvent(ev);
NS_ASSERTION(NS_SUCCEEDED(rv), "HandleEvent failed");
}
}
while (NS_SUCCEEDED(rv) && !listener->mLookupFinished)
rv = thread->RunNextTask(nsIThread::RUN_NORMAL);
aResult.Assign(listener->mOfficialHostName);
eventQService->PopThreadEventQueue(eventQ);
return rv;
}
@@ -295,4 +274,3 @@ nsDNSListener::OnLookupComplete(nsICancelable* aRequest,
mLookupFinished = PR_TRUE;
return NS_OK;
}

View File

@@ -39,7 +39,6 @@
#define nsWSAUtils_h__
#include "nsIDNSListener.h"
#include "nsIEventQueueService.h"
#include "nsIURI.h"
#include "nsCOMPtr.h"
#include "nsString.h"