Make observers support weak references. Bug #18682; r=dp.

This commit is contained in:
scc%netscape.com 1999-12-07 14:06:36 +00:00
Родитель b62de0a844
Коммит f4ad22b9d9
24 изменённых файлов: 182 добавлений и 227 удалений

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

@ -240,22 +240,26 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
#ifndef XSL #ifndef XSL
NS_IMPL_ISUPPORTS3(nsXMLContentSink, NS_IMPL_ADDREF(nsXMLContentSink)
nsIXMLContentSink, NS_IMPL_RELEASE(nsXMLContentSink)
nsIContentSink,
nsIUnicharStreamLoaderObserver)
#else #else
NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink) NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink)
NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink) NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink)
NS_IMPL_QUERY_INTERFACE4(nsXMLContentSink,
nsIXMLContentSink,
nsIContentSink,
nsIObserver,
nsIUnicharStreamLoaderObserver)
#endif #endif
NS_INTERFACE_MAP_BEGIN(nsXMLContentSink)
NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink)
#ifdef XSL
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
#endif
NS_INTERFACE_MAP_ENTRY(nsIUnicharStreamLoaderObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXMLContentSink)
NS_INTERFACE_MAP_END
// nsIContentSink // nsIContentSink
NS_IMETHODIMP NS_IMETHODIMP
nsXMLContentSink::WillBuildModel(void) nsXMLContentSink::WillBuildModel(void)

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

@ -28,6 +28,7 @@
#include "nsIScrollableView.h" #include "nsIScrollableView.h"
#ifdef XSL #ifdef XSL
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsITransformMediator.h" #include "nsITransformMediator.h"
#endif #endif
#include "nsIUnicharInputStream.h" #include "nsIUnicharInputStream.h"
@ -56,6 +57,7 @@ typedef enum {
class nsXMLContentSink : public nsIXMLContentSink, class nsXMLContentSink : public nsIXMLContentSink,
#ifdef XSL #ifdef XSL
public nsIObserver, public nsIObserver,
public nsSupportsWeakReference,
#endif #endif
public nsIUnicharStreamLoaderObserver public nsIUnicharStreamLoaderObserver
{ {

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

@ -26,6 +26,7 @@
#include "nsIFactory.h" #include "nsIFactory.h"
#include "nsIElementObserver.h" #include "nsIElementObserver.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
// {E12F6997-F28F-11d2-8ACE-00105A1B8860} // {E12F6997-F28F-11d2-8ACE-00105A1B8860}
@ -34,7 +35,11 @@
class nsPICSElementObserver : public nsIElementObserver, public nsIObserver { class nsPICSElementObserver
: public nsIElementObserver,
public nsIObserver,
public nsSupportsWeakReference
{
public: public:
nsPICSElementObserver(); nsPICSElementObserver();

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

@ -59,6 +59,24 @@ static NS_DEFINE_IID(kPICSCID, NS_PICS_CID);
NS_IMPL_ADDREF(nsPICSElementObserver) \ NS_IMPL_ADDREF(nsPICSElementObserver) \
NS_IMPL_RELEASE(nsPICSElementObserver) NS_IMPL_RELEASE(nsPICSElementObserver)
NS_INTERFACE_MAP_BEGIN(nsPICSElementObserver)
/*
Slight problem here: there is no |class nsIPICSElementObserver|,
so, this is a slightly un-orthodox entry, which will have to be
fixed before we could switch over to the table-driven mechanism.
*/
if ( aIID.Equals(kIPICSElementObserverIID) )
foundInterface = NS_STATIC_CAST(nsIElementObserver*, this);
else
NS_INTERFACE_MAP_ENTRY(nsIElementObserver)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIElementObserver)
NS_INTERFACE_MAP_END
NS_PICS nsresult NS_NewPICSElementObserver(nsIObserver** anObserver) NS_PICS nsresult NS_NewPICSElementObserver(nsIObserver** anObserver)
{ {
if (anObserver == NULL) if (anObserver == NULL)
@ -85,38 +103,6 @@ nsPICSElementObserver::~nsPICSElementObserver(void)
} }
NS_IMETHODIMP nsPICSElementObserver::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if( NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if( aIID.Equals ( kIPICSElementObserverIID )) {
*aInstancePtr = (void*) ((nsIElementObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( kIElementObserverIID )) {
*aInstancePtr = (void*) ((nsIElementObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( kIObserverIID )) {
*aInstancePtr = (void*) ((nsIObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( kISupportsIID )) {
*aInstancePtr = (void*) (this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
const char* nsPICSElementObserver::GetTagNameAt(PRUint32 aTagIndex) const char* nsPICSElementObserver::GetTagNameAt(PRUint32 aTagIndex)
{ {
if (aTagIndex == 0) { if (aTagIndex == 0) {

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

@ -55,35 +55,27 @@ nsWalletlibService::~nsWalletlibService()
{ {
} }
NS_IMETHODIMP
nsWalletlibService::QueryInterface(REFNSIID iid, void** result)
{
if (! result) {
return NS_ERROR_NULL_POINTER;
}
*result = nsnull;
if (iid.Equals(NS_GET_IID(nsISupports)) || iid.Equals(kIWalletServiceIID)) {
*result = NS_STATIC_CAST(nsIWalletService*, this);
AddRef();
return NS_OK;
}
if (iid.Equals(kIFormSubmitObserverIID)) {
*result = NS_STATIC_CAST(nsIFormSubmitObserver*, this);
AddRef();
return NS_OK;
}
if (iid.Equals(nsIDocumentLoaderObserver::GetIID())) {
*result = (void*) ((nsIDocumentLoaderObserver*)this);
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsWalletlibService); NS_IMPL_ADDREF(nsWalletlibService);
NS_IMPL_RELEASE(nsWalletlibService); NS_IMPL_RELEASE(nsWalletlibService);
NS_INTERFACE_MAP_BEGIN(nsWalletlibService)
NS_INTERFACE_MAP_ENTRY(nsIWalletService)
/*
Note: although this class always inherited from |nsIObserver|,
|QueryInterface| didn't previously respond to this request.
Now it does.
*/
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIFormSubmitObserver)
NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWalletService)
NS_INTERFACE_MAP_END
NS_IMETHODIMP nsWalletlibService::WALLET_PreEdit(nsAutoString& walletList) { NS_IMETHODIMP nsWalletlibService::WALLET_PreEdit(nsAutoString& walletList) {
::WLLT_PreEdit(walletList); ::WLLT_PreEdit(walletList);
return NS_OK; return NS_OK;

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

@ -27,11 +27,13 @@
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsIFormSubmitObserver.h" #include "nsIFormSubmitObserver.h"
#include "nsIDocumentLoaderObserver.h" #include "nsIDocumentLoaderObserver.h"
#include "nsWeakReference.h"
class nsWalletlibService : public nsIWalletService, class nsWalletlibService : public nsIWalletService,
public nsIObserver, public nsIObserver,
public nsIFormSubmitObserver, public nsIFormSubmitObserver,
public nsIDocumentLoaderObserver { public nsIDocumentLoaderObserver,
public nsSupportsWeakReference {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

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

@ -125,39 +125,18 @@ NS_IMPL_ADDREF(mozXMLTerminal)
NS_IMPL_RELEASE(mozXMLTerminal) NS_IMPL_RELEASE(mozXMLTerminal)
NS_IMETHODIMP NS_INTERFACE_MAP_BEGIN(mozXMLTerminal)
mozXMLTerminal::QueryInterface(REFNSIID aIID,void** aInstancePtr) /*
{ I maintained the order from the original, however,
if (aInstancePtr == NULL) { the original called |XMLT_LOG| and in the interface-map form
return NS_ERROR_NULL_POINTER; it no longer does. Is this an issue?
} */
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozIXMLTerminal)
// Always NULL result, in case of failure NS_INTERFACE_MAP_ENTRY(mozIXMLTerminal)
*aInstancePtr = NULL; NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
if ( aIID.Equals(kISupportsIID)) { NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
*aInstancePtr = NS_STATIC_CAST(nsISupports*, NS_INTERFACE_MAP_END
NS_STATIC_CAST(mozIXMLTerminal*,this));
} else if ( aIID.Equals(mozIXMLTerminal::GetIID()) ) {
*aInstancePtr = NS_STATIC_CAST(mozIXMLTerminal*,this);
} else if (aIID.Equals(nsIDocumentLoaderObserver::GetIID())) {
*aInstancePtr = NS_STATIC_CAST(nsIDocumentLoaderObserver*,this);
} else if (aIID.Equals(nsIObserver::GetIID())) {
*aInstancePtr = NS_STATIC_CAST(nsIObserver*,this);
} else {
return NS_ERROR_NO_INTERFACE;
}
NS_ADDREF_THIS();
XMLT_LOG(mozXMLTerminal::QueryInterface,20,("mRefCnt = %d\n", mRefCnt));
return NS_OK;
}
NS_IMETHODIMP mozXMLTerminal::GetCurrentEntryNumber(PRInt32 *aNumber) NS_IMETHODIMP mozXMLTerminal::GetCurrentEntryNumber(PRInt32 *aNumber)

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

@ -25,6 +25,7 @@
#include "nscore.h" #include "nscore.h"
#include "nspr.h" #include "nspr.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsWeakReference.h"
#include "nsString.h" #include "nsString.h"
#include "mozXMLT.h" #include "mozXMLT.h"
@ -38,7 +39,8 @@
class mozXMLTerminal : public mozIXMLTerminal, class mozXMLTerminal : public mozIXMLTerminal,
public nsIDocumentLoaderObserver, public nsIDocumentLoaderObserver,
public nsIObserver public nsIObserver,
public nsSupportsWeakReference
{ {
public: public:

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

@ -32,6 +32,7 @@
#include "nsCharDetDll.h" #include "nsCharDetDll.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsObserverBase.h" #include "nsObserverBase.h"
#include "nsWeakReference.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@ -43,7 +44,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
class nsMetaCharsetObserver: public nsIElementObserver, class nsMetaCharsetObserver: public nsIElementObserver,
public nsIObserver, public nsIObserver,
public nsObserverBase, public nsObserverBase,
public nsIMetaCharsetService { public nsIMetaCharsetService,
public nsSupportsWeakReference {
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -110,39 +112,13 @@ nsMetaCharsetObserver::~nsMetaCharsetObserver()
NS_IMPL_ADDREF ( nsMetaCharsetObserver ); NS_IMPL_ADDREF ( nsMetaCharsetObserver );
NS_IMPL_RELEASE ( nsMetaCharsetObserver ); NS_IMPL_RELEASE ( nsMetaCharsetObserver );
//------------------------------------------------------------------------- NS_INTERFACE_MAP_BEGIN(nsMetaCharsetObserver)
NS_IMETHODIMP nsMetaCharsetObserver::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_INTERFACE_MAP_ENTRY(nsIElementObserver)
{ NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIMetaCharsetService)
if( NULL == aInstancePtr) { NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
return NS_ERROR_NULL_POINTER; NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIElementObserver)
} NS_INTERFACE_MAP_END
*aInstancePtr = NULL;
if( aIID.Equals ( nsIElementObserver::GetIID() )) {
*aInstancePtr = (void*) ((nsIElementObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( nsIObserver::GetIID() )) {
*aInstancePtr = (void*) ((nsIObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( nsIMetaCharsetService::GetIID() )) {
*aInstancePtr = (void*) ((nsIMetaCharsetService*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( kISupportsIID )) {
*aInstancePtr = (void*) ( this );
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP_(const char*) nsMetaCharsetObserver::GetTagNameAt(PRUint32 aTagIndex) NS_IMETHODIMP_(const char*) nsMetaCharsetObserver::GetTagNameAt(PRUint32 aTagIndex)

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

@ -32,6 +32,7 @@
#include "nsCharDetDll.h" #include "nsCharDetDll.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsObserverBase.h" #include "nsObserverBase.h"
#include "nsWeakReference.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@ -43,7 +44,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
class nsXMLEncodingObserver: public nsIElementObserver, class nsXMLEncodingObserver: public nsIElementObserver,
public nsIObserver, public nsIObserver,
public nsObserverBase, public nsObserverBase,
public nsIXMLEncodingService { public nsIXMLEncodingService,
public nsSupportsWeakReference {
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -100,39 +102,13 @@ nsXMLEncodingObserver::~nsXMLEncodingObserver()
NS_IMPL_ADDREF ( nsXMLEncodingObserver ); NS_IMPL_ADDREF ( nsXMLEncodingObserver );
NS_IMPL_RELEASE ( nsXMLEncodingObserver ); NS_IMPL_RELEASE ( nsXMLEncodingObserver );
//------------------------------------------------------------------------- NS_INTERFACE_MAP_BEGIN(nsXMLEncodingObserver)
NS_IMETHODIMP nsXMLEncodingObserver::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_INTERFACE_MAP_ENTRY(nsIElementObserver)
{ NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIXMLEncodingService)
if( NULL == aInstancePtr) { NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
return NS_ERROR_NULL_POINTER; NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIElementObserver)
} NS_INTERFACE_MAP_END
*aInstancePtr = NULL;
if( aIID.Equals ( nsIElementObserver::GetIID() )) {
*aInstancePtr = (void*) ((nsIElementObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( nsIObserver::GetIID() )) {
*aInstancePtr = (void*) ((nsIObserver*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( nsIXMLEncodingService::GetIID() )) {
*aInstancePtr = (void*) ((nsIXMLEncodingService*) this);
NS_ADDREF_THIS();
return NS_OK;
}
if( aIID.Equals ( kISupportsIID )) {
*aInstancePtr = (void*) ( this );
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_IMETHODIMP_(const char*) nsXMLEncodingObserver::GetTagNameAt(PRUint32 aTagIndex) NS_IMETHODIMP_(const char*) nsXMLEncodingObserver::GetTagNameAt(PRUint32 aTagIndex)

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

@ -240,22 +240,26 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
#ifndef XSL #ifndef XSL
NS_IMPL_ISUPPORTS3(nsXMLContentSink, NS_IMPL_ADDREF(nsXMLContentSink)
nsIXMLContentSink, NS_IMPL_RELEASE(nsXMLContentSink)
nsIContentSink,
nsIUnicharStreamLoaderObserver)
#else #else
NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink) NS_IMPL_THREADSAFE_ADDREF(nsXMLContentSink)
NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink) NS_IMPL_THREADSAFE_RELEASE(nsXMLContentSink)
NS_IMPL_QUERY_INTERFACE4(nsXMLContentSink,
nsIXMLContentSink,
nsIContentSink,
nsIObserver,
nsIUnicharStreamLoaderObserver)
#endif #endif
NS_INTERFACE_MAP_BEGIN(nsXMLContentSink)
NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink)
#ifdef XSL
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
#endif
NS_INTERFACE_MAP_ENTRY(nsIUnicharStreamLoaderObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXMLContentSink)
NS_INTERFACE_MAP_END
// nsIContentSink // nsIContentSink
NS_IMETHODIMP NS_IMETHODIMP
nsXMLContentSink::WillBuildModel(void) nsXMLContentSink::WillBuildModel(void)

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

@ -28,6 +28,7 @@
#include "nsIScrollableView.h" #include "nsIScrollableView.h"
#ifdef XSL #ifdef XSL
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsITransformMediator.h" #include "nsITransformMediator.h"
#endif #endif
#include "nsIUnicharInputStream.h" #include "nsIUnicharInputStream.h"
@ -56,6 +57,7 @@ typedef enum {
class nsXMLContentSink : public nsIXMLContentSink, class nsXMLContentSink : public nsIXMLContentSink,
#ifdef XSL #ifdef XSL
public nsIObserver, public nsIObserver,
public nsSupportsWeakReference,
#endif #endif
public nsIUnicharStreamLoaderObserver public nsIUnicharStreamLoaderObserver
{ {

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

@ -341,7 +341,7 @@ typedef struct _findAccountByKeyEntry {
NS_IMPL_ISUPPORTS2(nsMsgAccountManager, nsIMsgAccountManager, nsIObserver) NS_IMPL_ISUPPORTS3(nsMsgAccountManager, nsIMsgAccountManager, nsIObserver, nsISupportsWeakReference)
nsMsgAccountManager::nsMsgAccountManager() : nsMsgAccountManager::nsMsgAccountManager() :
m_accountsLoaded(PR_FALSE), m_accountsLoaded(PR_FALSE),

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

@ -28,6 +28,7 @@
#include "nsIPref.h" #include "nsIPref.h"
#include "nsIMsgFolderCache.h" #include "nsIMsgFolderCache.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
/* /*
* some platforms (like Windows and Mac) use a map file, because of * some platforms (like Windows and Mac) use a map file, because of
@ -61,7 +62,10 @@
#define HAVE_MOVEMAIL 1 #define HAVE_MOVEMAIL 1
#endif /* HAVE_MOVEMAIL */ #endif /* HAVE_MOVEMAIL */
class nsMsgAccountManager : public nsIMsgAccountManager, public nsIObserver class nsMsgAccountManager
: public nsIMsgAccountManager,
public nsIObserver,
public nsSupportsWeakReference
{ {
public: public:

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

@ -28,7 +28,7 @@
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID); static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
NS_IMPL_ISUPPORTS3(nsMsgBiffManager, nsIMsgBiffManager, nsIIncomingServerListener, nsIObserver) NS_IMPL_ISUPPORTS4(nsMsgBiffManager, nsIMsgBiffManager, nsIIncomingServerListener, nsIObserver, nsISupportsWeakReference)
void OnBiffTimer(nsITimer *timer, void *aBiffManager) void OnBiffTimer(nsITimer *timer, void *aBiffManager)
{ {

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

@ -32,6 +32,7 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIIncomingServerListener.h" #include "nsIIncomingServerListener.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
typedef struct { typedef struct {
nsCOMPtr<nsIMsgIncomingServer> server; nsCOMPtr<nsIMsgIncomingServer> server;
@ -39,7 +40,11 @@ typedef struct {
} nsBiffEntry; } nsBiffEntry;
class nsMsgBiffManager: public nsIMsgBiffManager, public nsIIncomingServerListener, public nsIObserver class nsMsgBiffManager
: public nsIMsgBiffManager,
public nsIIncomingServerListener,
public nsIObserver,
public nsSupportsWeakReference
{ {
public: public:
nsMsgBiffManager(); nsMsgBiffManager();

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

@ -78,31 +78,13 @@ void nsMsgRDFDataSource::Close()
NS_IMPL_ADDREF(nsMsgRDFDataSource) NS_IMPL_ADDREF(nsMsgRDFDataSource)
NS_IMPL_RELEASE(nsMsgRDFDataSource) NS_IMPL_RELEASE(nsMsgRDFDataSource)
nsresult NS_INTERFACE_MAP_BEGIN(nsMsgRDFDataSource)
nsMsgRDFDataSource::QueryInterface(const nsIID& iid, void **result) NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
{ NS_INTERFACE_MAP_ENTRY(nsIObserver)
nsresult rv = NS_NOINTERFACE; NS_INTERFACE_MAP_ENTRY(nsIMsgRDFDataSource)
if (! result) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
return NS_ERROR_NULL_POINTER; NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRDFDataSource)
NS_INTERFACE_MAP_END
void *res=nsnull;
if (iid.Equals(nsCOMTypeInfo<nsIRDFDataSource>::GetIID()) ||
iid.Equals(nsCOMTypeInfo<nsISupports>::GetIID()))
res = NS_STATIC_CAST(nsIRDFDataSource*, this);
else if(iid.Equals(nsCOMTypeInfo<nsIObserver>::GetIID()))
res = NS_STATIC_CAST(nsIObserver*, this);
else if(iid.Equals(nsCOMTypeInfo<nsIMsgRDFDataSource>::GetIID()))
res = NS_STATIC_CAST(nsIMsgRDFDataSource*, this);
if (res) {
NS_ADDREF(this);
*result = res;
rv = NS_OK;
}
return rv;
}
/* readonly attribute string URI; */ /* readonly attribute string URI; */

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

@ -33,9 +33,11 @@
#include "nsITransactionManager.h" #include "nsITransactionManager.h"
#include "nsIMsgWindow.h" #include "nsIMsgWindow.h"
#include "nsIMsgRDFDataSource.h" #include "nsIMsgRDFDataSource.h"
#include "nsWeakReference.h"
class nsMsgRDFDataSource : public nsIRDFDataSource, class nsMsgRDFDataSource : public nsIRDFDataSource,
public nsIObserver, public nsIObserver,
public nsSupportsWeakReference,
public nsIMsgRDFDataSource public nsIMsgRDFDataSource
{ {
public: public:

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

@ -58,7 +58,16 @@ nsFtpProtocolHandler::~nsFtpProtocolHandler() {
PR_LOG(gFTPLog, PR_LOG_ALWAYS, ("~nsFtpProtocolHandler() called")); PR_LOG(gFTPLog, PR_LOG_ALWAYS, ("~nsFtpProtocolHandler() called"));
} }
NS_IMPL_ISUPPORTS3(nsFtpProtocolHandler, nsIProtocolHandler, nsIConnectionCache, nsIObserver); NS_IMPL_ADDREF(nsFtpProtocolHandler)
NS_IMPL_RELEASE(nsFtpProtocolHandler)
NS_INTERFACE_MAP_BEGIN(nsFtpProtocolHandler)
NS_INTERFACE_MAP_ENTRY(nsIProtocolHandler)
NS_INTERFACE_MAP_ENTRY(nsIConnectionCache)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIProtocolHandler)
NS_INTERFACE_MAP_END
NS_METHOD NS_METHOD
nsFtpProtocolHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) nsFtpProtocolHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)

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

@ -32,6 +32,7 @@
#include "nsIThreadPool.h" #include "nsIThreadPool.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
// {25029490-F132-11d2-9588-00805F369F95} // {25029490-F132-11d2-9588-00805F369F95}
#define NS_FTPPROTOCOLHANDLER_CID \ #define NS_FTPPROTOCOLHANDLER_CID \
@ -39,7 +40,8 @@
class nsFtpProtocolHandler : public nsIProtocolHandler, class nsFtpProtocolHandler : public nsIProtocolHandler,
public nsIConnectionCache, public nsIConnectionCache,
public nsIObserver public nsIObserver,
public nsSupportsWeakReference
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS

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

@ -29,6 +29,7 @@
#include "nsString.h" #include "nsString.h"
#include "prprf.h" #include "prprf.h"
#include <iostream.h> #include <iostream.h>
#include "nsWeakReference.h"
static nsIObserverService *anObserverService = NULL; static nsIObserverService *anObserverService = NULL;
@ -48,7 +49,7 @@ extern ostream &operator<<( ostream &s, nsString &str ) {
return s; return s;
} }
class TestObserver : public nsIObserver { class TestObserver : public nsIObserver, public nsSupportsWeakReference {
public: public:
TestObserver( const nsString &name = "unknown" ) TestObserver( const nsString &name = "unknown" )
: mName( name ) { : mName( name ) {
@ -60,7 +61,7 @@ public:
nsString mName; nsString mName;
}; };
NS_IMPL_ISUPPORTS( TestObserver, NS_GET_IID(nsIObserver) ); NS_IMPL_ISUPPORTS2( TestObserver, nsIObserver, nsISupportsWeakReference );
NS_IMETHODIMP NS_IMETHODIMP
TestObserver::Observe( nsISupports *aSubject, TestObserver::Observe( nsISupports *aSubject,

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

@ -30,6 +30,7 @@
#include "nsIEventQueueService.h" #include "nsIEventQueueService.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsXPComFactory.h" /* template implementation of a XPCOM factory */ #include "nsXPComFactory.h" /* template implementation of a XPCOM factory */
#include "nsITimer.h" #include "nsITimer.h"
@ -103,7 +104,8 @@ static char *gEQActivatedNotification = "nsIEventQueueActivated";
static char *gEQDestroyedNotification = "nsIEventQueueDestroyed"; static char *gEQDestroyedNotification = "nsIEventQueueDestroyed";
class nsAppShellService : public nsIAppShellService, class nsAppShellService : public nsIAppShellService,
public nsIObserver public nsIObserver,
public nsSupportsWeakReference
{ {
public: public:
nsAppShellService(void); nsAppShellService(void);
@ -173,7 +175,15 @@ nsAppShellService::~nsAppShellService()
/* /*
* Implement the nsISupports methods... * Implement the nsISupports methods...
*/ */
NS_IMPL_ISUPPORTS2(nsAppShellService, nsIAppShellService, nsIObserver); NS_IMPL_ADDREF(nsAppShellService)
NS_IMPL_RELEASE(nsAppShellService)
NS_INTERFACE_MAP_BEGIN(nsAppShellService)
NS_INTERFACE_MAP_ENTRY(nsIAppShellService)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAppShellService)
NS_INTERFACE_MAP_END
NS_IMETHODIMP NS_IMETHODIMP

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

@ -165,16 +165,17 @@ nsBrowserAppCore::~nsBrowserAppCore()
NS_IF_RELEASE(mSHistory); NS_IF_RELEASE(mSHistory);
} }
NS_IMPL_ADDREF(nsBrowserAppCore) NS_IMPL_ADDREF(nsBrowserInstance)
NS_IMPL_RELEASE(nsBrowserAppCore) NS_IMPL_RELEASE(nsBrowserInstance)
NS_INTERFACE_MAP_BEGIN(nsBrowserInstance)
NS_IMPL_QUERY_HEAD(nsBrowserAppCore) NS_INTERFACE_MAP_ENTRY(nsIBrowserInstance)
NS_IMPL_QUERY_BODY(nsIBrowserInstance) NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver)
NS_IMPL_QUERY_BODY(nsIDocumentLoaderObserver) NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_IMPL_QUERY_BODY(nsIObserver) NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
NS_IMPL_QUERY_BODY(nsIURIContentListener) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_IMPL_QUERY_TAIL(nsIBrowserInstance) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
NS_INTERFACE_MAP_END
static static
@ -948,7 +949,7 @@ nsBrowserAppCore::LoadUrl(const PRUnichar *aUrl)
#ifdef DEBUG #ifdef DEBUG
#include "nsProxyObjectManager.h" #include "nsProxyObjectManager.h"
class PageCycler : public nsIObserver { class PageCycler : public nsIObserver, public nsSupportsWeakReference {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -1059,7 +1060,14 @@ protected:
nsAutoString mLastRequest; nsAutoString mLastRequest;
}; };
NS_IMPL_ISUPPORTS1(PageCycler, nsIObserver); NS_IMPL_ADDREF(PageCycler)
NS_IMPL_RELEASE(PageCycler)
NS_INTERFACE_MAP_BEGIN(PageCycler)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
NS_INTERFACE_MAP_END
#endif #endif

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

@ -28,6 +28,7 @@
#include "nscore.h" #include "nscore.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsWeakReference.h"
#include "nsString.h" #include "nsString.h"
#include "nsISupports.h" #include "nsISupports.h"
@ -60,7 +61,8 @@ class nsBrowserInstance : public nsIBrowserInstance,
public nsIDocumentLoaderObserver, public nsIDocumentLoaderObserver,
public nsIObserver, public nsIObserver,
public nsISessionHistory, public nsISessionHistory,
public nsIURIContentListener { public nsIURIContentListener,
public nsSupportsWeakReference {
public: public:
nsBrowserInstance(); nsBrowserInstance();