зеркало из https://github.com/mozilla/gecko-dev.git
Bug 58252. Make sure that local store and internet search service match RegisterDataSource() calls with UnregisterDataSource(). Make RDFServiceImpl support weak references. r=rjc,scc; sr=alecf
This commit is contained in:
Родитель
8dc409d1f2
Коммит
4660c16995
|
@ -58,6 +58,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "plhash.h"
|
||||
#include "plstr.h"
|
||||
|
@ -94,7 +95,8 @@ static PRLogModuleInfo* gLog = nsnull;
|
|||
//
|
||||
// This is the RDF service.
|
||||
//
|
||||
class RDFServiceImpl : public nsIRDFService
|
||||
class RDFServiceImpl : public nsIRDFService,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
PLHashTable* mNamedDataSources;
|
||||
|
@ -633,10 +635,7 @@ RDFServiceImpl::GetRDFService(nsIRDFService** mgr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(RDFServiceImpl);
|
||||
NS_IMPL_THREADSAFE_RELEASE(RDFServiceImpl);
|
||||
NS_IMPL_THREADSAFE_QUERY_INTERFACE(RDFServiceImpl, kIRDFServiceIID);
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(RDFServiceImpl, nsIRDFService, nsISupportsWeakReference)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "plstr.h"
|
||||
#include "rdf.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
||||
|
||||
|
@ -49,7 +50,7 @@ class LocalStoreImpl : public nsILocalStore,
|
|||
public nsIRDFDataSource,
|
||||
public nsIRDFRemoteDataSource
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
|
||||
LocalStoreImpl();
|
||||
|
@ -61,6 +62,8 @@ private:
|
|||
|
||||
nsCOMPtr<nsISupportsArray> mObservers;
|
||||
|
||||
static nsWeakPtr gRDF;
|
||||
|
||||
public:
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -197,6 +200,8 @@ public:
|
|||
NS_IMETHOD Refresh(PRBool sync);
|
||||
};
|
||||
|
||||
nsWeakPtr LocalStoreImpl::gRDF;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -208,10 +213,9 @@ LocalStoreImpl::LocalStoreImpl(void)
|
|||
|
||||
LocalStoreImpl::~LocalStoreImpl(void)
|
||||
{
|
||||
#ifdef DEBUG_REFS
|
||||
--gInstanceCount;
|
||||
fprintf(stdout, "%d - RDF: LocalStoreImpl\n", gInstanceCount);
|
||||
#endif
|
||||
nsCOMPtr<nsIRDFService> rdf = do_QueryReferent(gRDF);
|
||||
if (rdf)
|
||||
rdf->UnregisterDataSource(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -387,9 +391,12 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// register this as a named data source with the RDF service
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
nsCOMPtr<nsIRDFService> rdf = do_GetService(kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// for later
|
||||
gRDF = getter_AddRefs(NS_GetWeakReference(rdf));
|
||||
|
||||
rv = rdf->RegisterDataSource(this, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register local store");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -521,6 +521,8 @@ InternetSearchDataSource::~InternetSearchDataSource (void)
|
|||
|
||||
if (gRDFService)
|
||||
{
|
||||
gRDFService->UnregisterDataSource(this);
|
||||
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче