From 0b7cc4c86e0d98f8462438ce465873279d24f706 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Wed, 18 Aug 1999 09:33:27 +0000 Subject: [PATCH] Updating to use new NetMod Notification. --- netwerk/protocol/http/src/nsHTTPChannel.cpp | 78 +++-------------- .../http/src/nsHTTPResponseListener.cpp | 87 ++++--------------- 2 files changed, 30 insertions(+), 135 deletions(-) diff --git a/netwerk/protocol/http/src/nsHTTPChannel.cpp b/netwerk/protocol/http/src/nsHTTPChannel.cpp index 91c128a372ea..2e7299e69a9c 100644 --- a/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -32,7 +32,6 @@ #include "nsIHttpNotify.h" #include "nsINetModRegEntry.h" -#include "nsProxyObjectManager.h" #include "nsIServiceManager.h" #include "nsINetModuleMgr.h" #include "nsIEventQueueService.h" @@ -44,7 +43,6 @@ extern PRLogModuleInfo* gHTTPLog; #endif /* PR_LOGGING */ static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); -static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL, nsIHTTPEventSink* i_HTTPEventSink, @@ -434,8 +432,6 @@ nsHTTPChannel::GetResponseDataListener(nsIStreamListener* *aListener) return rv; } -static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID); -static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -496,82 +492,34 @@ nsHTTPChannel::Open(void) NS_WITH_SERVICE(nsINetModuleMgr, pNetModuleMgr, kNetModuleMgrCID, &rv); if (NS_FAILED(rv)) return rv; - nsISimpleEnumerator* pModules = nsnull; - rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_PROGID, &pModules); + nsCOMPtr pModules; + rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_PROGID, getter_AddRefs(pModules)); if (NS_FAILED(rv)) return rv; - nsIProxyObjectManager* proxyObjectManager = nsnull; - rv = nsServiceManager::GetService( NS_XPCOMPROXY_PROGID, - kProxyObjectManagerIID, - (nsISupports **)&proxyObjectManager); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - return rv; - } - - nsISupports *supEntry = nsnull; - // Go through the external modules and notify each one. + nsISupports *supEntry; rv = pModules->GetNext(&supEntry); - while (NS_SUCCEEDED(rv)) { - nsINetModRegEntry *entry = nsnull; - rv = supEntry->QueryInterface(nsCOMTypeInfo::GetIID(), (void**)&entry); - NS_RELEASE(supEntry); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - NS_RELEASE(proxyObjectManager); + while (NS_SUCCEEDED(rv)) + { + nsCOMPtr entry = do_QueryInterface(supEntry, &rv); + if (NS_FAILED(rv)) return rv; - } - nsCID *lCID; - nsIEventQueue* lEventQ = nsnull; + nsCOMPtr syncNotifier; + entry->GetSyncProxy(getter_AddRefs(syncNotifier)); + nsCOMPtr pNotify = do_QueryInterface(syncNotifier, &rv); - rv = entry->GetMCID(&lCID); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - NS_RELEASE(proxyObjectManager); - return rv; - } - - rv = entry->GetMEventQ(&lEventQ); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - NS_RELEASE(proxyObjectManager); - return rv; - } - - nsIHTTPNotify *pNotify = nsnull; - // if this call fails one of the following happened. - // a) someone registered an object for this topic but didn't - // implement the nsIHTTPNotify interface on that object. - // b) someone registered an object for this topic bud didn't - // put the .xpt lib for that object in the components dir - rv = proxyObjectManager->GetProxyObject(lEventQ, - *lCID, - nsnull, - nsCOMTypeInfo::GetIID(), - PROXY_SYNC, - (void**)&pNotify); - NS_RELEASE(proxyObjectManager); - - NS_RELEASE(lEventQ); - - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) + { // send off the notification, and block. - // make the nsIHTTPNotify api call pNotify->ModifyRequest(this); - NS_RELEASE(pNotify); // we could do something with the return code from the external // module, but what???? } - - NS_RELEASE(entry); rv = pModules->GetNext(&supEntry); // go around again } - NS_RELEASE(pModules); - NS_IF_RELEASE(proxyObjectManager); - + if (channel) { nsCOMPtr stream; diff --git a/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index 254bdec5fd6b..7e7bcf1594fb 100644 --- a/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -29,10 +29,8 @@ #include "nsHTTPAtoms.h" #include "nsIHttpNotify.h" #include "nsINetModRegEntry.h" -#include "nsProxyObjectManager.h" #include "nsIServiceManager.h" #include "nsINetModuleMgr.h" -#include "nsIEventQueueService.h" #include "nsIBuffer.h" #include "nsIIOService.h" @@ -82,8 +80,6 @@ nsHTTPResponseListener::~nsHTTPResponseListener() NS_IMPL_ISUPPORTS(nsHTTPResponseListener,nsCOMTypeInfo::GetIID()); -static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID); -static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID); NS_IMETHODIMP @@ -243,7 +239,8 @@ nsresult nsHTTPResponseListener::FireOnHeadersAvailable() nsresult rv; NS_ASSERTION(m_bHeadersDone, "Headers have not been received!"); - if (m_bHeadersDone) { + if (m_bHeadersDone) + { // Notify the event sink that response headers are available... nsCOMPtr sink; @@ -251,90 +248,40 @@ nsresult nsHTTPResponseListener::FireOnHeadersAvailable() if (sink) { sink->OnHeadersAvailable(m_pConnection); } - // Check for any modules that want to receive headers once they've arrived. NS_WITH_SERVICE(nsINetModuleMgr, pNetModuleMgr, kNetModuleMgrCID, &rv); if (NS_FAILED(rv)) return rv; - nsISimpleEnumerator* pModules = nsnull; - rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_PROGID, &pModules); + nsCOMPtr pModules; + rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_PROGID, getter_AddRefs(pModules)); if (NS_FAILED(rv)) return rv; - nsIProxyObjectManager* proxyObjectManager = nsnull; - rv = nsServiceManager::GetService( NS_XPCOMPROXY_PROGID, - kProxyObjectManagerIID, - (nsISupports **)&proxyObjectManager); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - return rv; - } - - nsISupports *supEntry = nsnull; - // Go through the external modules and notify each one. + nsISupports *supEntry; rv = pModules->GetNext(&supEntry); - while (NS_SUCCEEDED(rv)) { - nsINetModRegEntry *entry = nsnull; - rv = supEntry->QueryInterface(nsCOMTypeInfo::GetIID(), (void**)&entry); - NS_RELEASE(supEntry); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - NS_RELEASE(proxyObjectManager); + while (NS_SUCCEEDED(rv)) + { + nsCOMPtr entry = do_QueryInterface(supEntry, &rv); + if (NS_FAILED(rv)) return rv; - } - nsCID *lCID; - nsIEventQueue* lEventQ = nsnull; + nsCOMPtr syncNotifier; + entry->GetSyncProxy(getter_AddRefs(syncNotifier)); + nsCOMPtr pNotify = do_QueryInterface(syncNotifier, &rv); - rv = entry->GetMCID(&lCID); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - NS_RELEASE(proxyObjectManager); - return rv; - } - - rv = entry->GetMEventQ(&lEventQ); - if (NS_FAILED(rv)) { - NS_RELEASE(pModules); - NS_RELEASE(proxyObjectManager); - return rv; - } - - nsIHTTPNotify *pNotify = nsnull; - // if this call fails one of the following happened. - // a) someone registered an object for this topic but didn't - // implement the nsIHTTPNotify interface on that object. - // b) someone registered an object for this topic bud didn't - // put the .xpt lib for that object in the components dir - rv = proxyObjectManager->GetProxyObject(lEventQ, - *lCID, - nsnull, - nsCOMTypeInfo::GetIID(), - /* XXX needs to be async */ - /*PROXY_ASYNC,*/ - PROXY_SYNC, - (void**)&pNotify); - NS_RELEASE(proxyObjectManager); - - NS_RELEASE(lEventQ); - - if (NS_SUCCEEDED(rv)) { + if (NS_SUCCEEDED(rv)) + { // send off the notification, and block. - // make the nsIHTTPNotify api call pNotify->AsyncExamineResponse(m_pConnection); - NS_RELEASE(pNotify); // we could do something with the return code from the external // module, but what???? } - - NS_RELEASE(entry); rv = pModules->GetNext(&supEntry); // go around again } - NS_RELEASE(pModules); - NS_IF_RELEASE(proxyObjectManager); - - } else { + } + else + { rv = NS_ERROR_FAILURE; }