Backing out Bug 383939. All RDF datasources must implement cycle collection to avoid leaking.
authorsayrer@gmail.com
Wed, 23 Jan 2008 14:07:47 -0800
changeset 10593 63b7065506c802cdb49cc4cc5963d3edb5d33000
parent 10592 cc8b120149e3f84a8b507f59da78e0b061b2180c
child 10594 59241a8ce76e1fa8feb35e4f6dc58f1e16f12718
push idunknown
push userunknown
push dateunknown
bugs383939
milestone1.9b3pre
Backing out Bug 383939. All RDF datasources must implement cycle collection to avoid leaking.
content/xul/document/src/nsXULDocument.cpp
rdf/datasource/src/nsFileSystemDataSource.cpp
rdf/datasource/src/nsFileSystemDataSource.h
rdf/datasource/src/nsLocalStore.cpp
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -340,19 +340,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
                                                      nsIScriptGlobalObjectOwner)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCommandDispatcher,
                                                      nsIDOMXULCommandDispatcher)
 
     PRUint32 i, count = tmp->mPrototypes.Length();
     for (i = 0; i < count; ++i) {
         cb.NoteXPCOMChild(static_cast<nsIScriptGlobalObjectOwner*>(tmp->mPrototypes[i]));
     }
-
+    
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTooltipNode)
-    NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLocalStore)
 
     if (tmp->mOverlayLoadObservers.IsInitialized())
         tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb);
     if (tmp->mPendingOverlayLoadNotifications.IsInitialized())
         tmp->mPendingOverlayLoadNotifications.EnumerateRead(TraverseObservers, &cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsXULDocument, nsXMLDocument)
--- a/rdf/datasource/src/nsFileSystemDataSource.cpp
+++ b/rdf/datasource/src/nsFileSystemDataSource.cpp
@@ -246,22 +246,17 @@ FileSystemDataSource::Create(nsISupports
         return NS_ERROR_OUT_OF_MEMORY;
      
     nsresult rv = self->Init();
     NS_ENSURE_SUCCESS(rv, rv);
 
     return self->QueryInterface(aIID, aResult);
 }
 
-NS_IMPL_CYCLE_COLLECTION_0(FileSystemDataSource) 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemDataSource)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemDataSource)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemDataSource)
-    NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
-NS_INTERFACE_MAP_END
+NS_IMPL_ISUPPORTS1(FileSystemDataSource, nsIRDFDataSource)
 
 NS_IMETHODIMP
 FileSystemDataSource::GetURI(char **uri)
 {
     NS_PRECONDITION(uri != nsnull, "null ptr");
     if (! uri)
         return NS_ERROR_NULL_POINTER;
 
--- a/rdf/datasource/src/nsFileSystemDataSource.h
+++ b/rdf/datasource/src/nsFileSystemDataSource.h
@@ -41,27 +41,25 @@
 
 #include "nsIRDFDataSource.h"
 #include "nsIRDFLiteral.h"
 #include "nsIRDFResource.h"
 #include "nsIRDFService.h"
 #include "nsISupportsArray.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
-#include "nsCycleCollectionParticipant.h"
 
 #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN) || defined(XP_BEOS)
 #define USE_NC_EXTENSION
 #endif
 
 class FileSystemDataSource : public nsIRDFDataSource
 {
 public:
-    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS(FileSystemDataSource)
+    NS_DECL_ISUPPORTS
     NS_DECL_NSIRDFDATASOURCE
 
     static NS_METHOD Create(nsISupports* aOuter,
                             const nsIID& aIID, void **aResult);
 
     ~FileSystemDataSource() { }
     nsresult Init();
 
--- a/rdf/datasource/src/nsLocalStore.cpp
+++ b/rdf/datasource/src/nsLocalStore.cpp
@@ -61,17 +61,16 @@
 #include "nsWeakPtr.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsWeakReference.h"
 #include "nsCRTGlue.h"
 #include "nsCRT.h"
 #include "nsEnumeratorUtils.h"
-#include "nsCycleCollectionParticipant.h"
 
 ////////////////////////////////////////////////////////////////////////
 
 class LocalStoreImpl : public nsILocalStore,
                        public nsIRDFDataSource,
                        public nsIRDFRemoteDataSource,
                        public nsIObserver,
                        public nsSupportsWeakReference
@@ -87,18 +86,17 @@ protected:
 
     friend NS_IMETHODIMP
     NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
     nsCOMPtr<nsIRDFService>    mRDFService;
 
 public:
     // nsISupports interface
-    NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
+    NS_DECL_ISUPPORTS
 
     // nsILocalStore interface
 
     // nsIRDFDataSource interface. Most of these are just delegated to
     // the inner, in-memory datasource.
     NS_IMETHOD GetURI(char* *aURI);
 
     NS_IMETHOD GetSource(nsIRDFResource* aProperty,
@@ -210,23 +208,23 @@ public:
         return mInner->BeginUpdateBatch();
     }
                                                                                 
     NS_IMETHOD EndUpdateBatch() {
         return mInner->EndUpdateBatch();
     }
 
     NS_IMETHOD GetLoaded(PRBool* _result);
-    NS_IMETHOD Init(const char *uri);
-    NS_IMETHOD Flush();
-    NS_IMETHOD FlushTo(const char *aURI);
-    NS_IMETHOD Refresh(PRBool sync);
-
-    // nsIObserver
-    NS_DECL_NSIOBSERVER
+	NS_IMETHOD Init(const char *uri);
+	NS_IMETHOD Flush();
+	NS_IMETHOD FlushTo(const char *aURI);
+	NS_IMETHOD Refresh(PRBool sync);
+	
+	// nsIObserver
+	NS_DECL_NSIOBSERVER
 };
 
 ////////////////////////////////////////////////////////////////////////
 
 
 LocalStoreImpl::LocalStoreImpl(void)
 {
 }
@@ -261,31 +259,61 @@ NS_NewLocalStore(nsISupports* aOuter, RE
         // Set up the result pointer
         rv = impl->QueryInterface(aIID, aResult);
     }
 
     NS_RELEASE(impl);
     return rv;
 }
 
-NS_IMPL_CYCLE_COLLECTION_1(LocalStoreImpl, mInner)
-NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
-NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
+
+// nsISupports interface
+
+NS_IMPL_ADDREF(LocalStoreImpl)
+NS_IMPL_RELEASE(LocalStoreImpl)
+
+NS_IMETHODIMP
+LocalStoreImpl::QueryInterface(REFNSIID aIID, void** aResult)
+{
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+
+    NS_PRECONDITION(aResult != nsnull, "null ptr");
+    if (! aResult)
+        return NS_ERROR_NULL_POINTER;
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(LocalStoreImpl)
-    NS_INTERFACE_MAP_ENTRY(nsILocalStore)
-    NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
-    NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource)
-    NS_INTERFACE_MAP_ENTRY(nsIObserver)
-    NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsILocalStore)
-NS_INTERFACE_MAP_END
+    if (aIID.Equals(kISupportsIID) ||
+        aIID.Equals(NS_GET_IID(nsILocalStore))) {
+        *aResult = static_cast<nsILocalStore*>(this);
+    }
+    else if (aIID.Equals(NS_GET_IID(nsIRDFDataSource))) {
+        *aResult = static_cast<nsIRDFDataSource *>(this);
+    }
+    else if (aIID.Equals(NS_GET_IID(nsIRDFRemoteDataSource))) {
+        *aResult = static_cast<nsIRDFRemoteDataSource *>(this);
+    }
+    else if (aIID.Equals(NS_GET_IID(nsIObserver))) {
+        *aResult = static_cast<nsIObserver *>(this);
+    }
+    else if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference))) {
+        *aResult = static_cast<nsISupportsWeakReference *>(this);
+    }
+    else {
+        *aResult = nsnull;
+        return NS_NOINTERFACE;
+    }
+
+    NS_ADDREF(this);
+    return NS_OK;
+}
+
 
 // nsILocalStore interface
 
+
+
 // nsIRDFDataSource interface
 
 NS_IMETHODIMP
 LocalStoreImpl::GetLoaded(PRBool* _result)
 {
 	nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(mInner);
     NS_ASSERTION(remote != nsnull, "not an nsIRDFRemoteDataSource");
 	if (! remote)