зеркало из 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::nsBookmarksService() :
|
||||
mInner(nsnull),
|
||||
mUpdateBatchNest(0),
|
||||
mDirty(PR_FALSE)
|
||||
|
||||
|
@ -1615,7 +1614,6 @@ nsBookmarksService::~nsBookmarksService()
|
|||
// has probably already been destroyed
|
||||
// Flush();
|
||||
bm_ReleaseGlobals();
|
||||
NS_IF_RELEASE(mInner);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2505,44 +2503,52 @@ NS_IMETHODIMP nsBookmarksService::Observe(nsISupports *aSubject, const char *aTo
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports methods
|
||||
|
||||
NS_IMPL_ADDREF(nsBookmarksService)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsBookmarksService)
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsBookmarksService::Release()
|
||||
{
|
||||
// We need a special implementation of Release() because our mInner
|
||||
// holds a Circular References back to us.
|
||||
NS_PRECONDITION(PRInt32(mRefCnt) > 0, "duplicate release");
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsBookmarksService");
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsBookmarksService)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mInner)
|
||||
// Skip busyResource?
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mObservers)
|
||||
// Skip mBundle?
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTimer)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNetService)
|
||||
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) {
|
||||
nsIRDFDataSource* tmp = mInner;
|
||||
mInner = nsnull;
|
||||
NS_IF_RELEASE(tmp);
|
||||
return 0;
|
||||
}
|
||||
else if (mRefCnt == 0) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return mRefCnt;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE10(nsBookmarksService,
|
||||
nsIBookmarksService,
|
||||
nsIRDFDataSource,
|
||||
nsIRDFRemoteDataSource,
|
||||
nsIRDFPropagatableDataSource,
|
||||
nsIRDFObserver,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsICharsetResolver,
|
||||
nsIObserver,
|
||||
nsISupportsWeakReference)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBookmarksService)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mInner)
|
||||
// Skip busyResource?
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mObservers)
|
||||
// Skip mBundle?
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTimer)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mNetService)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCacheService)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCacheSession)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTransactionManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBookmarksFile)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
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
|
||||
|
@ -5103,10 +5109,9 @@ nsBookmarksService::initDatasource()
|
|||
{
|
||||
// the profile manager might call Readbookmarks() in certain circumstances
|
||||
// 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
|
||||
nsresult rv = CallCreateInstance(kRDFInMemoryDataSourceCID, &mInner);
|
||||
nsresult rv;
|
||||
mInner = do_CreateInstance(kRDFInMemoryDataSourceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mInner->AddObserver(this);
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsICacheSession.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsICharsetResolver.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
class nsIOutputStream;
|
||||
|
||||
|
@ -79,7 +80,7 @@ class nsBookmarksService : public nsIBookmarksService,
|
|||
public nsSupportsWeakReference
|
||||
{
|
||||
protected:
|
||||
nsIRDFDataSource* mInner;
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
nsCOMPtr<nsIRDFResource> busyResource;
|
||||
nsCOMArray<nsIRDFObserver> mObservers;
|
||||
nsCOMPtr<nsIStringBundle> mBundle;
|
||||
|
@ -218,7 +219,9 @@ public:
|
|||
nsresult Init();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsBookmarksService,
|
||||
nsIBookmarksService)
|
||||
|
||||
// nsIBookmarksService
|
||||
NS_DECL_NSIBOOKMARKSSERVICE
|
||||
|
|
Загрузка…
Ссылка в новой задаче