From 97bcf14c9a5774a8549b362a62b86f6594b902ed Mon Sep 17 00:00:00 2001 From: "leaf%mozilla.org" Date: Thu, 19 Aug 1999 02:58:12 +0000 Subject: [PATCH] Finishing backout of dougt git-svn-id: svn://10.0.0.236/trunk@43539 18797224-902f-48f8-a5cc-f745e15eee43 --- .../protocol/http/src/nsHTTPChannel.cpp | 78 ++++++++++++++--- .../http/src/nsHTTPResponseListener.cpp | 87 +++++++++++++++---- 2 files changed, 135 insertions(+), 30 deletions(-) diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index 2e7299e69a9..91c128a372e 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -32,6 +32,7 @@ #include "nsIHttpNotify.h" #include "nsINetModRegEntry.h" +#include "nsProxyObjectManager.h" #include "nsIServiceManager.h" #include "nsINetModuleMgr.h" #include "nsIEventQueueService.h" @@ -43,6 +44,7 @@ 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, @@ -432,6 +434,8 @@ 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); @@ -492,34 +496,82 @@ nsHTTPChannel::Open(void) NS_WITH_SERVICE(nsINetModuleMgr, pNetModuleMgr, kNetModuleMgrCID, &rv); if (NS_FAILED(rv)) return rv; - nsCOMPtr pModules; - rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_PROGID, getter_AddRefs(pModules)); + nsISimpleEnumerator* pModules = nsnull; + rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_PROGID, &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)) - { - nsCOMPtr entry = do_QueryInterface(supEntry, &rv); - if (NS_FAILED(rv)) + 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); return rv; + } - nsCOMPtr syncNotifier; - entry->GetSyncProxy(getter_AddRefs(syncNotifier)); - nsCOMPtr pNotify = do_QueryInterface(syncNotifier, &rv); + nsCID *lCID; + nsIEventQueue* lEventQ = nsnull; - if (NS_SUCCEEDED(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)) { // 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/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp index 7e7bcf1594f..254bdec5fd6 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponseListener.cpp @@ -29,8 +29,10 @@ #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" @@ -80,6 +82,8 @@ 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 @@ -239,8 +243,7 @@ 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; @@ -248,40 +251,90 @@ 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; - nsCOMPtr pModules; - rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_PROGID, getter_AddRefs(pModules)); + nsISimpleEnumerator* pModules = nsnull; + rv = pNetModuleMgr->EnumerateModules(NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_PROGID, &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)) - { - nsCOMPtr entry = do_QueryInterface(supEntry, &rv); - if (NS_FAILED(rv)) + 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); return rv; + } - nsCOMPtr syncNotifier; - entry->GetSyncProxy(getter_AddRefs(syncNotifier)); - nsCOMPtr pNotify = do_QueryInterface(syncNotifier, &rv); + nsCID *lCID; + nsIEventQueue* lEventQ = nsnull; - if (NS_SUCCEEDED(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)) { // 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 } - } - else - { + NS_RELEASE(pModules); + NS_IF_RELEASE(proxyObjectManager); + + } else { rv = NS_ERROR_FAILURE; }