Updating to use new NetMod Notification.

This commit is contained in:
dougt%netscape.com 1999-08-18 09:33:27 +00:00
Родитель 431a9eef50
Коммит 0b7cc4c86e
2 изменённых файлов: 30 добавлений и 135 удалений

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

@ -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<nsISimpleEnumerator> 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<nsINetModRegEntry>::GetIID(), (void**)&entry);
NS_RELEASE(supEntry);
if (NS_FAILED(rv)) {
NS_RELEASE(pModules);
NS_RELEASE(proxyObjectManager);
while (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsINetModRegEntry> entry = do_QueryInterface(supEntry, &rv);
if (NS_FAILED(rv))
return rv;
}
nsCID *lCID;
nsIEventQueue* lEventQ = nsnull;
nsCOMPtr<nsINetNotify> syncNotifier;
entry->GetSyncProxy(getter_AddRefs(syncNotifier));
nsCOMPtr<nsIHTTPNotify> 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<nsIHTTPNotify>::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<nsIInputStream> stream;

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

@ -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<nsIStreamListener>::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<nsIHTTPEventSink> 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<nsISimpleEnumerator> 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<nsINetModRegEntry>::GetIID(), (void**)&entry);
NS_RELEASE(supEntry);
if (NS_FAILED(rv)) {
NS_RELEASE(pModules);
NS_RELEASE(proxyObjectManager);
while (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsINetModRegEntry> entry = do_QueryInterface(supEntry, &rv);
if (NS_FAILED(rv))
return rv;
}
nsCID *lCID;
nsIEventQueue* lEventQ = nsnull;
nsCOMPtr<nsINetNotify> syncNotifier;
entry->GetSyncProxy(getter_AddRefs(syncNotifier));
nsCOMPtr<nsIHTTPNotify> 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<nsIHTTPNotify>::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;
}