Backed out changeset ecd2b45a42af (Bug 364864) due to Leak test red

This commit is contained in:
Karsten Düsterloh
2009-10-05 23:34:21 +02:00
parent 18eeeadc8d
commit b1af2f1ce4
3 changed files with 14 additions and 31 deletions

View File

@@ -283,10 +283,8 @@ CategoryNode::AddLeaf(const char* aEntryName,
PRBool aPersist,
PRBool aReplace,
char** _retval,
PLArenaPool* aArena,
PRBool* aDirty)
PLArenaPool* aArena)
{
NS_ABORT_IF_FALSE(aDirty, "CategoryNode::AddLeaf: aDirty is null");
MutexAutoLock lock(mLock);
CategoryLeaf* leaf =
mTable.GetEntry(aEntryName);
@@ -325,29 +323,25 @@ CategoryNode::AddLeaf(const char* aEntryName,
}
leaf->nonpValue = arenaValue;
if (aPersist) {
if (aPersist)
leaf->pValue = arenaValue;
*aDirty = PR_TRUE;
}
}
}
return rv;
}
NS_METHOD
CategoryNode::DeleteLeaf(const char* aEntryName,
PRBool aDontPersistAnymore,
PRBool* aDirty)
PRBool aDontPersist)
{
NS_ABORT_IF_FALSE(aDirty, "CategoryNode::DeleteLeaf: aDirty is null");
// we don't throw any errors, because it normally doesn't matter
// and it makes JS a lot cleaner
MutexAutoLock lock(mLock);
if (aDontPersistAnymore) {
if (aDontPersist) {
// we can just remove the entire hash entry without introspection
mTable.RemoveEntry(aEntryName);
*aDirty = PR_TRUE;
} else {
// if we are keeping the persistent value, we need to look at
// the contents of the current entry
@@ -603,6 +597,7 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
if (!category) {
// That category doesn't exist yet; let's make it.
category = CategoryNode::Create(&mArena);
char* categoryName = ArenaStrdup(aCategoryName, &mArena);
mTable.Put(categoryName, category);
}
@@ -613,13 +608,13 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
// We will need the return value of AddLeaf even if the called doesn't want it
char *oldEntry = nsnull;
nsresult rv = category->AddLeaf(aEntryName,
aValue,
aPersist,
aReplace,
&oldEntry,
&mArena,
&mDirty);
&mArena);
if (NS_SUCCEEDED(rv)) {
if (oldEntry) {
@@ -641,7 +636,7 @@ nsCategoryManager::AddCategoryEntry( const char *aCategoryName,
NS_IMETHODIMP
nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
const char *aEntryName,
PRBool aDontPersistAnymore)
PRBool aDontPersist)
{
NS_ENSURE_ARG_POINTER(aCategoryName);
NS_ENSURE_ARG_POINTER(aEntryName);
@@ -662,8 +657,7 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
return NS_OK;
nsresult rv = category->DeleteLeaf(aEntryName,
aDontPersistAnymore,
&mDirty);
aDontPersist);
if (NS_SUCCEEDED(rv)) {
NotifyObservers(NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID,
@@ -768,7 +762,6 @@ nsCategoryManager::WriteCategoryManagerToRegistry(PRFileDesc* fd)
return NS_ERROR_UNEXPECTED;
}
mDirty = PR_FALSE;
return NS_OK;
}

View File

@@ -88,12 +88,10 @@ public:
PRBool aPersist,
PRBool aReplace,
char** _retval,
PLArenaPool* aArena,
PRBool* aDirty);
PLArenaPool* aArena);
NS_METHOD DeleteLeaf(const char* aEntryName,
PRBool aDontPersist,
PRBool* aDirty);
PRBool aDontPersist);
void Clear() {
mozilla::MutexAutoLock lock(mLock);
@@ -152,16 +150,9 @@ public:
*/
NS_METHOD SuppressNotifications(PRBool aSuppress);
/**
* Do we have persistable category changes?
* This is to be used by nsComponentManagerImpl::Shutdown ONLY.
*/
inline PRBool IsDirty() { return mDirty; }
nsCategoryManager()
: mLock("nsCategoryManager")
, mSuppressNotifications(PR_FALSE)
, mDirty(PR_FALSE)
{ }
private:
@@ -179,7 +170,6 @@ private:
nsClassHashtable<nsDepCharHashKey, CategoryNode> mTable;
mozilla::Mutex mLock;
PRBool mSuppressNotifications;
PRBool mDirty;
};
#endif

View File

@@ -715,8 +715,8 @@ nsresult nsComponentManagerImpl::Shutdown(void)
// Shutdown the component manager
PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning Shutdown."));
// Write out our component data file, if dirty.
if (mRegistryDirty || mCategoryManager->IsDirty()) {
// Write out our component data file.
if (mRegistryDirty) {
nsresult rv = WritePersistentRegistry();
if (NS_FAILED(rv)) {
PR_LOG(nsComponentManagerLog, PR_LOG_ERROR, ("nsComponentManager: Could not write out persistent registry."));