mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 697247: Part 1 - Use atoms instead of hashes for database IDs. r=bent
This commit is contained in:
parent
95334a6aca
commit
4ba69f30ba
@ -61,7 +61,7 @@ struct DatabaseInfoHash
|
||||
nsAutoPtr<ObjectStoreInfoHash> objectStoreHash;
|
||||
};
|
||||
|
||||
typedef nsClassHashtable<nsUint32HashKey, DatabaseInfoHash>
|
||||
typedef nsClassHashtable<nsISupportsHashKey, DatabaseInfoHash>
|
||||
DatabaseHash;
|
||||
|
||||
DatabaseHash* gDatabaseHash = nsnull;
|
||||
@ -83,8 +83,7 @@ EnumerateObjectStoreNames(const nsAString& aKey,
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
DatabaseInfo::DatabaseInfo()
|
||||
: id(0),
|
||||
nextObjectStoreId(1),
|
||||
: nextObjectStoreId(1),
|
||||
nextIndexId(1),
|
||||
runningVersionChange(false)
|
||||
{
|
||||
@ -135,7 +134,7 @@ IndexUpdateInfo::~IndexUpdateInfo()
|
||||
|
||||
// static
|
||||
bool
|
||||
DatabaseInfo::Get(PRUint32 aId,
|
||||
DatabaseInfo::Get(nsIAtom* aId,
|
||||
DatabaseInfo** aInfo)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
@ -187,7 +186,7 @@ DatabaseInfo::Put(DatabaseInfo* aInfo)
|
||||
|
||||
// static
|
||||
void
|
||||
DatabaseInfo::Remove(PRUint32 aId)
|
||||
DatabaseInfo::Remove(nsIAtom* aId)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(Get(aId, nsnull), "Don't know anything about this one!");
|
||||
@ -241,7 +240,7 @@ DatabaseInfo::ContainsStoreName(const nsAString& aName)
|
||||
|
||||
// static
|
||||
bool
|
||||
ObjectStoreInfo::Get(PRUint32 aDatabaseId,
|
||||
ObjectStoreInfo::Get(nsIAtom* aDatabaseId,
|
||||
const nsAString& aName,
|
||||
ObjectStoreInfo** aInfo)
|
||||
{
|
||||
@ -297,7 +296,7 @@ ObjectStoreInfo::Put(ObjectStoreInfo* aInfo)
|
||||
|
||||
// static
|
||||
void
|
||||
ObjectStoreInfo::Remove(PRUint32 aDatabaseId,
|
||||
ObjectStoreInfo::Remove(nsIAtom* aDatabaseId,
|
||||
const nsAString& aName)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
@ -54,23 +54,23 @@ struct DatabaseInfo
|
||||
~DatabaseInfo();
|
||||
#else
|
||||
DatabaseInfo()
|
||||
: id(0), nextObjectStoreId(1), nextIndexId(1), runningVersionChange(false)
|
||||
: nextObjectStoreId(1), nextIndexId(1), runningVersionChange(false)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
static bool Get(PRUint32 aId,
|
||||
static bool Get(nsIAtom* aId,
|
||||
DatabaseInfo** aInfo);
|
||||
|
||||
static bool Put(DatabaseInfo* aInfo);
|
||||
|
||||
static void Remove(PRUint32 aId);
|
||||
static void Remove(nsIAtom* aId);
|
||||
|
||||
bool GetObjectStoreNames(nsTArray<nsString>& aNames);
|
||||
bool ContainsStoreName(const nsAString& aName);
|
||||
|
||||
nsString name;
|
||||
PRUint64 version;
|
||||
PRUint32 id;
|
||||
nsIAtom* id;
|
||||
nsString filePath;
|
||||
PRInt64 nextObjectStoreId;
|
||||
PRInt64 nextIndexId;
|
||||
@ -106,20 +106,20 @@ struct ObjectStoreInfo
|
||||
: id(0), autoIncrement(false), databaseId(0) { }
|
||||
#endif
|
||||
|
||||
static bool Get(PRUint32 aDatabaseId,
|
||||
static bool Get(nsIAtom* aDatabaseId,
|
||||
const nsAString& aName,
|
||||
ObjectStoreInfo** aInfo);
|
||||
|
||||
static bool Put(ObjectStoreInfo* aInfo);
|
||||
|
||||
static void Remove(PRUint32 aDatabaseId,
|
||||
static void Remove(nsIAtom* aDatabaseId,
|
||||
const nsAString& aName);
|
||||
|
||||
nsString name;
|
||||
PRInt64 id;
|
||||
nsString keyPath;
|
||||
bool autoIncrement;
|
||||
PRUint32 databaseId;
|
||||
nsIAtom* databaseId;
|
||||
nsTArray<IndexInfo> indexes;
|
||||
};
|
||||
|
||||
|
@ -141,7 +141,7 @@ NS_STACK_CLASS
|
||||
class AutoRemoveObjectStore
|
||||
{
|
||||
public:
|
||||
AutoRemoveObjectStore(PRUint32 aId, const nsAString& aName)
|
||||
AutoRemoveObjectStore(nsIAtom* aId, const nsAString& aName)
|
||||
: mId(aId), mName(aName)
|
||||
{ }
|
||||
|
||||
@ -158,7 +158,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint32 mId;
|
||||
nsCOMPtr<nsIAtom> mId;
|
||||
nsString mName;
|
||||
};
|
||||
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
// nsIDOMEventTarget
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
|
||||
PRUint32 Id()
|
||||
nsIAtom* Id()
|
||||
{
|
||||
return mDatabaseId;
|
||||
}
|
||||
@ -144,7 +144,7 @@ private:
|
||||
|
||||
void OnUnlink();
|
||||
|
||||
PRUint32 mDatabaseId;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
nsString mName;
|
||||
nsString mFilePath;
|
||||
nsCString mASCIIOrigin;
|
||||
|
@ -214,7 +214,7 @@ IDBFactory::GetDirectoryForOrigin(const nsACString& aASCIIOrigin,
|
||||
// static
|
||||
nsresult
|
||||
IDBFactory::LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
||||
PRUint32 aDatabaseId,
|
||||
nsIAtom* aDatabaseId,
|
||||
PRUint64* aVersion,
|
||||
ObjectStoreInfoArray& aObjectStores)
|
||||
{
|
||||
@ -436,6 +436,9 @@ IDBFactory::Open(const nsAString& aName,
|
||||
nsRefPtr<OpenDatabaseHelper> openHelper =
|
||||
new OpenDatabaseHelper(request, aName, origin, aVersion);
|
||||
|
||||
rv = openHelper->Init();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
nsRefPtr<CheckPermissionsHelper> permissionHelper =
|
||||
new CheckPermissionsHelper(openHelper, window, aName, origin);
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
class nsIAtom;
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
||||
@ -84,7 +85,7 @@ public:
|
||||
|
||||
static nsresult
|
||||
LoadDatabaseInformation(mozIStorageConnection* aConnection,
|
||||
PRUint32 aDatabaseId,
|
||||
nsIAtom* aDatabaseId,
|
||||
PRUint64* aVersion,
|
||||
ObjectStoreInfoArray& aObjectStores);
|
||||
|
||||
|
@ -364,7 +364,7 @@ NS_STACK_CLASS
|
||||
class AutoRemoveIndex
|
||||
{
|
||||
public:
|
||||
AutoRemoveIndex(PRUint32 aDatabaseId,
|
||||
AutoRemoveIndex(nsIAtom* aDatabaseId,
|
||||
const nsAString& aObjectStoreName,
|
||||
const nsAString& aIndexName)
|
||||
: mDatabaseId(aDatabaseId), mObjectStoreName(aObjectStoreName),
|
||||
@ -392,7 +392,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint32 mDatabaseId;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
nsString mObjectStoreName;
|
||||
nsString mIndexName;
|
||||
};
|
||||
|
@ -194,7 +194,7 @@ private:
|
||||
nsString mName;
|
||||
nsString mKeyPath;
|
||||
bool mAutoIncrement;
|
||||
PRUint32 mDatabaseId;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
PRUint32 mStructuredCloneVersion;
|
||||
|
||||
nsTArray<nsRefPtr<IDBIndex> > mCreatedIndexes;
|
||||
|
@ -523,6 +523,20 @@ private:
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(OpenDatabaseHelper, nsIRunnable);
|
||||
|
||||
nsresult
|
||||
OpenDatabaseHelper::Init()
|
||||
{
|
||||
nsCString str(mASCIIOrigin);
|
||||
str.Append("*");
|
||||
str.Append(NS_ConvertUTF16toUTF8(mName));
|
||||
|
||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(str);
|
||||
NS_ENSURE_TRUE(atom, NS_ERROR_FAILURE);
|
||||
|
||||
atom.swap(mDatabaseId);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenDatabaseHelper::Dispatch(nsIEventTarget* aTarget)
|
||||
{
|
||||
@ -630,9 +644,6 @@ OpenDatabaseHelper::DoDatabaseWork()
|
||||
NS_NOTYETIMPLEMENTED("Implement me!");
|
||||
}
|
||||
|
||||
mDatabaseId = HashString(mDatabaseFilePath);
|
||||
NS_ASSERTION(mDatabaseId, "HashString gave us 0?!");
|
||||
|
||||
rv = IDBFactory::LoadDatabaseInformation(connection, mDatabaseId, &mCurrentVersion,
|
||||
mObjectStores);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
nsresult Init();
|
||||
|
||||
nsresult Dispatch(nsIEventTarget* aDatabaseThread);
|
||||
nsresult RunImmediately();
|
||||
|
||||
@ -103,13 +105,13 @@ private:
|
||||
nsString mName;
|
||||
nsCString mASCIIOrigin;
|
||||
PRUint64 mRequestedVersion;
|
||||
nsCOMPtr<nsIAtom> mDatabaseId;
|
||||
|
||||
// Out-params.
|
||||
nsTArray<nsAutoPtr<ObjectStoreInfo> > mObjectStores;
|
||||
PRUint64 mCurrentVersion;
|
||||
PRUint32 mDataVersion;
|
||||
nsString mDatabaseFilePath;
|
||||
PRUint32 mDatabaseId;
|
||||
PRInt64 mLastObjectStoreId;
|
||||
PRInt64 mLastIndexId;
|
||||
nsRefPtr<IDBDatabase> mDatabase;
|
||||
|
@ -223,7 +223,7 @@ TransactionThreadPool::FinishTransaction(IDBTransaction* aTransaction)
|
||||
// AddRef here because removing from the hash will call Release.
|
||||
nsRefPtr<IDBTransaction> transaction(aTransaction);
|
||||
|
||||
const PRUint32 databaseId = aTransaction->mDatabase->Id();
|
||||
nsIAtom* databaseId = aTransaction->mDatabase->Id();
|
||||
|
||||
DatabaseTransactionInfo* dbTransactionInfo;
|
||||
if (!mTransactionsInProgress.Get(databaseId, &dbTransactionInfo)) {
|
||||
@ -324,7 +324,7 @@ TransactionThreadPool::TransactionCanRun(IDBTransaction* aTransaction,
|
||||
NS_ASSERTION(aCanRun, "Null pointer!");
|
||||
NS_ASSERTION(aExistingQueue, "Null pointer!");
|
||||
|
||||
const PRUint32 databaseId = aTransaction->mDatabase->Id();
|
||||
nsIAtom* databaseId = aTransaction->mDatabase->Id();
|
||||
const nsTArray<nsString>& objectStoreNames = aTransaction->mObjectStoreNames;
|
||||
const PRUint16 mode = aTransaction->mMode;
|
||||
|
||||
@ -421,7 +421,7 @@ TransactionThreadPool::Dispatch(IDBTransaction* aTransaction,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const PRUint32 databaseId = aTransaction->mDatabase->Id();
|
||||
nsIAtom* databaseId = aTransaction->mDatabase->Id();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (aTransaction->mMode == IDBTransaction::VERSION_CHANGE) {
|
||||
|
@ -168,7 +168,7 @@ protected:
|
||||
|
||||
nsCOMPtr<nsIThreadPool> mThreadPool;
|
||||
|
||||
nsClassHashtable<nsUint32HashKey, DatabaseTransactionInfo>
|
||||
nsClassHashtable<nsISupportsHashKey, DatabaseTransactionInfo>
|
||||
mTransactionsInProgress;
|
||||
|
||||
nsTArray<QueuedDispatchInfo> mDelayedDispatchQueue;
|
||||
|
Loading…
Reference in New Issue
Block a user