IndexedDB: simplify RecordIdentifier
[WebKit-https.git] / Source / WebCore / Modules / indexeddb / IDBBackingStore.cpp
index 663e352..9905d5b 100644 (file)
@@ -27,7 +27,6 @@
 #include "IDBBackingStore.h"
 
 #if ENABLE(INDEXED_DATABASE)
-#if USE(LEVELDB)
 
 #include "FileSystem.h"
 #include "HistogramSupport.h"
@@ -35,7 +34,6 @@
 #include "IDBKey.h"
 #include "IDBKeyPath.h"
 #include "IDBKeyRange.h"
-#include "IDBLevelDBBackingStore.h"
 #include "IDBLevelDBCoding.h"
 #include "IDBMetadata.h"
 #include "IDBTracing.h"
@@ -223,7 +221,7 @@ static int64_t getMaxObjectStoreId(DBOrTransaction* db, const Vector<char>& maxO
     return maxObjectStoreId;
 }
 
-IDBLevelDBBackingStore::IDBLevelDBBackingStore(const String& identifier, IDBFactoryBackendImpl* factory, PassOwnPtr<LevelDBDatabase> db)
+IDBBackingStore::IDBBackingStore(const String& identifier, IDBFactoryBackendImpl* factory, PassOwnPtr<LevelDBDatabase> db)
     : m_identifier(identifier)
     , m_factory(factory)
     , m_db(db)
@@ -231,9 +229,15 @@ IDBLevelDBBackingStore::IDBLevelDBBackingStore(const String& identifier, IDBFact
     m_factory->addIDBBackingStore(identifier, this);
 }
 
-IDBLevelDBBackingStore::~IDBLevelDBBackingStore()
+IDBBackingStore::IDBBackingStore()
 {
-    m_factory->removeIDBBackingStore(m_identifier);
+}
+
+IDBBackingStore::~IDBBackingStore()
+{
+    // Only null in tests.
+    if (m_factory)
+        m_factory->removeIDBBackingStore(m_identifier);
 
     // m_db's destructor uses m_comparator. The order of destruction is important.
     m_db.clear();
@@ -251,9 +255,9 @@ enum IDBLevelDBBackingStoreOpenResult {
     IDBLevelDBBackingStoreOpenMax,
 };
 
-PassRefPtr<IDBBackingStore> IDBLevelDBBackingStore::open(SecurityOrigin* securityOrigin, const String& pathBaseArg, const String& fileIdentifier, IDBFactoryBackendImpl* factory)
+PassRefPtr<IDBBackingStore> IDBBackingStore::open(SecurityOrigin* securityOrigin, const String& pathBaseArg, const String& fileIdentifier, IDBFactoryBackendImpl* factory)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::open");
+    IDB_TRACE("IDBBackingStore::open");
     String pathBase = pathBaseArg;
 
     OwnPtr<LevelDBComparator> comparator = adoptPtr(new Comparator());
@@ -305,7 +309,7 @@ PassRefPtr<IDBBackingStore> IDBLevelDBBackingStore::open(SecurityOrigin* securit
 
     // FIXME: Handle comparator name changes.
 
-    RefPtr<IDBLevelDBBackingStore> backingStore(adoptRef(new IDBLevelDBBackingStore(fileIdentifier, factory, db.release())));
+    RefPtr<IDBBackingStore> backingStore(adoptRef(new IDBBackingStore(fileIdentifier, factory, db.release())));
     backingStore->m_comparator = comparator.release();
 
     if (!setUpMetadata(backingStore->m_db.get(), fileIdentifier))
@@ -314,7 +318,7 @@ PassRefPtr<IDBBackingStore> IDBLevelDBBackingStore::open(SecurityOrigin* securit
     return backingStore.release();
 }
 
-Vector<String> IDBLevelDBBackingStore::getDatabaseNames()
+Vector<String> IDBBackingStore::getDatabaseNames()
 {
     Vector<String> foundNames;
     const Vector<char> startKey = DatabaseNameKey::encodeMinKeyForOrigin(m_identifier);
@@ -336,7 +340,7 @@ Vector<String> IDBLevelDBBackingStore::getDatabaseNames()
     return foundNames;
 }
 
-bool IDBLevelDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata* metadata)
+bool IDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMetadata* metadata)
 {
     const Vector<char> key = DatabaseNameKey::encode(m_identifier, name);
 
@@ -382,7 +386,7 @@ static int64_t getNewDatabaseId(LevelDBDatabase* db)
     return databaseId;
 }
 
-bool IDBLevelDBBackingStore::createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId)
+bool IDBBackingStore::createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId)
 {
     rowId = getNewDatabaseId(m_db.get());
     if (rowId < 0)
@@ -402,7 +406,7 @@ bool IDBLevelDBBackingStore::createIDBDatabaseMetaData(const String& name, const
     return true;
 }
 
-bool IDBLevelDBBackingStore::updateIDBDatabaseIntVersion(IDBBackingStore::Transaction* transaction, int64_t rowId, int64_t intVersion)
+bool IDBBackingStore::updateIDBDatabaseIntVersion(IDBBackingStore::Transaction* transaction, int64_t rowId, int64_t intVersion)
 {
     if (intVersion == IDBDatabaseMetadata::NoIntVersion)
         intVersion = IDBDatabaseMetadata::DefaultIntVersion;
@@ -411,7 +415,7 @@ bool IDBLevelDBBackingStore::updateIDBDatabaseIntVersion(IDBBackingStore::Transa
     return true;
 }
 
-bool IDBLevelDBBackingStore::updateIDBDatabaseMetaData(IDBBackingStore::Transaction* transaction, int64_t rowId, const String& version)
+bool IDBBackingStore::updateIDBDatabaseMetaData(IDBBackingStore::Transaction* transaction, int64_t rowId, const String& version)
 {
     putString(Transaction::levelDBTransactionFrom(transaction), DatabaseMetaDataKey::encode(rowId, DatabaseMetaDataKey::UserVersion), version);
     return true;
@@ -425,9 +429,9 @@ static void deleteRange(LevelDBTransaction* transaction, const Vector<char>& beg
 }
 
 
-bool IDBLevelDBBackingStore::deleteDatabase(const String& name)
+bool IDBBackingStore::deleteDatabase(const String& name)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::deleteDatabase");
+    IDB_TRACE("IDBBackingStore::deleteDatabase");
     OwnPtr<LevelDBWriteOnlyTransaction> transaction = LevelDBWriteOnlyTransaction::create(m_db.get());
 
     IDBDatabaseMetadata metadata;
@@ -461,9 +465,9 @@ static bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vec
     return true;
 }
 
-Vector<IDBObjectStoreMetadata> IDBLevelDBBackingStore::getObjectStores(int64_t databaseId)
+Vector<IDBObjectStoreMetadata> IDBBackingStore::getObjectStores(int64_t databaseId)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::getObjectStores");
+    IDB_TRACE("IDBBackingStore::getObjectStores");
     Vector<IDBObjectStoreMetadata> objectStores;
     const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0);
     const Vector<char> stopKey = ObjectStoreMetaDataKey::encodeMaxKey(databaseId);
@@ -565,10 +569,10 @@ static bool setMaxObjectStoreId(LevelDBTransaction* transaction, int64_t databas
     return true;
 }
 
-bool IDBLevelDBBackingStore::createObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
+bool IDBBackingStore::createObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::createObjectStore");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::createObjectStore");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
     if (!setMaxObjectStoreId(levelDBTransaction, databaseId, objectStoreId))
         return false;
 
@@ -594,10 +598,10 @@ bool IDBLevelDBBackingStore::createObjectStore(IDBBackingStore::Transaction* tra
     return true;
 }
 
-void IDBLevelDBBackingStore::deleteObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
+void IDBBackingStore::deleteObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::deleteObjectStore");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::deleteObjectStore");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
 
     String objectStoreName;
     getString(levelDBTransaction, ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::Name), objectStoreName);
@@ -612,10 +616,10 @@ void IDBLevelDBBackingStore::deleteObjectStore(IDBBackingStore::Transaction* tra
     clearObjectStore(transaction, databaseId, objectStoreId);
 }
 
-String IDBLevelDBBackingStore::getRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key)
+String IDBBackingStore::getRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::getRecord");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::getRecord");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
 
     const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
     Vector<char> data;
@@ -634,27 +638,6 @@ String IDBLevelDBBackingStore::getRecord(IDBBackingStore::Transaction* transacti
     return decodeString(p, data.end());
 }
 
-namespace {
-class LevelDBRecordIdentifier : public IDBBackingStore::RecordIdentifier {
-public:
-    static PassRefPtr<LevelDBRecordIdentifier> create(const Vector<char>& primaryKey, int64_t version) { return adoptRef(new LevelDBRecordIdentifier(primaryKey, version)); }
-    static PassRefPtr<LevelDBRecordIdentifier> create() { return adoptRef(new LevelDBRecordIdentifier()); }
-
-    virtual bool isValid() const { return m_primaryKey.isEmpty(); }
-    Vector<char> primaryKey() const { return m_primaryKey; }
-    void setPrimaryKey(const Vector<char>& primaryKey) { m_primaryKey = primaryKey; }
-    int64_t version() const { return m_version; }
-    void setVersion(int64_t version) { m_version = version; }
-
-private:
-    LevelDBRecordIdentifier(const Vector<char>& primaryKey, int64_t version) : m_primaryKey(primaryKey), m_version(version) { ASSERT(!primaryKey.isEmpty()); }
-    LevelDBRecordIdentifier() : m_primaryKey(), m_version(-1) { }
-
-    Vector<char> m_primaryKey; // FIXME: Make it more clear that this is the *encoded* version of the key.
-    int64_t m_version;
-};
-}
-
 static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId)
 {
     const Vector<char> lastVersionKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::LastVersion);
@@ -673,11 +656,11 @@ static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t data
     return version;
 }
 
-bool IDBLevelDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
+void IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::putRecord");
+    IDB_TRACE("IDBBackingStore::putRecord");
     ASSERT(key.isValid());
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
     int64_t version = getNewVersionNumber(levelDBTransaction, databaseId, objectStoreId);
     const Vector<char> objectStoredataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
 
@@ -690,44 +673,35 @@ bool IDBLevelDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction
     const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, key);
     levelDBTransaction->put(existsEntryKey, encodeInt(version));
 
-    LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<LevelDBRecordIdentifier*>(recordIdentifier);
-    levelDBRecordIdentifier->setPrimaryKey(encodeIDBKey(key));
-    levelDBRecordIdentifier->setVersion(version);
-    return true;
+    recordIdentifier->reset(encodeIDBKey(key), version);
 }
 
-void IDBLevelDBBackingStore::clearObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
+void IDBBackingStore::clearObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::clearObjectStore");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::clearObjectStore");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
     const Vector<char> startKey = KeyPrefix(databaseId, objectStoreId, 0).encode();
     const Vector<char> stopKey = KeyPrefix(databaseId, objectStoreId + 1, 0).encode();
 
     deleteRange(levelDBTransaction, startKey, stopKey);
 }
 
-PassRefPtr<IDBBackingStore::RecordIdentifier> IDBLevelDBBackingStore::createInvalidRecordIdentifier()
+void IDBBackingStore::deleteRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier& recordIdentifier)
 {
-    return LevelDBRecordIdentifier::create();
-}
-
-void IDBLevelDBBackingStore::deleteRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier* recordIdentifier)
-{
-    IDB_TRACE("IDBLevelDBBackingStore::deleteRecord");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    const LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<const LevelDBRecordIdentifier*>(recordIdentifier);
+    IDB_TRACE("IDBBackingStore::deleteRecord");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
 
-    const Vector<char> objectStoreDataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, levelDBRecordIdentifier->primaryKey());
+    const Vector<char> objectStoreDataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, recordIdentifier.primaryKey());
     levelDBTransaction->remove(objectStoreDataKey);
 
-    const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, levelDBRecordIdentifier->primaryKey());
+    const Vector<char> existsEntryKey = ExistsEntryKey::encode(databaseId, objectStoreId, recordIdentifier.primaryKey());
     levelDBTransaction->remove(existsEntryKey);
 }
 
 
-int64_t IDBLevelDBBackingStore::getKeyGeneratorCurrentNumber(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
+int64_t IDBBackingStore::getKeyGeneratorCurrentNumber(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
 {
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
 
     const Vector<char> keyGeneratorCurrentNumberKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::KeyGeneratorCurrentNumber);
 
@@ -767,25 +741,24 @@ int64_t IDBLevelDBBackingStore::getKeyGeneratorCurrentNumber(IDBBackingStore::Tr
     return keyGeneratorCurrentNumber;
 }
 
-bool IDBLevelDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent)
+void IDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent)
 {
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
 
     if (checkCurrent) {
         int64_t currentNumber = getKeyGeneratorCurrentNumber(transaction, databaseId, objectStoreId);
         if (newNumber <= currentNumber)
-            return true;
+            return;
     }
 
     const Vector<char> keyGeneratorCurrentNumberKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::KeyGeneratorCurrentNumber);
     putInt(levelDBTransaction, keyGeneratorCurrentNumberKey, newNumber);
-    return true;
 }
 
-bool IDBLevelDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, RecordIdentifier* foundRecordIdentifier)
+bool IDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, RecordIdentifier* foundRecordIdentifier)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::keyExistsInObjectStore");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::keyExistsInObjectStore");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
     const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
     Vector<char> data;
 
@@ -796,9 +769,7 @@ bool IDBLevelDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction
     if (!decodeVarInt(data.begin(), data.end(), version))
         return false;
 
-    LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<LevelDBRecordIdentifier*>(foundRecordIdentifier);
-    levelDBRecordIdentifier->setPrimaryKey(encodeIDBKey(key));
-    levelDBRecordIdentifier->setVersion(version);
+    foundRecordIdentifier->reset(encodeIDBKey(key), version);
     return true;
 }
 
@@ -818,9 +789,9 @@ static bool checkIndexAndMetaDataKey(const LevelDBIterator* it, const Vector<cha
 }
 
 
-Vector<IDBIndexMetadata> IDBLevelDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId)
+Vector<IDBIndexMetadata> IDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::getIndexes");
+    IDB_TRACE("IDBBackingStore::getIndexes");
     Vector<IDBIndexMetadata> indexes;
     const Vector<char> startKey = IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0);
     const Vector<char> stopKey = IndexMetaDataKey::encode(databaseId, objectStoreId + 1, 0, 0);
@@ -889,10 +860,10 @@ static bool setMaxIndexId(LevelDBTransaction* transaction, int64_t databaseId, i
     return true;
 }
 
-bool IDBLevelDBBackingStore::createIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry)
+bool IDBBackingStore::createIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::createIndex");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::createIndex");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
     if (!setMaxIndexId(levelDBTransaction, databaseId, objectStoreId, indexId))
         return false;
 
@@ -908,10 +879,10 @@ bool IDBLevelDBBackingStore::createIndex(IDBBackingStore::Transaction* transacti
     return true;
 }
 
-void IDBLevelDBBackingStore::deleteIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId)
+void IDBBackingStore::deleteIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::deleteIndex");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    IDB_TRACE("IDBBackingStore::deleteIndex");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
 
     const Vector<char> indexMetaDataStart = IndexMetaDataKey::encode(databaseId, objectStoreId, indexId, 0);
     const Vector<char> indexMetaDataEnd = IndexMetaDataKey::encodeMaxKey(databaseId, objectStoreId, indexId);
@@ -922,22 +893,20 @@ void IDBLevelDBBackingStore::deleteIndex(IDBBackingStore::Transaction* transacti
     deleteRange(levelDBTransaction, indexDataStart, indexDataEnd);
 }
 
-bool IDBLevelDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const RecordIdentifier* recordIdentifier)
+void IDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const RecordIdentifier& recordIdentifier)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::putIndexDataForRecord");
+    IDB_TRACE("IDBBackingStore::putIndexDataForRecord");
     ASSERT(key.isValid());
     ASSERT(indexId >= MinimumIndexId);
-    const LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<const LevelDBRecordIdentifier*>(recordIdentifier);
 
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    const Vector<char> indexDataKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, encodeIDBKey(key), levelDBRecordIdentifier->primaryKey());
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
+    const Vector<char> indexDataKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, encodeIDBKey(key), recordIdentifier.primaryKey());
 
     Vector<char> data;
-    data.append(encodeVarInt(levelDBRecordIdentifier->version()));
-    data.append(levelDBRecordIdentifier->primaryKey());
+    data.append(encodeVarInt(recordIdentifier.version()));
+    data.append(recordIdentifier.primaryKey());
 
     levelDBTransaction->put(indexDataKey, data);
-    return true;
 }
 
 static bool findGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, const Vector<char>& target, Vector<char>& foundKey)
@@ -968,12 +937,6 @@ static bool findGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, cons
     return true;
 }
 
-bool IDBLevelDBBackingStore::deleteIndexDataForRecord(IDBBackingStore::Transaction*, int64_t, int64_t, int64_t, const RecordIdentifier*)
-{
-    // FIXME: This isn't needed since we invalidate index data via the version number mechanism.
-    return true;
-}
-
 static bool versionExists(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t version, const Vector<char>& encodedPrimaryKey)
 {
     const Vector<char> key = ExistsEntryKey::encode(databaseId, objectStoreId, encodedPrimaryKey);
@@ -985,12 +948,12 @@ static bool versionExists(LevelDBTransaction* transaction, int64_t databaseId, i
     return decodeInt(data.begin(), data.end()) == version;
 }
 
-bool IDBLevelDBBackingStore::findKeyInIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, Vector<char>& foundEncodedPrimaryKey)
+bool IDBBackingStore::findKeyInIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, Vector<char>& foundEncodedPrimaryKey)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::findKeyInIndex");
+    IDB_TRACE("IDBBackingStore::findKeyInIndex");
     ASSERT(foundEncodedPrimaryKey.isEmpty());
 
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
     const Vector<char> leveldbKey = IndexDataKey::encode(databaseId, objectStoreId, indexId, key);
     OwnPtr<LevelDBIterator> it = levelDBTransaction->createIterator();
     it->seek(leveldbKey);
@@ -1020,9 +983,9 @@ bool IDBLevelDBBackingStore::findKeyInIndex(IDBBackingStore::Transaction* transa
     }
 }
 
-PassRefPtr<IDBKey> IDBLevelDBBackingStore::getPrimaryKeyViaIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key)
+PassRefPtr<IDBKey> IDBBackingStore::getPrimaryKeyViaIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::getPrimaryKeyViaIndex");
+    IDB_TRACE("IDBBackingStore::getPrimaryKeyViaIndex");
 
     Vector<char> foundEncodedPrimaryKey;
     if (findKeyInIndex(transaction, databaseId, objectStoreId, indexId, key, foundEncodedPrimaryKey)) {
@@ -1034,9 +997,9 @@ PassRefPtr<IDBKey> IDBLevelDBBackingStore::getPrimaryKeyViaIndex(IDBBackingStore
     return 0;
 }
 
-bool IDBLevelDBBackingStore::keyExistsInIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey)
+bool IDBBackingStore::keyExistsInIndex(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::keyExistsInIndex");
+    IDB_TRACE("IDBBackingStore::keyExistsInIndex");
 
     Vector<char> foundEncodedPrimaryKey;
     if (!findKeyInIndex(transaction, databaseId, objectStoreId, indexId, indexKey, foundEncodedPrimaryKey))
@@ -1046,64 +1009,22 @@ bool IDBLevelDBBackingStore::keyExistsInIndex(IDBBackingStore::Transaction* tran
     return true;
 }
 
-namespace {
-
-struct CursorOptions {
-    Vector<char> lowKey;
-    bool lowOpen;
-    Vector<char> highKey;
-    bool highOpen;
-    bool forward;
-    bool unique;
-};
-
-class CursorImplCommon : public IDBBackingStore::Cursor {
-public:
-    // IDBBackingStore::Cursor
-    virtual bool advance(unsigned long);
-    virtual bool continueFunction(const IDBKey* = 0, IteratorState = Seek);
-    virtual PassRefPtr<IDBKey> key() { return m_currentKey; }
-    virtual PassRefPtr<IDBKey> primaryKey() { return m_currentKey; }
-    virtual String value() = 0;
-    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() = 0;
-
-    virtual bool loadCurrentRow() = 0;
-    bool firstSeek();
-
-protected:
-    CursorImplCommon(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
-        : m_transaction(transaction)
-        , m_cursorOptions(cursorOptions)
-    {
-    }
-
-    CursorImplCommon(const CursorImplCommon* other)
-        : m_transaction(other->m_transaction)
-        , m_cursorOptions(other->m_cursorOptions)
-        , m_currentKey(other->m_currentKey)
-    {
-        if (other->m_iterator) {
-            m_iterator = m_transaction->createIterator();
+IDBBackingStore::Cursor::Cursor(const IDBBackingStore::Cursor* other)
+    : m_transaction(other->m_transaction)
+    , m_cursorOptions(other->m_cursorOptions)
+    , m_currentKey(other->m_currentKey)
+{
+    if (other->m_iterator) {
+        m_iterator = m_transaction->createIterator();
 
-            if (other->m_iterator->isValid()) {
-                m_iterator->seek(other->m_iterator->key());
-                ASSERT(m_iterator->isValid());
-            }
+        if (other->m_iterator->isValid()) {
+            m_iterator->seek(other->m_iterator->key());
+            ASSERT(m_iterator->isValid());
         }
     }
+}
 
-    virtual ~CursorImplCommon() { }
-
-    bool isPastBounds() const;
-    bool haveEnteredRange() const;
-
-    LevelDBTransaction* m_transaction;
-    CursorOptions m_cursorOptions;
-    OwnPtr<LevelDBIterator> m_iterator;
-    RefPtr<IDBKey> m_currentKey;
-};
-
-bool CursorImplCommon::firstSeek()
+bool IDBBackingStore::Cursor::firstSeek()
 {
     m_iterator = m_transaction->createIterator();
     if (m_cursorOptions.forward)
@@ -1114,7 +1035,7 @@ bool CursorImplCommon::firstSeek()
     return continueFunction(0, Ready);
 }
 
-bool CursorImplCommon::advance(unsigned long count)
+bool IDBBackingStore::Cursor::advance(unsigned long count)
 {
     while (count--) {
         if (!continueFunction())
@@ -1123,7 +1044,7 @@ bool CursorImplCommon::advance(unsigned long count)
     return true;
 }
 
-bool CursorImplCommon::continueFunction(const IDBKey* key, IteratorState nextState)
+bool IDBBackingStore::Cursor::continueFunction(const IDBKey* key, IteratorState nextState)
 {
     RefPtr<IDBKey> previousKey = m_currentKey;
 
@@ -1215,7 +1136,7 @@ bool CursorImplCommon::continueFunction(const IDBKey* key, IteratorState nextSta
     return true;
 }
 
-bool CursorImplCommon::haveEnteredRange() const
+bool IDBBackingStore::Cursor::haveEnteredRange() const
 {
     if (m_cursorOptions.forward) {
         if (m_cursorOptions.lowOpen)
@@ -1229,7 +1150,7 @@ bool CursorImplCommon::haveEnteredRange() const
     return compareIndexKeys(m_iterator->key(), m_cursorOptions.highKey) <= 0;
 }
 
-bool CursorImplCommon::isPastBounds() const
+bool IDBBackingStore::Cursor::isPastBounds() const
 {
     if (m_cursorOptions.forward) {
         if (m_cursorOptions.highOpen)
@@ -1242,9 +1163,9 @@ bool CursorImplCommon::isPastBounds() const
     return compareIndexKeys(m_iterator->key(), m_cursorOptions.lowKey) < 0;
 }
 
-class ObjectStoreKeyCursorImpl : public CursorImplCommon {
+class ObjectStoreKeyCursorImpl : public IDBBackingStore::Cursor {
 public:
-    static PassRefPtr<ObjectStoreKeyCursorImpl> create(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
+    static PassRefPtr<ObjectStoreKeyCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
     {
         return adoptRef(new ObjectStoreKeyCursorImpl(transaction, cursorOptions));
     }
@@ -1254,26 +1175,21 @@ public:
         return adoptRef(new ObjectStoreKeyCursorImpl(this));
     }
 
-    // CursorImplCommon
-    virtual String value() { ASSERT_NOT_REACHED(); return String(); }
-    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() OVERRIDE
-    {
-        return m_identifier;
-    }
+    // IDBBackingStore::Cursor
+    virtual String value() const { ASSERT_NOT_REACHED(); return String(); }
     virtual bool loadCurrentRow();
 
 private:
-    ObjectStoreKeyCursorImpl(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
-        : CursorImplCommon(transaction, cursorOptions)
+    ObjectStoreKeyCursorImpl(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
+        : IDBBackingStore::Cursor(transaction, cursorOptions)
     {
     }
 
     ObjectStoreKeyCursorImpl(const ObjectStoreKeyCursorImpl* other)
-        : CursorImplCommon(other)
+        : IDBBackingStore::Cursor(other)
     {
     }
 
-    RefPtr<LevelDBRecordIdentifier> m_identifier;
 };
 
 bool ObjectStoreKeyCursorImpl::loadCurrentRow()
@@ -1298,14 +1214,14 @@ bool ObjectStoreKeyCursorImpl::loadCurrentRow()
     }
 
     // FIXME: This re-encodes what was just decoded; try and optimize.
-    m_identifier = LevelDBRecordIdentifier::create(encodeIDBKey(*m_currentKey), version);
+    m_recordIdentifier.reset(encodeIDBKey(*m_currentKey), version);
 
     return true;
 }
 
-class ObjectStoreCursorImpl : public CursorImplCommon {
+class ObjectStoreCursorImpl : public IDBBackingStore::Cursor {
 public:
-    static PassRefPtr<ObjectStoreCursorImpl> create(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
+    static PassRefPtr<ObjectStoreCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
     {
         return adoptRef(new ObjectStoreCursorImpl(transaction, cursorOptions));
     }
@@ -1315,28 +1231,23 @@ public:
         return adoptRef(new ObjectStoreCursorImpl(this));
     }
 
-    // CursorImplCommon
-    virtual String value() { return m_currentValue; }
-    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() OVERRIDE
-    {
-        return m_identifier;
-    }
+    // IDBBackingStore::Cursor
+    virtual String value() const { return m_currentValue; }
     virtual bool loadCurrentRow();
 
 private:
-    ObjectStoreCursorImpl(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
-        : CursorImplCommon(transaction, cursorOptions)
+    ObjectStoreCursorImpl(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
+        : IDBBackingStore::Cursor(transaction, cursorOptions)
     {
     }
 
     ObjectStoreCursorImpl(const ObjectStoreCursorImpl* other)
-        : CursorImplCommon(other)
+        : IDBBackingStore::Cursor(other)
         , m_currentValue(other->m_currentValue)
     {
     }
 
     String m_currentValue;
-    RefPtr<LevelDBRecordIdentifier> m_identifier;
 };
 
 bool ObjectStoreCursorImpl::loadCurrentRow()
@@ -1361,16 +1272,16 @@ bool ObjectStoreCursorImpl::loadCurrentRow()
     }
 
     // FIXME: This re-encodes what was just decoded; try and optimize.
-    m_identifier = LevelDBRecordIdentifier::create(encodeIDBKey(*m_currentKey), version);
+    m_recordIdentifier.reset(encodeIDBKey(*m_currentKey), version);
 
     m_currentValue = decodeString(valuePosition, m_iterator->value().end());
 
     return true;
 }
 
-class IndexKeyCursorImpl : public CursorImplCommon {
+class IndexKeyCursorImpl : public IDBBackingStore::Cursor {
 public:
-    static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
+    static PassRefPtr<IndexKeyCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
     {
         return adoptRef(new IndexKeyCursorImpl(transaction, cursorOptions));
     }
@@ -1380,20 +1291,20 @@ public:
         return adoptRef(new IndexKeyCursorImpl(this));
     }
 
-    // CursorImplCommon
-    virtual String value() { ASSERT_NOT_REACHED(); return String(); }
-    virtual PassRefPtr<IDBKey> primaryKey() { return m_primaryKey; }
-    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
+    // IDBBackingStore::Cursor
+    virtual String value() const { ASSERT_NOT_REACHED(); return String(); }
+    virtual PassRefPtr<IDBKey> primaryKey() const { return m_primaryKey; }
+    virtual const IDBBackingStore::RecordIdentifier& recordIdentifier() const { ASSERT_NOT_REACHED(); return m_recordIdentifier; }
     virtual bool loadCurrentRow();
 
 private:
-    IndexKeyCursorImpl(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
-        : CursorImplCommon(transaction, cursorOptions)
+    IndexKeyCursorImpl(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
+        : IDBBackingStore::Cursor(transaction, cursorOptions)
     {
     }
 
     IndexKeyCursorImpl(const IndexKeyCursorImpl* other)
-        : CursorImplCommon(other)
+        : IDBBackingStore::Cursor(other)
         , m_primaryKey(other->m_primaryKey)
     {
     }
@@ -1447,9 +1358,9 @@ bool IndexKeyCursorImpl::loadCurrentRow()
     return true;
 }
 
-class IndexCursorImpl : public CursorImplCommon {
+class IndexCursorImpl : public IDBBackingStore::Cursor {
 public:
-    static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
+    static PassRefPtr<IndexCursorImpl> create(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
     {
         return adoptRef(new IndexCursorImpl(transaction, cursorOptions));
     }
@@ -1459,20 +1370,20 @@ public:
         return adoptRef(new IndexCursorImpl(this));
     }
 
-    // CursorImplCommon
-    virtual String value() { return m_value; }
-    virtual PassRefPtr<IDBKey> primaryKey() { return m_primaryKey; }
-    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
+    // IDBBackingStore::Cursor
+    virtual String value() const { return m_value; }
+    virtual PassRefPtr<IDBKey> primaryKey() const { return m_primaryKey; }
+    virtual const IDBBackingStore::RecordIdentifier& recordIdentifier() const { ASSERT_NOT_REACHED(); return m_recordIdentifier; }
     bool loadCurrentRow();
 
 private:
-    IndexCursorImpl(LevelDBTransaction* transaction, const CursorOptions& cursorOptions)
-        : CursorImplCommon(transaction, cursorOptions)
+    IndexCursorImpl(LevelDBTransaction* transaction, const IDBBackingStore::Cursor::CursorOptions& cursorOptions)
+        : IDBBackingStore::Cursor(transaction, cursorOptions)
     {
     }
 
     IndexCursorImpl(const IndexCursorImpl* other)
-        : CursorImplCommon(other)
+        : IDBBackingStore::Cursor(other)
         , m_primaryKey(other->m_primaryKey)
         , m_value(other->m_value)
         , m_primaryLevelDBKey(other->m_primaryLevelDBKey)
@@ -1533,7 +1444,7 @@ bool IndexCursorImpl::loadCurrentRow()
     return true;
 }
 
-bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction, CursorOptions& cursorOptions)
+bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction, IDBBackingStore::Cursor::CursorOptions& cursorOptions)
 {
     bool lowerBound = range && range->lower();
     bool upperBound = range && range->upper();
@@ -1580,7 +1491,7 @@ bool objectStoreCursorOptions(LevelDBTransaction* transaction, int64_t databaseI
     return true;
 }
 
-bool indexCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction, CursorOptions& cursorOptions)
+bool indexCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction, IDBBackingStore::Cursor::CursorOptions& cursorOptions)
 {
     ASSERT(transaction);
     bool lowerBound = range && range->lower();
@@ -1623,13 +1534,11 @@ bool indexCursorOptions(LevelDBTransaction* transaction, int64_t databaseId, int
     return true;
 }
 
-}
-
-PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openObjectStoreCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction)
+PassRefPtr<IDBBackingStore::Cursor> IDBBackingStore::openObjectStoreCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::openObjectStoreCursor");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    CursorOptions cursorOptions;
+    IDB_TRACE("IDBBackingStore::openObjectStoreCursor");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
+    IDBBackingStore::Cursor::CursorOptions cursorOptions;
     if (!objectStoreCursorOptions(levelDBTransaction, databaseId, objectStoreId, range, direction, cursorOptions))
         return 0;
     RefPtr<ObjectStoreCursorImpl> cursor = ObjectStoreCursorImpl::create(levelDBTransaction, cursorOptions);
@@ -1639,11 +1548,11 @@ PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openObjectStoreCurso
     return cursor.release();
 }
 
-PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openObjectStoreKeyCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction)
+PassRefPtr<IDBBackingStore::Cursor> IDBBackingStore::openObjectStoreKeyCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::openObjectStoreKeyCursor");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    CursorOptions cursorOptions;
+    IDB_TRACE("IDBBackingStore::openObjectStoreKeyCursor");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
+    IDBBackingStore::Cursor::CursorOptions cursorOptions;
     if (!objectStoreCursorOptions(levelDBTransaction, databaseId, objectStoreId, range, direction, cursorOptions))
         return 0;
     RefPtr<ObjectStoreKeyCursorImpl> cursor = ObjectStoreKeyCursorImpl::create(levelDBTransaction, cursorOptions);
@@ -1653,11 +1562,11 @@ PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openObjectStoreKeyCu
     return cursor.release();
 }
 
-PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openIndexKeyCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)
+PassRefPtr<IDBBackingStore::Cursor> IDBBackingStore::openIndexKeyCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::openIndexKeyCursor");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    CursorOptions cursorOptions;
+    IDB_TRACE("IDBBackingStore::openIndexKeyCursor");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
+    IDBBackingStore::Cursor::CursorOptions cursorOptions;
     if (!indexCursorOptions(levelDBTransaction, databaseId, objectStoreId, indexId, range, direction, cursorOptions))
         return 0;
     RefPtr<IndexKeyCursorImpl> cursor = IndexKeyCursorImpl::create(levelDBTransaction, cursorOptions);
@@ -1667,11 +1576,11 @@ PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openIndexKeyCursor(I
     return cursor.release();
 }
 
-PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openIndexCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)
+PassRefPtr<IDBBackingStore::Cursor> IDBBackingStore::openIndexCursor(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange* range, IDBCursor::Direction direction)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::openIndexCursor");
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    CursorOptions cursorOptions;
+    IDB_TRACE("IDBBackingStore::openIndexCursor");
+    LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
+    IDBBackingStore::Cursor::CursorOptions cursorOptions;
     if (!indexCursorOptions(levelDBTransaction, databaseId, objectStoreId, indexId, range, direction, cursorOptions))
         return 0;
     RefPtr<IndexCursorImpl> cursor = IndexCursorImpl::create(levelDBTransaction, cursorOptions);
@@ -1681,60 +1590,35 @@ PassRefPtr<IDBBackingStore::Cursor> IDBLevelDBBackingStore::openIndexCursor(IDBB
     return cursor.release();
 }
 
-PassRefPtr<IDBBackingStore::Transaction> IDBLevelDBBackingStore::createTransaction()
-{
-    return Transaction::create(this);
-}
-
-PassRefPtr<IDBLevelDBBackingStore::Transaction> IDBLevelDBBackingStore::Transaction::create(IDBLevelDBBackingStore* backingStore)
-{
-    return adoptRef(new Transaction(backingStore));
-}
-
-IDBLevelDBBackingStore::Transaction::Transaction(IDBLevelDBBackingStore* backingStore)
+IDBBackingStore::Transaction::Transaction(IDBBackingStore* backingStore)
     : m_backingStore(backingStore)
 {
 }
 
-void IDBLevelDBBackingStore::Transaction::begin()
+void IDBBackingStore::Transaction::begin()
 {
-    IDB_TRACE("IDBLevelDBBackingStore::Transaction::begin");
+    IDB_TRACE("IDBBackingStore::Transaction::begin");
     ASSERT(!m_transaction);
     m_transaction = LevelDBTransaction::create(m_backingStore->m_db.get());
 }
 
-bool IDBLevelDBBackingStore::Transaction::commit()
+bool IDBBackingStore::Transaction::commit()
 {
-    IDB_TRACE("IDBLevelDBBackingStore::Transaction::commit");
+    IDB_TRACE("IDBBackingStore::Transaction::commit");
     ASSERT(m_transaction);
     bool result = m_transaction->commit();
     m_transaction.clear();
     return result;
 }
 
-void IDBLevelDBBackingStore::Transaction::rollback()
+void IDBBackingStore::Transaction::rollback()
 {
-    IDB_TRACE("IDBLevelDBBackingStore::Transaction::rollback");
+    IDB_TRACE("IDBBackingStore::Transaction::rollback");
     ASSERT(m_transaction);
     m_transaction->rollback();
     m_transaction.clear();
 }
 
-bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String&, const String& pathBaseArg)
-{
-    String pathBase = pathBaseArg;
-
-    if (pathBase.isEmpty())
-        return false;
-
-    // FIXME: We should eventually use the same LevelDB database for all origins.
-    String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb");
-
-    // FIXME: this is checking for presence of the domain, not the database itself
-    return fileExists(path+"/CURRENT");
-}
-
 } // namespace WebCore
 
-#endif // USE(LEVELDB)
 #endif // ENABLE(INDEXED_DATABASE)