зеркало из https://github.com/mozilla/gecko-dev.git
Cycle collect through the bookmark service. Bug 383945, r+sr=neil
This commit is contained in:
Родитель
bfa5897a0c
Коммит
ac83350950
|
@ -1588,7 +1588,6 @@ ElementArray::Clear()
|
||||||
// nsBookmarksService implementation
|
// nsBookmarksService implementation
|
||||||
|
|
||||||
nsBookmarksService::nsBookmarksService() :
|
nsBookmarksService::nsBookmarksService() :
|
||||||
mInner(nsnull),
|
|
||||||
mUpdateBatchNest(0),
|
mUpdateBatchNest(0),
|
||||||
mDirty(PR_FALSE)
|
mDirty(PR_FALSE)
|
||||||
|
|
||||||
|
@ -1615,7 +1614,6 @@ nsBookmarksService::~nsBookmarksService()
|
||||||
// has probably already been destroyed
|
// has probably already been destroyed
|
||||||
// Flush();
|
// Flush();
|
||||||
bm_ReleaseGlobals();
|
bm_ReleaseGlobals();
|
||||||
NS_IF_RELEASE(mInner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -2505,44 +2503,52 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// nsISupports methods
|
// nsISupports methods
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsBookmarksService)
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsBookmarksService)
|
||||||
|
|
||||||
NS_IMETHODIMP_(nsrefcnt)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsBookmarksService)
|
||||||
nsBookmarksService::Release()
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mInner)
|
||||||
{
|
// Skip busyResource?
|
||||||
// We need a special implementation of Release() because our mInner
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mObservers)
|
||||||
// holds a Circular References back to us.
|
// Skip mBundle?
|
||||||
NS_PRECONDITION(PRInt32(mRefCnt) > 0, "duplicate release");
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTimer)
|
||||||
--mRefCnt;
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNetService)
|
||||||
NS_LOG_RELEASE(this, mRefCnt, "nsBookmarksService");
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCacheService)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCacheSession)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTransactionManager)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBookmarksFile)
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||||
|
|
||||||
if (mInner && mRefCnt == 1) {
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBookmarksService)
|
||||||
nsIRDFDataSource* tmp = mInner;
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInner)
|
||||||
mInner = nsnull;
|
// Skip busyResource?
|
||||||
NS_IF_RELEASE(tmp);
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mObservers)
|
||||||
return 0;
|
// Skip mBundle?
|
||||||
}
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTimer)
|
||||||
else if (mRefCnt == 0) {
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNetService)
|
||||||
delete this;
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCacheService)
|
||||||
return 0;
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCacheSession)
|
||||||
}
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTransactionManager)
|
||||||
else {
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBookmarksFile)
|
||||||
return mRefCnt;
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_QUERY_INTERFACE10(nsBookmarksService,
|
|
||||||
nsIBookmarksService,
|
|
||||||
nsIRDFDataSource,
|
|
||||||
nsIRDFRemoteDataSource,
|
|
||||||
nsIRDFPropagatableDataSource,
|
|
||||||
nsIRDFObserver,
|
|
||||||
nsIStreamListener,
|
|
||||||
nsIRequestObserver,
|
|
||||||
nsICharsetResolver,
|
|
||||||
nsIObserver,
|
|
||||||
nsISupportsWeakReference)
|
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsBookmarksService,
|
||||||
|
nsIBookmarksService)
|
||||||
|
NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsBookmarksService,
|
||||||
|
nsIBookmarksService)
|
||||||
|
NS_INTERFACE_MAP_BEGIN(nsBookmarksService)
|
||||||
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIBookmarksService)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIBookmarksService)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIRDFPropagatableDataSource)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIRDFObserver)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsICharsetResolver)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||||
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||||
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsBookmarksService)
|
||||||
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// nsIBookmarksService
|
// nsIBookmarksService
|
||||||
|
@ -5103,10 +5109,9 @@ nsBookmarksService::initDatasource()
|
||||||
{
|
{
|
||||||
// the profile manager might call Readbookmarks() in certain circumstances
|
// the profile manager might call Readbookmarks() in certain circumstances
|
||||||
// so we need to forget about any previous bookmarks
|
// so we need to forget about any previous bookmarks
|
||||||
NS_IF_RELEASE(mInner);
|
|
||||||
|
|
||||||
// don't change this to an xml-ds, it will cause serious perf problems
|
// don't change this to an xml-ds, it will cause serious perf problems
|
||||||
nsresult rv = CallCreateInstance(kRDFInMemoryDataSourceCID, &mInner);
|
nsresult rv;
|
||||||
|
mInner = do_CreateInstance(kRDFInMemoryDataSourceCID, &rv);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
rv = mInner->AddObserver(this);
|
rv = mInner->AddObserver(this);
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include "nsICacheSession.h"
|
#include "nsICacheSession.h"
|
||||||
#include "nsITransactionManager.h"
|
#include "nsITransactionManager.h"
|
||||||
#include "nsICharsetResolver.h"
|
#include "nsICharsetResolver.h"
|
||||||
|
#include "nsCycleCollectionParticipant.h"
|
||||||
|
|
||||||
class nsIOutputStream;
|
class nsIOutputStream;
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ class nsBookmarksService : public nsIBookmarksService,
|
||||||
public nsSupportsWeakReference
|
public nsSupportsWeakReference
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
nsIRDFDataSource* mInner;
|
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||||
nsCOMPtr<nsIRDFResource> busyResource;
|
nsCOMPtr<nsIRDFResource> busyResource;
|
||||||
nsCOMArray<nsIRDFObserver> mObservers;
|
nsCOMArray<nsIRDFObserver> mObservers;
|
||||||
nsCOMPtr<nsIStringBundle> mBundle;
|
nsCOMPtr<nsIStringBundle> mBundle;
|
||||||
|
@ -218,7 +219,9 @@ public:
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
||||||
// nsISupports
|
// nsISupports
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsBookmarksService,
|
||||||
|
nsIBookmarksService)
|
||||||
|
|
||||||
// nsIBookmarksService
|
// nsIBookmarksService
|
||||||
NS_DECL_NSIBOOKMARKSSERVICE
|
NS_DECL_NSIBOOKMARKSSERVICE
|
||||||
|
|
Загрузка…
Ссылка в новой задаче