зеркало из https://github.com/mozilla/gecko-dev.git
fixes bug 217766 "use nsIObserverService in place of nsINetModuleMgr (eliminate nsIHttpNotify)" r=dwitte sr=bzbarsky
This commit is contained in:
Родитель
9a7c290d71
Коммит
a3e9dca1b6
|
@ -54,9 +54,6 @@ XPIDLSRCS = \
|
|||
nsIInputStreamPump.idl \
|
||||
nsIInputStreamChannel.idl \
|
||||
nsIMIMEInputStream.idl \
|
||||
nsINetModRegEntry.idl \
|
||||
nsINetModuleMgr.idl \
|
||||
nsINetNotify.idl \
|
||||
nsIPasswordManager.idl \
|
||||
nsIPasswordManagerInternal.idl \
|
||||
nsIProgressEventSink.idl \
|
||||
|
|
|
@ -50,8 +50,6 @@ CPPSRCS = \
|
|||
nsIOService.cpp \
|
||||
nsLoadGroup.cpp \
|
||||
nsMIMEInputStream.cpp \
|
||||
nsNetModRegEntry.cpp \
|
||||
nsNetModuleMgr.cpp \
|
||||
nsProtocolProxyService.cpp \
|
||||
nsRequestObserverProxy.cpp \
|
||||
nsResumableEntityID.cpp \
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsReadLine.h"
|
||||
#include "prlog.h"
|
||||
#include "prio.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsNetModuleMgr.h"
|
||||
#include "nsSocketProviderService.h"
|
||||
#include "nscore.h"
|
||||
#include "nsSimpleURI.h"
|
||||
|
@ -592,10 +591,6 @@ static const nsModuleComponentInfo gNetModuleInfo[] = {
|
|||
NS_SIMPLEURI_CID,
|
||||
NS_SIMPLEURI_CONTRACTID,
|
||||
nsSimpleURI::Create },
|
||||
{ "External Module Manager",
|
||||
NS_NETMODULEMGR_CID,
|
||||
"@mozilla.org/network/net-extern-mod;1",
|
||||
nsNetModuleMgr::Create },
|
||||
{ NS_ASYNCSTREAMCOPIER_CLASSNAME,
|
||||
NS_ASYNCSTREAMCOPIER_CID,
|
||||
NS_ASYNCSTREAMCOPIER_CONTRACTID,
|
||||
|
|
|
@ -37,7 +37,6 @@ SDK_XPIDLSRCS = \
|
|||
|
||||
XPIDLSRCS = \
|
||||
nsIHttpChannelInternal.idl \
|
||||
nsIHttpNotify.idl \
|
||||
nsIHttpProtocolHandler.idl \
|
||||
nsIHttpEventSink.idl \
|
||||
nsIHttpAuthenticator.idl \
|
||||
|
|
|
@ -105,10 +105,32 @@ interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler
|
|||
};
|
||||
|
||||
%{C++
|
||||
// HTTP protocol handler will do_GetService() on each ContractId that is
|
||||
// registered under this category when it comes alive.
|
||||
/**
|
||||
* At initialization time, the HTTP handler will initialize each service
|
||||
* registered under this category:
|
||||
*/
|
||||
#define NS_HTTP_STARTUP_CATEGORY "http-startup-category"
|
||||
// If the resulting service implements nsIObserver, then its Observer
|
||||
// method will be invoked with the following topic.
|
||||
|
||||
/**
|
||||
* nsIObserver notification corresponding to startup category. Services
|
||||
* registered under the startup category will receive this observer topic at
|
||||
* startup if they implement nsIObserver. The "subject" of the notification
|
||||
* is the nsIHttpProtocolHandler instance.
|
||||
*/
|
||||
#define NS_HTTP_STARTUP_TOPIC "http-startup"
|
||||
|
||||
/**
|
||||
* Before an HTTP request is sent to the server, this observer topic is
|
||||
* notified. The observer of this topic can then choose to set any additional
|
||||
* headers for this request before the request is actually sent to the server.
|
||||
* The "subject" of the notification is the nsIHttpChannel instance.
|
||||
*/
|
||||
#define NS_HTTP_ON_MODIFY_REQUEST_TOPIC "http-on-modify-request"
|
||||
|
||||
/**
|
||||
* After an HTTP server response is received, this observer topic is notified.
|
||||
* The observer of this topic can interrogate the response. The "subject" of
|
||||
* the notification is the nsIHttpChannel instance.
|
||||
*/
|
||||
#define NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC "http-on-examine-response"
|
||||
%}
|
||||
|
|
|
@ -36,14 +36,11 @@
|
|||
#include "nsHttpAuthCache.h"
|
||||
#include "nsStandardURL.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpNotify.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIStandardURL.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsINetModRegEntry.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
|
@ -75,7 +72,6 @@ extern PRThread *gSocketThread;
|
|||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID);
|
||||
static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID);
|
||||
|
@ -238,13 +234,12 @@ nsHttpHandler::Init()
|
|||
NS_STATIC_CAST(nsISupports*,NS_STATIC_CAST(void*,this)),
|
||||
NS_HTTP_STARTUP_TOPIC);
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerSvc =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (observerSvc) {
|
||||
observerSvc->AddObserver(this, "profile-change-net-teardown", PR_TRUE);
|
||||
observerSvc->AddObserver(this, "profile-change-net-restore", PR_TRUE);
|
||||
observerSvc->AddObserver(this, "session-logout", PR_TRUE);
|
||||
observerSvc->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
mObserverService = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (mObserverService) {
|
||||
mObserverService->AddObserver(this, "profile-change-net-teardown", PR_TRUE);
|
||||
mObserverService->AddObserver(this, "profile-change-net-restore", PR_TRUE);
|
||||
mObserverService->AddObserver(this, "session-logout", PR_TRUE);
|
||||
mObserverService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_TRUE);
|
||||
}
|
||||
|
||||
StartPruneDeadConnectionsTimer();
|
||||
|
@ -486,80 +481,18 @@ nsHttpHandler::GetIOService(nsIIOService** result)
|
|||
nsresult
|
||||
nsHttpHandler::OnModifyRequest(nsIHttpChannel *chan)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
LOG(("nsHttpHandler::OnModifyRequest [chan=%x]\n", chan));
|
||||
|
||||
if (!mNetModuleMgr) {
|
||||
mNetModuleMgr = do_GetService(kNetModuleMgrCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> modules;
|
||||
rv = mNetModuleMgr->EnumerateModules(
|
||||
NS_NETWORK_MODULE_MANAGER_HTTP_REQUEST_CONTRACTID,
|
||||
getter_AddRefs(modules));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
|
||||
// notify each module...
|
||||
while (NS_SUCCEEDED(modules->GetNext(getter_AddRefs(sup)))) {
|
||||
nsCOMPtr<nsINetModRegEntry> entry = do_QueryInterface(sup, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsINetNotify> netNotify;
|
||||
rv = entry->GetSyncProxy(getter_AddRefs(netNotify));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIHttpNotify> httpNotify = do_QueryInterface(netNotify, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// fire off the notification, ignore the return code.
|
||||
httpNotify->OnModifyRequest(chan);
|
||||
}
|
||||
|
||||
if (mObserverService)
|
||||
mObserverService->NotifyObservers(chan, NS_HTTP_ON_MODIFY_REQUEST_TOPIC, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHttpHandler::OnExamineResponse(nsIHttpChannel *chan)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
LOG(("nsHttpHandler::OnExamineResponse [chan=%x]\n", chan));
|
||||
|
||||
if (!mNetModuleMgr) {
|
||||
mNetModuleMgr = do_GetService(kNetModuleMgrCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> modules;
|
||||
rv = mNetModuleMgr->EnumerateModules(
|
||||
NS_NETWORK_MODULE_MANAGER_HTTP_RESPONSE_CONTRACTID,
|
||||
getter_AddRefs(modules));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
nsCOMPtr<nsINetModRegEntry> entry;
|
||||
nsCOMPtr<nsINetNotify> netNotify;
|
||||
nsCOMPtr<nsIHttpNotify> httpNotify;
|
||||
|
||||
// notify each module...
|
||||
while (NS_SUCCEEDED(modules->GetNext(getter_AddRefs(sup)))) {
|
||||
entry = do_QueryInterface(sup, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = entry->GetSyncProxy(getter_AddRefs(netNotify));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
httpNotify = do_QueryInterface(netNotify, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// fire off the notification, ignore the return code.
|
||||
httpNotify->OnExamineResponse(chan);
|
||||
}
|
||||
|
||||
if (mObserverService)
|
||||
mObserverService->NotifyObservers(chan, NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
#include "nsIProtocolProxyService.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsINetModuleMgr.h"
|
||||
#include "nsIProxy.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsICacheSession.h"
|
||||
|
@ -183,8 +183,8 @@ private:
|
|||
nsCOMPtr<nsIIOService> mIOService;
|
||||
nsCOMPtr<nsIProxyObjectManager> mProxyMgr;
|
||||
nsCOMPtr<nsIEventQueueService> mEventQueueService;
|
||||
nsCOMPtr<nsINetModuleMgr> mNetModuleMgr;
|
||||
nsCOMPtr<nsIStreamConverterService> mStreamConvSvc;
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
nsCOMPtr<nsICookieService> mCookieService;
|
||||
nsCOMPtr<nsIMIMEService> mMimeService;
|
||||
nsCOMPtr<nsIIDNService> mIDNConverter;
|
||||
|
|
Загрузка…
Ссылка в новой задаче