Bug 434838 - mozStorageConnection uses nsDataHashtable when it should use nsInterfaceHashtable

This makes mozStorageConnection no longer manually AddRef and Release user
defined functions.
r=sdwilsh
r=bent
This commit is contained in:
Arpad Borsos 2008-07-08 18:38:25 -04:00
Родитель 0f40660f74
Коммит a9bfd7a480
2 изменённых файлов: 3 добавлений и 26 удалений

Просмотреть файл

@ -206,9 +206,6 @@ mozStorageConnection::Close()
if (srv != SQLITE_OK)
NS_WARNING("sqlite3_close failed. There are probably outstanding statements!");
// Release all functions
mFunctions.EnumerateRead(s_ReleaseFuncEnum, NULL);
mDBConn = NULL;
return ConvertResultCode(srv);
}
@ -508,15 +505,6 @@ mozStorageConnection::s_FindFuncEnum(const nsACString &aKey,
return PL_DHASH_NEXT;
}
PLDHashOperator
mozStorageConnection::s_ReleaseFuncEnum(const nsACString &aKey,
nsISupports* aData,
void* userArg)
{
NS_RELEASE(aData);
return PL_DHASH_NEXT;
}
PRBool
mozStorageConnection::FindFunctionByInstance(nsISupports *aInstance)
{
@ -676,8 +664,6 @@ mozStorageConnection::CreateFunction(const nsACString &aFunctionName,
}
if (mFunctions.Put (aFunctionName, aFunction)) {
// We hold function object -- add ref to it
NS_ADDREF(aFunction);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
@ -759,8 +745,6 @@ mozStorageConnection::CreateAggregateFunction(const nsACString &aFunctionName,
}
if (mFunctions.Put (aFunctionName, aFunction)) {
// We hold function object -- add ref to it
NS_ADDREF(aFunction);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
@ -771,9 +755,7 @@ mozStorageConnection::RemoveFunction(const nsACString &aFunctionName)
{
if (!mDBConn) return NS_ERROR_NOT_INITIALIZED;
nsISupports *func;
NS_ENSURE_TRUE(mFunctions.Get (aFunctionName, &func), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mFunctions.Get (aFunctionName, NULL), NS_ERROR_FAILURE);
int srv = sqlite3_create_function (mDBConn,
nsPromiseFlatCString(aFunctionName).get(),
@ -790,9 +772,6 @@ mozStorageConnection::RemoveFunction(const nsACString &aFunctionName)
mFunctions.Remove (aFunctionName);
// We don't hold function object anymore -- remove ref to it
NS_RELEASE(func);
return NS_OK;
}

Просмотреть файл

@ -43,7 +43,7 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsDataHashtable.h"
#include "nsInterfaceHashtable.h"
#include "mozIStorageProgressHandler.h"
#include "mozIStorageConnection.h"
@ -81,8 +81,6 @@ protected:
void HandleSqliteError(const char *aSqlStatement);
static PLDHashOperator s_FindFuncEnum(const nsACString &aKey,
nsISupports* aData, void* userArg);
static PLDHashOperator s_ReleaseFuncEnum(const nsACString &aKey,
nsISupports* aData, void* userArg);
PRBool FindFunctionByInstance(nsISupports *aInstance);
static int s_ProgressHelper(void *arg);
@ -95,7 +93,7 @@ protected:
nsCOMPtr<nsIFile> mDatabaseFile;
PRBool mTransactionInProgress;
nsDataHashtable<nsCStringHashKey, nsISupports*> mFunctions;
nsInterfaceHashtable<nsCStringHashKey, nsISupports> mFunctions;
nsCOMPtr<mozIStorageProgressHandler> mProgressHandler;