IndexedDB: Allow createIndex/createObjectStore to be asynchronous
authoralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 07:33:14 +0000 (07:33 +0000)
committeralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jan 2013 07:33:14 +0000 (07:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106377

Reviewed by Tony Chang.

Source/WebCore:

Migrate implementations of createIndex/deleteIndex,
createObjectStore/deleteObjectStore over to IDBDatabaseBackendImpl,
so that they can be asynchronous in multi-process ports.

Has the side effect of removing the last consumers of
IDBIndexBackendImpl and IDBObjectStoreBackendImpl. The former
is removed complete and the latter becomes a temporary namespace
pending a further more mechanical code shuffle.

A key refactoring effect is that the IDBDatabaseBackendImpl
now contains the authoritative IDBDatabaseMetadata hierarchy,
and updates to it are consolidated in one place rather than
scattered across a parallel object tree.

No new tests as this is just refactoring.

* Modules/indexeddb/IDBBackingStore.cpp: Simplify objectstore/index loading and propagate errors.
(WebCore::IDBBackingStore::getObjectStores):
(WebCore::IDBBackingStore::getIndexes):
* Modules/indexeddb/IDBBackingStore.h:
(IDBBackingStore):
* Modules/indexeddb/IDBCursorBackendImpl.cpp: Dependency cleanup.
* Modules/indexeddb/IDBCursorBackendImpl.h: Dependency cleanup.
(WebCore):
* Modules/indexeddb/IDBDatabase.cpp: Frontend IDBObjectStores no longer hold onto backend objects.
(WebCore::IDBDatabase::createObjectStore):
(WebCore::IDBDatabase::deleteObjectStore):
* Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Add all create/deleteIndex operations from IDBIndexBackendImpl.
(WebCore::CreateObjectStoreOperation::create):
(WebCore::CreateObjectStoreOperation::CreateObjectStoreOperation):
(CreateObjectStoreOperation):
(WebCore::DeleteObjectStoreOperation::create):
(WebCore::DeleteObjectStoreOperation::DeleteObjectStoreOperation):
(DeleteObjectStoreOperation):
(WebCore::CreateObjectStoreAbortOperation::create):
(WebCore::CreateObjectStoreAbortOperation::CreateObjectStoreAbortOperation):
(CreateObjectStoreAbortOperation):
(WebCore::DeleteObjectStoreAbortOperation::create):
(WebCore::DeleteObjectStoreAbortOperation::DeleteObjectStoreAbortOperation):
(DeleteObjectStoreAbortOperation):
(CreateIndexOperation):
(WebCore::CreateIndexOperation::create):
(WebCore::CreateIndexOperation::CreateIndexOperation):
(WebCore):
(DeleteIndexOperation):
(WebCore::DeleteIndexOperation::create):
(WebCore::DeleteIndexOperation::DeleteIndexOperation):
(CreateIndexAbortOperation):
(WebCore::CreateIndexAbortOperation::create):
(WebCore::CreateIndexAbortOperation::CreateIndexAbortOperation):
(DeleteIndexAbortOperation):
(WebCore::DeleteIndexAbortOperation::create):
(WebCore::DeleteIndexAbortOperation::DeleteIndexAbortOperation):
(WebCore::GetOperation::GetOperation):
(WebCore::IDBDatabaseBackendImpl::addObjectStore):
(WebCore::IDBDatabaseBackendImpl::removeObjectStore):
(WebCore::IDBDatabaseBackendImpl::addIndex):
(WebCore::IDBDatabaseBackendImpl::removeIndex):
(WebCore::IDBDatabaseBackendImpl::openInternal):
(WebCore::IDBDatabaseBackendImpl::metadata):
(WebCore::IDBDatabaseBackendImpl::createObjectStore):
(WebCore::CreateObjectStoreOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteObjectStore):
(WebCore::IDBDatabaseBackendImpl::createIndex):
(WebCore::CreateIndexOperation::perform):
(WebCore::CreateIndexAbortOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteIndex):
(WebCore::DeleteIndexOperation::perform):
(WebCore::DeleteIndexAbortOperation::perform):
(WebCore::IDBDatabaseBackendImpl::get):
(WebCore::IDBDatabaseBackendImpl::put):
(WebCore::IDBDatabaseBackendImpl::setIndexKeys):
(WebCore::IDBDatabaseBackendImpl::count):
(WebCore::DeleteRangeOperation::perform):
(WebCore::DeleteObjectStoreOperation::perform):
(WebCore::IDBDatabaseBackendImpl::deleteDatabaseFinal):
(WebCore::IDBDatabaseBackendImpl::loadObjectStores): Load directly into metadata from backing store.
(WebCore::CreateObjectStoreAbortOperation::perform):
(WebCore::DeleteObjectStoreAbortOperation::perform):
(WebCore::IDBDatabaseBackendImpl::VersionChangeAbortOperation::perform):
* Modules/indexeddb/IDBDatabaseBackendImpl.h:
(WebCore):
(IDBDatabaseBackendImpl):
(WebCore::IDBDatabaseBackendImpl::createObjectStore):
(WebCore::IDBDatabaseBackendImpl::deleteObjectStore):
* Modules/indexeddb/IDBIndexBackendImpl.cpp: Removed.
* Modules/indexeddb/IDBIndexBackendImpl.h: Removed.
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::IDBObjectStore): Frontend IDBIndex objects no longer hold onto backend.
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::deleteIndex):
* Modules/indexeddb/IDBObjectStore.h:
(WebCore::IDBObjectStore::create):
(IDBObjectStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
* Modules/indexeddb/IDBObjectStoreBackendImpl.h:
(WebCore):
(IDBObjectStoreBackendImpl):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::objectStore):
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/IDBTransactionBackendImpl.cpp:
* Modules/indexeddb/IDBTransactionBackendImpl.h:
(WebCore::IDBTransactionBackendImpl::objectStore):
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit/chromium:

Remove this test as it makes no sense once the objectstore/index
hierarchy is gone.

* tests/IDBDatabaseBackendTest.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139289 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp [deleted file]
Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h [deleted file]
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.h
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
Source/WebKit/chromium/tests/IDBFakeBackingStore.h

index 5124545..b7fca7e 100644 (file)
@@ -826,7 +826,6 @@ set(WebCore_SOURCES
     Modules/indexeddb/IDBFactoryBackendImpl.cpp
     Modules/indexeddb/IDBFactoryBackendInterface.cpp
     Modules/indexeddb/IDBIndex.cpp
-    Modules/indexeddb/IDBIndexBackendImpl.cpp
     Modules/indexeddb/IDBKey.cpp
     Modules/indexeddb/IDBKeyRange.cpp
     Modules/indexeddb/IDBKeyPath.cpp
index 6d51cbc..13a4349 100644 (file)
@@ -1,3 +1,118 @@
+2013-01-09  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Allow createIndex/createObjectStore to be asynchronous
+        https://bugs.webkit.org/show_bug.cgi?id=106377
+
+        Reviewed by Tony Chang.
+
+        Migrate implementations of createIndex/deleteIndex,
+        createObjectStore/deleteObjectStore over to IDBDatabaseBackendImpl,
+        so that they can be asynchronous in multi-process ports.
+
+        Has the side effect of removing the last consumers of
+        IDBIndexBackendImpl and IDBObjectStoreBackendImpl. The former
+        is removed complete and the latter becomes a temporary namespace
+        pending a further more mechanical code shuffle.
+
+        A key refactoring effect is that the IDBDatabaseBackendImpl
+        now contains the authoritative IDBDatabaseMetadata hierarchy,
+        and updates to it are consolidated in one place rather than
+        scattered across a parallel object tree.
+
+        No new tests as this is just refactoring.
+
+        * Modules/indexeddb/IDBBackingStore.cpp: Simplify objectstore/index loading and propagate errors.
+        (WebCore::IDBBackingStore::getObjectStores):
+        (WebCore::IDBBackingStore::getIndexes):
+        * Modules/indexeddb/IDBBackingStore.h:
+        (IDBBackingStore):
+        * Modules/indexeddb/IDBCursorBackendImpl.cpp: Dependency cleanup.
+        * Modules/indexeddb/IDBCursorBackendImpl.h: Dependency cleanup.
+        (WebCore):
+        * Modules/indexeddb/IDBDatabase.cpp: Frontend IDBObjectStores no longer hold onto backend objects.
+        (WebCore::IDBDatabase::createObjectStore):
+        (WebCore::IDBDatabase::deleteObjectStore):
+        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Add all create/deleteIndex operations from IDBIndexBackendImpl.
+        (WebCore::CreateObjectStoreOperation::create):
+        (WebCore::CreateObjectStoreOperation::CreateObjectStoreOperation):
+        (CreateObjectStoreOperation):
+        (WebCore::DeleteObjectStoreOperation::create):
+        (WebCore::DeleteObjectStoreOperation::DeleteObjectStoreOperation):
+        (DeleteObjectStoreOperation):
+        (WebCore::CreateObjectStoreAbortOperation::create):
+        (WebCore::CreateObjectStoreAbortOperation::CreateObjectStoreAbortOperation):
+        (CreateObjectStoreAbortOperation):
+        (WebCore::DeleteObjectStoreAbortOperation::create):
+        (WebCore::DeleteObjectStoreAbortOperation::DeleteObjectStoreAbortOperation):
+        (DeleteObjectStoreAbortOperation):
+        (CreateIndexOperation):
+        (WebCore::CreateIndexOperation::create):
+        (WebCore::CreateIndexOperation::CreateIndexOperation):
+        (WebCore):
+        (DeleteIndexOperation):
+        (WebCore::DeleteIndexOperation::create):
+        (WebCore::DeleteIndexOperation::DeleteIndexOperation):
+        (CreateIndexAbortOperation):
+        (WebCore::CreateIndexAbortOperation::create):
+        (WebCore::CreateIndexAbortOperation::CreateIndexAbortOperation):
+        (DeleteIndexAbortOperation):
+        (WebCore::DeleteIndexAbortOperation::create):
+        (WebCore::DeleteIndexAbortOperation::DeleteIndexAbortOperation):
+        (WebCore::GetOperation::GetOperation):
+        (WebCore::IDBDatabaseBackendImpl::addObjectStore):
+        (WebCore::IDBDatabaseBackendImpl::removeObjectStore):
+        (WebCore::IDBDatabaseBackendImpl::addIndex):
+        (WebCore::IDBDatabaseBackendImpl::removeIndex):
+        (WebCore::IDBDatabaseBackendImpl::openInternal):
+        (WebCore::IDBDatabaseBackendImpl::metadata):
+        (WebCore::IDBDatabaseBackendImpl::createObjectStore):
+        (WebCore::CreateObjectStoreOperation::perform):
+        (WebCore::IDBDatabaseBackendImpl::deleteObjectStore):
+        (WebCore::IDBDatabaseBackendImpl::createIndex):
+        (WebCore::CreateIndexOperation::perform):
+        (WebCore::CreateIndexAbortOperation::perform):
+        (WebCore::IDBDatabaseBackendImpl::deleteIndex):
+        (WebCore::DeleteIndexOperation::perform):
+        (WebCore::DeleteIndexAbortOperation::perform):
+        (WebCore::IDBDatabaseBackendImpl::get):
+        (WebCore::IDBDatabaseBackendImpl::put):
+        (WebCore::IDBDatabaseBackendImpl::setIndexKeys):
+        (WebCore::IDBDatabaseBackendImpl::count):
+        (WebCore::DeleteRangeOperation::perform):
+        (WebCore::DeleteObjectStoreOperation::perform):
+        (WebCore::IDBDatabaseBackendImpl::deleteDatabaseFinal):
+        (WebCore::IDBDatabaseBackendImpl::loadObjectStores): Load directly into metadata from backing store.
+        (WebCore::CreateObjectStoreAbortOperation::perform):
+        (WebCore::DeleteObjectStoreAbortOperation::perform):
+        (WebCore::IDBDatabaseBackendImpl::VersionChangeAbortOperation::perform):
+        * Modules/indexeddb/IDBDatabaseBackendImpl.h:
+        (WebCore):
+        (IDBDatabaseBackendImpl):
+        (WebCore::IDBDatabaseBackendImpl::createObjectStore):
+        (WebCore::IDBDatabaseBackendImpl::deleteObjectStore):
+        * Modules/indexeddb/IDBIndexBackendImpl.cpp: Removed.
+        * Modules/indexeddb/IDBIndexBackendImpl.h: Removed.
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::IDBObjectStore): Frontend IDBIndex objects no longer hold onto backend.
+        (WebCore::IDBObjectStore::createIndex): 
+        (WebCore::IDBObjectStore::deleteIndex):
+        * Modules/indexeddb/IDBObjectStore.h:
+        (WebCore::IDBObjectStore::create):
+        (IDBObjectStore):
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.h:
+        (WebCore):
+        (IDBObjectStoreBackendImpl):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::objectStore):
+        * Modules/indexeddb/IDBTransaction.h:
+        * Modules/indexeddb/IDBTransactionBackendImpl.cpp:
+        * Modules/indexeddb/IDBTransactionBackendImpl.h:
+        (WebCore::IDBTransactionBackendImpl::objectStore):
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2013-01-09  John J. Barton  <johnjbarton@chromium.org>
 
         Web Inspector: Don't throw exceptions when we don't have a callstack
index 02259c4..2028d90 100644 (file)
@@ -1873,8 +1873,6 @@ webcore_modules_sources += \
        Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h \
        Source/WebCore/Modules/indexeddb/IDBFactory.cpp \
        Source/WebCore/Modules/indexeddb/IDBFactory.h \
-       Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp \
-       Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h \
        Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h \
        Source/WebCore/Modules/indexeddb/IDBIndex.cpp \
        Source/WebCore/Modules/indexeddb/IDBIndex.h \
index 202f050..da48499 100644 (file)
@@ -605,13 +605,15 @@ static bool checkObjectStoreAndMetaDataType(const LevelDBIterator* it, const Vec
     return true;
 }
 
-Vector<IDBObjectStoreMetadata> IDBBackingStore::getObjectStores(int64_t databaseId)
+// FIXME: This should do some error handling rather than plowing ahead when bad data is encountered.
+void IDBBackingStore::getObjectStores(int64_t databaseId, IDBDatabaseMetadata::ObjectStoreMap* objectStores)
 {
     IDB_TRACE("IDBBackingStore::getObjectStores");
-    Vector<IDBObjectStoreMetadata> objectStores;
     const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0);
     const Vector<char> stopKey = ObjectStoreMetaDataKey::encodeMaxKey(databaseId);
 
+    ASSERT(objectStores->isEmpty());
+
     OwnPtr<LevelDBIterator> it = m_db->createIterator();
     it->seek(startKey);
     while (it->isValid() && compareKeys(it->key(), stopKey) < 0) {
@@ -691,9 +693,10 @@ Vector<IDBObjectStoreMetadata> IDBBackingStore::getObjectStores(int64_t database
             it->next();
         }
 
-        objectStores.append(IDBObjectStoreMetadata(objectStoreName, objectStoreId, keyPath, autoIncrement, maxIndexId));
+        IDBObjectStoreMetadata metadata(objectStoreName, objectStoreId, keyPath, autoIncrement, maxIndexId);
+        getIndexes(databaseId, objectStoreId, &metadata.indexes);
+        objectStores->set(objectStoreId, metadata);
     }
-    return objectStores;
 }
 
 WARN_UNUSED_RETURN static bool setMaxObjectStoreId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId)
@@ -979,14 +982,14 @@ static bool checkIndexAndMetaDataKey(const LevelDBIterator* it, const Vector<cha
 }
 
 
-Vector<IDBIndexMetadata> IDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId)
+// FIXME: This should do some error handling rather than plowing ahead when bad data is encountered.
+void IDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId, IDBObjectStoreMetadata::IndexMap* indexes)
 {
     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);
 
-    ASSERT(indexes.isEmpty());
+    ASSERT(indexes->isEmpty());
 
     OwnPtr<LevelDBIterator> it = m_db->createIterator();
     it->seek(startKey);
@@ -1029,9 +1032,8 @@ Vector<IDBIndexMetadata> IDBBackingStore::getIndexes(int64_t databaseId, int64_t
             it->next();
         }
 
-        indexes.append(IDBIndexMetadata(indexName, indexId, keyPath, indexUnique, indexMultiEntry));
+        indexes->set(indexId, IDBIndexMetadata(indexName, indexId, keyPath, indexUnique, indexMultiEntry));
     }
-    return indexes;
 }
 
 WARN_UNUSED_RETURN static bool setMaxIndexId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId)
index 2f99ca3..66b72f4 100644 (file)
@@ -58,7 +58,7 @@ public:
     virtual bool updateIDBDatabaseIntVersion(IDBBackingStore::Transaction*, int64_t rowId, int64_t intVersion);
     virtual bool deleteDatabase(const String& name);
 
-    virtual Vector<IDBObjectStoreMetadata> getObjectStores(int64_t databaseId);
+    void getObjectStores(int64_t databaseId, IDBDatabaseMetadata::ObjectStoreMap*);
     virtual bool createObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement);
     virtual bool deleteObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId) WARN_UNUSED_RETURN;
 
@@ -85,7 +85,6 @@ public:
     virtual bool maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent) WARN_UNUSED_RETURN;
     virtual bool keyExistsInObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier, bool& found) WARN_UNUSED_RETURN;
 
-    virtual Vector<IDBIndexMetadata> getIndexes(int64_t databaseId, int64_t objectStoreId);
     virtual bool createIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry);
     virtual void deleteIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId);
     virtual void putIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier&);
@@ -169,6 +168,7 @@ protected:
 
 private:
     bool findKeyInIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, Vector<char>& foundEncodedPrimaryKey, bool& found);
+    void getIndexes(int64_t databaseId, int64_t objectStoreId, IDBObjectStoreMetadata::IndexMap*);
 
     String m_identifier;
     RefPtr<IDBFactoryBackendImpl> m_factory;
index feab5c5..64c4aab 100644 (file)
 
 #include "IDBBackingStore.h"
 #include "IDBCallbacks.h"
+#include "IDBDatabaseBackendImpl.h"
 #include "IDBDatabaseError.h"
 #include "IDBDatabaseException.h"
 #include "IDBKeyRange.h"
-#include "IDBObjectStoreBackendImpl.h"
 #include "IDBRequest.h"
 #include "IDBTracing.h"
 #include "IDBTransactionBackendImpl.h"
index 9668dfd..712c2b4 100644 (file)
@@ -41,9 +41,7 @@
 namespace WebCore {
 
 class IDBDatabaseBackendImpl;
-class IDBIndexBackendImpl;
 class IDBKeyRange;
-class IDBObjectStoreBackendImpl;
 
 class IDBCursorBackendImpl : public IDBCursorBackendInterface {
 public:
index ebde0f1..74646d0 100644 (file)
@@ -184,14 +184,10 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
     }
 
     int64_t objectStoreId = m_metadata.maxObjectStoreId + 1;
-    RefPtr<IDBObjectStoreBackendInterface> objectStoreBackend = m_backend->createObjectStore(objectStoreId, name, keyPath, autoIncrement, m_versionChangeTransaction->backend(), ec);
-    if (!objectStoreBackend) {
-        ASSERT(ec);
-        return 0;
-    }
+    m_backend->createObjectStore(m_versionChangeTransaction->id(), objectStoreId, name, keyPath, autoIncrement);
 
     IDBObjectStoreMetadata metadata(name, objectStoreId, keyPath, autoIncrement, IDBObjectStoreBackendInterface::MinimumIndexId);
-    RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, objectStoreBackend.release(), m_versionChangeTransaction.get());
+    RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata, m_versionChangeTransaction.get());
     m_metadata.objectStores.set(metadata.id, metadata);
     ++m_metadata.maxObjectStoreId;
 
@@ -216,11 +212,9 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionCode& ec)
         return;
     }
 
-    m_backend->deleteObjectStore(objectStoreId, m_versionChangeTransaction->backend(), ec);
-    if (!ec) {
-        m_versionChangeTransaction->objectStoreDeleted(name);
-        m_metadata.objectStores.remove(objectStoreId);
-    }
+    m_backend->deleteObjectStore(m_versionChangeTransaction->id(), objectStoreId);
+    m_versionChangeTransaction->objectStoreDeleted(name);
+    m_metadata.objectStores.remove(objectStoreId);
 }
 
 PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* context, const Vector<String>& scope, const String& modeString, ExceptionCode& ec)
index 0d1ddb0..92c918c 100644 (file)
@@ -32,7 +32,6 @@
 #include "IDBCursorBackendImpl.h"
 #include "IDBDatabaseException.h"
 #include "IDBFactoryBackendImpl.h"
-#include "IDBIndexBackendImpl.h"
 #include "IDBObjectStoreBackendImpl.h"
 #include "IDBTracing.h"
 #include "IDBTransactionBackendImpl.h"
 
 namespace WebCore {
 
-class IDBDatabaseBackendImpl::CreateObjectStoreOperation : public IDBTransactionBackendImpl::Operation {
+class CreateObjectStoreOperation : public IDBTransactionBackendImpl::Operation {
 public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBBackingStore> backingStore, const IDBObjectStoreMetadata& objectStoreMetadata)
     {
-        return adoptPtr(new CreateObjectStoreOperation(database, objectStore));
+        return adoptPtr(new CreateObjectStoreOperation(backingStore, objectStoreMetadata));
     }
     virtual void perform(IDBTransactionBackendImpl*);
 private:
-    CreateObjectStoreOperation(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
-        : m_database(database)
-        , m_objectStore(objectStore)
+    CreateObjectStoreOperation(PassRefPtr<IDBBackingStore> backingStore, const IDBObjectStoreMetadata& objectStoreMetadata)
+        : m_backingStore(backingStore)
+        , m_objectStoreMetadata(objectStoreMetadata)
     {
     }
 
-    RefPtr<IDBDatabaseBackendImpl> m_database;
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
+    const RefPtr<IDBBackingStore> m_backingStore;
+    const IDBObjectStoreMetadata m_objectStoreMetadata;
 };
 
-class IDBDatabaseBackendImpl::DeleteObjectStoreOperation : public IDBTransactionBackendImpl::Operation {
+class DeleteObjectStoreOperation : public IDBTransactionBackendImpl::Operation {
 public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBBackingStore> backingStore, const IDBObjectStoreMetadata& objectStoreMetadata)
     {
-        return adoptPtr(new DeleteObjectStoreOperation(database, objectStore));
+        return adoptPtr(new DeleteObjectStoreOperation(backingStore, objectStoreMetadata));
     }
     virtual void perform(IDBTransactionBackendImpl*);
 private:
-    DeleteObjectStoreOperation(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
-        : m_database(database)
-        , m_objectStore(objectStore)
+    DeleteObjectStoreOperation(PassRefPtr<IDBBackingStore> backingStore, const IDBObjectStoreMetadata& objectStoreMetadata)
+        : m_backingStore(backingStore)
+        , m_objectStoreMetadata(objectStoreMetadata)
     {
     }
 
-    RefPtr<IDBDatabaseBackendImpl> m_database;
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
+    const RefPtr<IDBBackingStore> m_backingStore;
+    const IDBObjectStoreMetadata m_objectStoreMetadata;
 };
 
 class IDBDatabaseBackendImpl::VersionChangeOperation : public IDBTransactionBackendImpl::Operation {
@@ -100,40 +99,40 @@ private:
     RefPtr<IDBDatabaseCallbacks> m_databaseCallbacks;
 };
 
-class IDBDatabaseBackendImpl::CreateObjectStoreAbortOperation : public IDBTransactionBackendImpl::Operation {
+class CreateObjectStoreAbortOperation : public IDBTransactionBackendImpl::Operation {
 public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, int64_t objectStoreId)
     {
-        return adoptPtr(new CreateObjectStoreAbortOperation(database, objectStore));
+        return adoptPtr(new CreateObjectStoreAbortOperation(database, objectStoreId));
     }
     virtual void perform(IDBTransactionBackendImpl*);
 private:
-    CreateObjectStoreAbortOperation(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
+    CreateObjectStoreAbortOperation(PassRefPtr<IDBDatabaseBackendImpl> database, int64_t objectStoreId)
         : m_database(database)
-        , m_objectStore(objectStore)
+        , m_objectStoreId(objectStoreId)
     {
     }
 
-    RefPtr<IDBDatabaseBackendImpl> m_database;
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
+    const RefPtr<IDBDatabaseBackendImpl> m_database;
+    const int64_t m_objectStoreId;
 };
 
-class IDBDatabaseBackendImpl::DeleteObjectStoreAbortOperation : public IDBTransactionBackendImpl::Operation {
+class DeleteObjectStoreAbortOperation : public IDBTransactionBackendImpl::Operation {
 public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, const IDBObjectStoreMetadata& objectStore)
     {
         return adoptPtr(new DeleteObjectStoreAbortOperation(database, objectStore));
     }
     virtual void perform(IDBTransactionBackendImpl*);
 private:
-    DeleteObjectStoreAbortOperation(PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore)
+    DeleteObjectStoreAbortOperation(PassRefPtr<IDBDatabaseBackendImpl> database, const IDBObjectStoreMetadata& objectStoreMetadata)
         : m_database(database)
-        , m_objectStore(objectStore)
+        , m_objectStoreMetadata(objectStoreMetadata)
     {
     }
 
     RefPtr<IDBDatabaseBackendImpl> m_database;
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
+    IDBObjectStoreMetadata m_objectStoreMetadata;
 };
 
 class IDBDatabaseBackendImpl::VersionChangeAbortOperation : public IDBTransactionBackendImpl::Operation {
@@ -156,6 +155,86 @@ private:
     int64_t m_previousIntVersion;
 };
 
+class CreateIndexOperation : public IDBTransactionBackendImpl::Operation {
+public:
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBBackingStore> backingStore, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata)
+    {
+        return adoptPtr(new CreateIndexOperation(backingStore, objectStoreId, indexMetadata));
+    }
+    virtual void perform(IDBTransactionBackendImpl*);
+private:
+    CreateIndexOperation(PassRefPtr<IDBBackingStore> backingStore, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata)
+        : m_backingStore(backingStore)
+        , m_objectStoreId(objectStoreId)
+        , m_indexMetadata(indexMetadata)
+    {
+    }
+
+    const RefPtr<IDBBackingStore> m_backingStore;
+    const int64_t m_objectStoreId;
+    const IDBIndexMetadata m_indexMetadata;
+};
+
+class DeleteIndexOperation : public IDBTransactionBackendImpl::Operation {
+public:
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBBackingStore> backingStore, int64_t objectStoreId, int64_t indexId)
+    {
+        return adoptPtr(new DeleteIndexOperation(backingStore, objectStoreId, indexId));
+    }
+    virtual void perform(IDBTransactionBackendImpl*);
+private:
+    DeleteIndexOperation(PassRefPtr<IDBBackingStore> backingStore, int64_t objectStoreId, int64_t indexId)
+        : m_backingStore(backingStore)
+        , m_objectStoreId(objectStoreId)
+        , m_indexId(indexId)
+    {
+    }
+
+    const RefPtr<IDBBackingStore> m_backingStore;
+    const int64_t m_objectStoreId;
+    const int64_t m_indexId;
+};
+
+class CreateIndexAbortOperation : public IDBTransactionBackendImpl::Operation {
+public:
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, int64_t objectStoreId, int64_t indexId)
+    {
+        return adoptPtr(new CreateIndexAbortOperation(database, objectStoreId, indexId));
+    }
+    virtual void perform(IDBTransactionBackendImpl*);
+private:
+    CreateIndexAbortOperation(PassRefPtr<IDBDatabaseBackendImpl> database, int64_t objectStoreId, int64_t indexId)
+        : m_database(database)
+        , m_objectStoreId(objectStoreId)
+        , m_indexId(indexId)
+    {
+    }
+
+    const RefPtr<IDBDatabaseBackendImpl> m_database;
+    const int64_t m_objectStoreId;
+    const int64_t m_indexId;
+};
+
+class DeleteIndexAbortOperation : public IDBTransactionBackendImpl::Operation {
+public:
+    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBDatabaseBackendImpl> database, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata)
+    {
+        return adoptPtr(new DeleteIndexAbortOperation(database, objectStoreId, indexMetadata));
+    }
+    virtual void perform(IDBTransactionBackendImpl*);
+private:
+    DeleteIndexAbortOperation(PassRefPtr<IDBDatabaseBackendImpl> database, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata)
+        : m_database(database)
+        , m_objectStoreId(objectStoreId)
+        , m_indexMetadata(indexMetadata)
+    {
+    }
+
+    const RefPtr<IDBDatabaseBackendImpl> m_database;
+    const int64_t m_objectStoreId;
+    const IDBIndexMetadata m_indexMetadata;
+};
+
 class GetOperation : public IDBTransactionBackendImpl::Operation {
 public:
     static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBBackingStore> backingStore, const IDBDatabaseMetadata& metadata, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange> keyRange, IDBCursorBackendInterface::CursorType cursorType, PassRefPtr<IDBCallbacks> callbacks)
@@ -175,6 +254,7 @@ private:
         , m_cursorType(cursorType)
         , m_callbacks(callbacks)
     {
+        ASSERT(metadata.objectStores.contains(objectStoreId));
         ASSERT(metadata.objectStores.get(objectStoreId).id == objectStoreId);
     }
 
@@ -405,6 +485,46 @@ IDBDatabaseBackendImpl::IDBDatabaseBackendImpl(const String& name, IDBBackingSto
     ASSERT(!m_metadata.name.isNull());
 }
 
+void IDBDatabaseBackendImpl::addObjectStore(const IDBObjectStoreMetadata& objectStore, int64_t newMaxObjectStoreId)
+{
+    ASSERT(!m_metadata.objectStores.contains(objectStore.id));
+    if (newMaxObjectStoreId != IDBObjectStoreMetadata::InvalidId) {
+        ASSERT(m_metadata.maxObjectStoreId < newMaxObjectStoreId);
+        m_metadata.maxObjectStoreId = newMaxObjectStoreId;
+    }
+    m_metadata.objectStores.set(objectStore.id, objectStore);
+}
+
+void IDBDatabaseBackendImpl::removeObjectStore(int64_t objectStoreId)
+{
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    m_metadata.objectStores.remove(objectStoreId);
+}
+
+void IDBDatabaseBackendImpl::addIndex(int64_t objectStoreId, const IDBIndexMetadata& index, int64_t newMaxIndexId)
+{
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId);
+
+    ASSERT(!objectStore.indexes.contains(index.id));
+    objectStore.indexes.set(index.id, index);
+    if (newMaxIndexId != IDBIndexMetadata::InvalidId) {
+        ASSERT(objectStore.maxIndexId < newMaxIndexId);
+        objectStore.maxIndexId = newMaxIndexId;
+    }
+    m_metadata.objectStores.set(objectStoreId, objectStore);
+}
+
+void IDBDatabaseBackendImpl::removeIndex(int64_t objectStoreId, int64_t indexId)
+{
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId);
+
+    ASSERT(objectStore.indexes.contains(indexId));
+    objectStore.indexes.remove(indexId);
+    m_metadata.objectStores.set(objectStoreId, objectStore);
+}
+
 bool IDBDatabaseBackendImpl::openInternal()
 {
     bool success = false;
@@ -413,7 +533,7 @@ bool IDBDatabaseBackendImpl::openInternal()
     if (!ok)
         return false;
     if (success) {
-        loadObjectStores();
+        m_backingStore->getObjectStores(m_metadata.id, &m_metadata.objectStores);
         return true;
     }
     return m_backingStore->createIDBDatabaseMetaData(m_metadata.name, m_metadata.version, m_metadata.intVersion, m_metadata.id);
@@ -430,64 +550,112 @@ PassRefPtr<IDBBackingStore> IDBDatabaseBackendImpl::backingStore() const
 
 IDBDatabaseMetadata IDBDatabaseBackendImpl::metadata() const
 {
-    // FIXME: Figure out a way to keep m_metadata.objectStores.get(N).indexes up to date rather than regenerating this every time.
-    IDBDatabaseMetadata metadata(m_metadata);
-    for (ObjectStoreMap::const_iterator it = m_objectStores.begin(); it != m_objectStores.end(); ++it)
-        metadata.objectStores.set(it->value->id(), it->value->metadata());
-    return metadata;
+    return m_metadata;
 }
 
-PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(int64_t id, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
+void IDBDatabaseBackendImpl::createObjectStore(int64_t transactionId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
 {
-    ASSERT(!m_objectStores.contains(id));
-
-    RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, IDBObjectStoreMetadata(name, id, keyPath, autoIncrement, IDBObjectStoreBackendInterface::MinimumIndexId));
-    ASSERT(objectStore->name() == name);
+    IDB_TRACE("IDBDatabaseBackendImpl::createObjectStore");
+    ASSERT(!m_metadata.objectStores.contains(objectStoreId));
 
-    RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
-    ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
+    ASSERT(m_transactions.contains(transactionId));
+    IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
 
-    // FIXME: Fix edge cases around transaction aborts that prevent this from just being ASSERT(id == m_metadata.maxObjectStoreId + 1)
-    ASSERT(id > m_metadata.maxObjectStoreId);
-    m_metadata.maxObjectStoreId = id;
+    IDBObjectStoreMetadata objectStoreMetadata(name, objectStoreId, keyPath, autoIncrement, IDBObjectStoreBackendInterface::MinimumIndexId);
 
-    if (!transaction->scheduleTask(CreateObjectStoreOperation::create(this, objectStore), CreateObjectStoreAbortOperation::create(this, objectStore))) {
-        ec = IDBDatabaseException::TransactionInactiveError;
-        return 0;
-    }
+    transaction->scheduleTask(CreateObjectStoreOperation::create(m_backingStore, objectStoreMetadata), CreateObjectStoreAbortOperation::create(this, objectStoreId));
 
-    m_objectStores.set(id, objectStore);
-    return objectStore.release();
+    addObjectStore(objectStoreMetadata, objectStoreId);
 }
 
-void IDBDatabaseBackendImpl::CreateObjectStoreOperation::perform(IDBTransactionBackendImpl* transaction)
+void CreateObjectStoreOperation::perform(IDBTransactionBackendImpl* transaction)
 {
     IDB_TRACE("CreateObjectStoreOperation");
-    if (!m_database->m_backingStore->createObjectStore(transaction->backingStoreTransaction(), m_database->id(), m_objectStore->id(), m_objectStore->name(), m_objectStore->keyPath(), m_objectStore->autoIncrement())) {
-        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error creating object store '%s'.", m_objectStore->name().utf8().data()));
+    if (!m_backingStore->createObjectStore(transaction->backingStoreTransaction(), transaction->database()->id(), m_objectStoreMetadata.id, m_objectStoreMetadata.name, m_objectStoreMetadata.keyPath, m_objectStoreMetadata.autoIncrement)) {
+        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error creating object store '%s'.", m_objectStoreMetadata.name.utf8().data()));
         transaction->abort(error.release());
         return;
     }
 }
 
-PassRefPtr<IDBObjectStoreBackendImpl> IDBDatabaseBackendImpl::objectStore(int64_t id)
+void IDBDatabaseBackendImpl::deleteObjectStore(int64_t transactionId, int64_t objectStoreId)
 {
-    return m_objectStores.get(id);
+    IDB_TRACE("IDBDatabaseBackendImpl::deleteObjectStore");
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    const IDBObjectStoreMetadata& objectStoreMetadata = m_metadata.objectStores.get(objectStoreId);
+
+    ASSERT(m_transactions.contains(transactionId));
+    IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
+    ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
+
+    transaction->scheduleTask(DeleteObjectStoreOperation::create(m_backingStore, objectStoreMetadata),  DeleteObjectStoreAbortOperation::create(this, objectStoreMetadata));
+    removeObjectStore(objectStoreId);
 }
 
-void IDBDatabaseBackendImpl::deleteObjectStore(int64_t id, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
+void IDBDatabaseBackendImpl::createIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry)
 {
-    ASSERT(m_objectStores.contains(id));
+    IDB_TRACE("IDBDatabaseBackendImpl::createIndex");
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    const IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId);
 
-    RefPtr<IDBObjectStoreBackendImpl> objectStore = m_objectStores.get(id);
-    RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
+    ASSERT(!objectStore.indexes.contains(indexId));
+    const IDBIndexMetadata indexMetadata(name, indexId, keyPath, unique, multiEntry);
+
+    ASSERT(m_transactions.contains(transactionId));
+    IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
     ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
 
-    if (!transaction->scheduleTask(DeleteObjectStoreOperation::create(this, objectStore), DeleteObjectStoreAbortOperation::create(this, objectStore))) {
-        ec = IDBDatabaseException::TransactionInactiveError;
+    transaction->scheduleTask(CreateIndexOperation::create(m_backingStore, objectStoreId, indexMetadata), CreateIndexAbortOperation::create(this, objectStoreId, indexId));
+
+    addIndex(objectStoreId, indexMetadata, indexId);
+}
+
+
+void CreateIndexOperation::perform(IDBTransactionBackendImpl* transaction)
+{
+    IDB_TRACE("CreateIndexOperation");
+    if (!m_backingStore->createIndex(transaction->backingStoreTransaction(), transaction->database()->id(), m_objectStoreId, m_indexMetadata.id, m_indexMetadata.name, m_indexMetadata.keyPath, m_indexMetadata.unique, m_indexMetadata.multiEntry)) {
+        transaction->abort(IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error when trying to create index '%s'.", m_indexMetadata.name.utf8().data())));
         return;
     }
-    m_objectStores.remove(id);
+}
+
+void CreateIndexAbortOperation::perform(IDBTransactionBackendImpl* transaction)
+{
+    IDB_TRACE("CreateIndexAbortOperation");
+    ASSERT(!transaction);
+    m_database->removeIndex(m_objectStoreId, m_indexId);
+}
+
+void IDBDatabaseBackendImpl::deleteIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId)
+{
+    IDB_TRACE("IDBDatabaseBackendImpl::deleteIndex");
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    const IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId);
+
+    ASSERT(objectStore.indexes.contains(indexId));
+    const IDBIndexMetadata& indexMetadata = objectStore.indexes.get(indexId);
+
+    ASSERT(m_transactions.contains(transactionId));
+    IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
+    ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
+
+    transaction->scheduleTask(DeleteIndexOperation::create(m_backingStore, objectStoreId, indexId), DeleteIndexAbortOperation::create(this, objectStoreId, indexMetadata));
+
+    removeIndex(objectStoreId, indexId);
+}
+
+void DeleteIndexOperation::perform(IDBTransactionBackendImpl* transaction)
+{
+    IDB_TRACE("DeleteIndexOperation");
+    m_backingStore->deleteIndex(transaction->backingStoreTransaction(), transaction->database()->id(), m_objectStoreId, m_indexId);
+}
+
+void DeleteIndexAbortOperation::perform(IDBTransactionBackendImpl* transaction)
+{
+    IDB_TRACE("DeleteIndexAbortOperation");
+    ASSERT(!transaction);
+    m_database->addIndex(m_objectStoreId, m_indexMetadata, IDBIndexMetadata::InvalidId);
 }
 
 void IDBDatabaseBackendImpl::commit(int64_t transactionId)
@@ -508,7 +676,7 @@ void IDBDatabaseBackendImpl::get(int64_t transactionId, int64_t objectStoreId, i
     ASSERT(m_transactions.contains(transactionId));
     IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
 
-    transaction->scheduleTask(GetOperation::create(m_backingStore, metadata(), objectStoreId, indexId, keyRange, keyOnly ? IDBCursorBackendInterface::KeyOnly : IDBCursorBackendInterface::KeyAndValue, callbacks));
+    transaction->scheduleTask(GetOperation::create(m_backingStore, m_metadata, objectStoreId, indexId, keyRange, keyOnly ? IDBCursorBackendInterface::KeyOnly : IDBCursorBackendInterface::KeyAndValue, callbacks));
 }
 
 void GetOperation::perform(IDBTransactionBackendImpl* transaction)
@@ -607,7 +775,7 @@ void IDBDatabaseBackendImpl::put(int64_t transactionId, int64_t objectStoreId, V
     IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
     ASSERT(transaction->mode() != IDBTransaction::READ_ONLY);
 
-    const IDBObjectStoreMetadata objectStoreMetadata = metadata().objectStores.get(objectStoreId);
+    const IDBObjectStoreMetadata objectStoreMetadata = m_metadata.objectStores.get(objectStoreId);
 
     ASSERT(objectStoreMetadata.autoIncrement || key.get());
 
@@ -715,8 +883,8 @@ void IDBDatabaseBackendImpl::setIndexKeys(int64_t transactionId, int64_t objectS
     Vector<OwnPtr<IDBObjectStoreBackendImpl::IndexWriter> > indexWriters;
     String errorMessage;
     bool obeysConstraints = false;
-    ASSERT(metadata().objectStores.contains(objectStoreId));
-    const IDBObjectStoreMetadata& objectStoreMetadata = metadata().objectStores.get(objectStoreId);
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
+    const IDBObjectStoreMetadata& objectStoreMetadata = m_metadata.objectStores.get(objectStoreId);
     bool backingStoreSuccess = IDBObjectStoreBackendImpl::makeIndexWriters(transaction, store.get(), id(), objectStoreMetadata, primaryKey, false, indexIds, indexKeys, &indexWriters, &errorMessage, obeysConstraints);
     if (!backingStoreSuccess) {
         transaction->abort(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error: backing store error updating index keys."));
@@ -803,7 +971,7 @@ void IDBDatabaseBackendImpl::count(int64_t transactionId, int64_t objectStoreId,
     IDB_TRACE("IDBDatabaseBackendImpl::count");
     ASSERT(m_transactions.contains(transactionId));
     IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);
-    ASSERT(metadata().objectStores.contains(objectStoreId));
+    ASSERT(m_metadata.objectStores.contains(objectStoreId));
     transaction->scheduleTask(CountOperation::create(m_backingStore, id(), objectStoreId, indexId, keyRange, callbacks));
 }
 
@@ -843,7 +1011,6 @@ void IDBDatabaseBackendImpl::deleteRange(int64_t transactionId, int64_t objectSt
 void DeleteRangeOperation::perform(IDBTransactionBackendImpl* transaction)
 {
     IDB_TRACE("DeleteRangeOperation");
-
     RefPtr<IDBBackingStore::Cursor> backingStoreCursor = m_backingStore->openObjectStoreCursor(transaction->backingStoreTransaction(), m_databaseId, m_objectStoreId, m_keyRange.get(), IDBCursor::NEXT);
     if (backingStoreCursor) {
         do {
@@ -872,12 +1039,12 @@ void ClearOperation::perform(IDBTransactionBackendImpl* transaction)
     m_callbacks->onSuccess();
 }
 
-void IDBDatabaseBackendImpl::DeleteObjectStoreOperation::perform(IDBTransactionBackendImpl* transaction)
+void DeleteObjectStoreOperation::perform(IDBTransactionBackendImpl* transaction)
 {
     IDB_TRACE("DeleteObjectStoreOperation");
-    bool ok = m_database->m_backingStore->deleteObjectStore(transaction->backingStoreTransaction(), m_database->id(), m_objectStore->id());
+    bool ok = m_backingStore->deleteObjectStore(transaction->backingStoreTransaction(), transaction->database()->id(), m_objectStoreMetadata.id);
     if (!ok) {
-        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error deleting object store '%s'.", m_objectStore->name().utf8().data()));
+        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error deleting object store '%s'.", m_objectStoreMetadata.name.utf8().data()));
         transaction->abort(error);
     }
 }
@@ -1132,7 +1299,7 @@ void IDBDatabaseBackendImpl::deleteDatabaseFinal(PassRefPtr<IDBCallbacks> callba
     m_metadata.version = NoStringVersion;
     m_metadata.id = InvalidId;
     m_metadata.intVersion = IDBDatabaseMetadata::NoIntVersion;
-    m_objectStores.clear();
+    m_metadata.objectStores.clear();
     callbacks->onSuccess();
 }
 
@@ -1177,35 +1344,23 @@ void IDBDatabaseBackendImpl::close(PassRefPtr<IDBDatabaseCallbacks> prpCallbacks
     m_closingConnection = false;
 }
 
-void IDBDatabaseBackendImpl::loadObjectStores()
-{
-    Vector<int64_t> ids;
-    Vector<String> names;
-    Vector<IDBKeyPath> keyPaths;
-    Vector<bool> autoIncrementFlags;
-    Vector<int64_t> maxIndexIds;
-    Vector<IDBObjectStoreMetadata> objectStores = m_backingStore->getObjectStores(m_metadata.id);
-
-    for (size_t i = 0; i < objectStores.size(); i++)
-        m_objectStores.set(objectStores[i].id, IDBObjectStoreBackendImpl::create(this, objectStores[i]));
-}
-
-void IDBDatabaseBackendImpl::CreateObjectStoreAbortOperation::perform(IDBTransactionBackendImpl* transaction)
+void CreateObjectStoreAbortOperation::perform(IDBTransactionBackendImpl* transaction)
 {
+    IDB_TRACE("CreateObjectStoreAbortOperation");
     ASSERT(!transaction);
-    ASSERT(m_database->m_objectStores.contains(m_objectStore->id()));
-    m_database->m_objectStores.remove(m_objectStore->id());
+    m_database->removeObjectStore(m_objectStoreId);
 }
 
-void IDBDatabaseBackendImpl::DeleteObjectStoreAbortOperation::perform(IDBTransactionBackendImpl* transaction)
+void DeleteObjectStoreAbortOperation::perform(IDBTransactionBackendImpl* transaction)
 {
+    IDB_TRACE("DeleteObjectStoreAbortOperation");
     ASSERT(!transaction);
-    ASSERT(!m_database->m_objectStores.contains(m_objectStore->id()));
-    m_database->m_objectStores.set(m_objectStore->id(), m_objectStore);
+    m_database->addObjectStore(m_objectStoreMetadata, IDBObjectStoreMetadata::InvalidId);
 }
 
 void IDBDatabaseBackendImpl::VersionChangeAbortOperation::perform(IDBTransactionBackendImpl* transaction)
 {
+    IDB_TRACE("VersionChangeAbortOperation");
     ASSERT(!transaction);
     m_database->m_metadata.version = m_previousVersion;
     m_database->m_metadata.intVersion = m_previousIntVersion;
index 944b830..347f23e 100644 (file)
@@ -40,7 +40,6 @@ namespace WebCore {
 class IDBBackingStore;
 class IDBDatabase;
 class IDBFactoryBackendImpl;
-class IDBObjectStoreBackendImpl;
 class IDBTransactionBackendImpl;
 class IDBTransactionBackendInterface;
 class IDBTransactionCoordinator;
@@ -54,16 +53,20 @@ public:
 
     static const int64_t InvalidId = 0;
     int64_t id() const { return m_metadata.id; }
+    void addObjectStore(const IDBObjectStoreMetadata&, int64_t newMaxObjectStoreId);
+    void removeObjectStore(int64_t objectStoreId);
+    void addIndex(int64_t objectStoreId, const IDBIndexMetadata&, int64_t newMaxIndexId);
+    void removeIndex(int64_t objectStoreId, int64_t indexId);
 
     void openConnection(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, int64_t version);
     void deleteDatabase(PassRefPtr<IDBCallbacks>);
 
     // IDBDatabaseBackendInterface
     virtual IDBDatabaseMetadata metadata() const;
-    virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(int64_t id, const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&);
-    virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) { ASSERT_NOT_REACHED(); }
-    virtual void deleteObjectStore(int64_t, IDBTransactionBackendInterface*, ExceptionCode&);
-    virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId) { ASSERT_NOT_REACHED(); }
+    virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(int64_t id, const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&)  { ASSERT_NOT_REACHED(); return 0; }
+    virtual void createObjectStore(int64_t transactionId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement);
+    virtual void deleteObjectStore(int64_t, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
+    virtual void deleteObjectStore(int64_t transactionId, int64_t objectStoreId);
     // FIXME: Remove this method in https://bugs.webkit.org/show_bug.cgi?id=103923.
     virtual PassRefPtr<IDBTransactionBackendInterface> createTransaction(int64_t transactionId, const Vector<int64_t>& objectStoreIds, IDBTransaction::Mode);
     virtual void createTransaction(int64_t transactionId, PassRefPtr<IDBDatabaseCallbacks>, const Vector<int64_t>& objectStoreIds, unsigned short mode);
@@ -72,10 +75,9 @@ public:
     virtual void commit(int64_t transactionId);
     virtual void abort(int64_t transactionId);
 
-    virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry) { ASSERT_NOT_REACHED(); }
-    virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId) { ASSERT_NOT_REACHED(); }
+    virtual void createIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool unique, bool multiEntry);
+    virtual void deleteIndex(int64_t transactionId, int64_t objectStoreId, int64_t indexId);
 
-    PassRefPtr<IDBObjectStoreBackendImpl> objectStore(int64_t id);
     IDBTransactionCoordinator* transactionCoordinator() const { return m_transactionCoordinator.get(); }
     void transactionStarted(PassRefPtr<IDBTransactionBackendImpl>);
     void transactionFinished(PassRefPtr<IDBTransactionBackendImpl>);
@@ -96,20 +98,15 @@ private:
 
     bool openInternal();
     void runIntVersionChangeTransaction(PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, int64_t transactionId, int64_t requestedVersion);
-    void loadObjectStores();
     size_t connectionCount();
     void processPendingCalls();
 
     bool isDeleteDatabaseBlocked();
     void deleteDatabaseFinal(PassRefPtr<IDBCallbacks>);
 
-    class CreateObjectStoreOperation;
-    class DeleteObjectStoreOperation;
     class VersionChangeOperation;
 
     // When a "versionchange" transaction aborts, these restore the back-end object hierarchy.
-    class CreateObjectStoreAbortOperation;
-    class DeleteObjectStoreAbortOperation;
     class VersionChangeAbortOperation;
 
     RefPtr<IDBBackingStore> m_backingStore;
@@ -119,9 +116,6 @@ private:
     // This might not need to be a RefPtr since the factory's lifetime is that of the page group, but it's better to be conservitive than sorry.
     RefPtr<IDBFactoryBackendImpl> m_factory;
 
-    typedef HashMap<int64_t, RefPtr<IDBObjectStoreBackendImpl> > ObjectStoreMap;
-    ObjectStoreMap m_objectStores;
-
     OwnPtr<IDBTransactionCoordinator> m_transactionCoordinator;
     RefPtr<IDBTransactionBackendImpl> m_runningVersionChangeTransaction;
 
diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp
deleted file mode 100644 (file)
index 8940c5e..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IDBIndexBackendImpl.h"
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBBackingStore.h"
-#include "IDBCallbacks.h"
-#include "IDBCursorBackendImpl.h"
-#include "IDBDatabaseBackendImpl.h"
-#include "IDBDatabaseException.h"
-#include "IDBKey.h"
-#include "IDBKeyRange.h"
-#include "IDBMetadata.h"
-#include "IDBObjectStoreBackendImpl.h"
-#include "IDBTracing.h"
-#include "IDBTransactionBackendImpl.h"
-
-namespace WebCore {
-
-IDBIndexBackendImpl::IDBIndexBackendImpl(const IDBDatabaseBackendImpl* database, const IDBIndexMetadata& metadata)
-    : m_database(database)
-    , m_metadata(metadata)
-{
-}
-
-IDBIndexBackendImpl::~IDBIndexBackendImpl()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h b/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h
deleted file mode 100644 (file)
index 1a93999..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IDBIndexBackendImpl_h
-#define IDBIndexBackendImpl_h
-
-#if ENABLE(INDEXED_DATABASE)
-
-#include "IDBCursorBackendInterface.h"
-#include "IDBDatabaseBackendImpl.h"
-#include "IDBIndexBackendInterface.h"
-#include "IDBKeyPath.h"
-#include "IDBMetadata.h"
-
-namespace WebCore {
-
-class IDBBackingStore;
-class IDBKey;
-class IDBObjectStoreBackendImpl;
-
-class IDBIndexBackendImpl : public IDBIndexBackendInterface {
-public:
-    static PassRefPtr<IDBIndexBackendImpl> create(const IDBDatabaseBackendImpl* database, const IDBIndexMetadata& metadata)
-    {
-        return adoptRef(new IDBIndexBackendImpl(database, metadata));
-    }
-    virtual ~IDBIndexBackendImpl();
-
-    int64_t id() const
-    {
-        ASSERT(m_metadata.id != InvalidId);
-        return m_metadata.id;
-    }
-
-    // IDBIndexBackendInterface
-    virtual void openCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void count(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void openKeyCursor(PassRefPtr<IDBKeyRange>, unsigned short direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void get(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void getKey(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-
-    IDBIndexMetadata metadata() const { return m_metadata; }
-    const String& name() { return m_metadata.name; }
-    const IDBKeyPath& keyPath() { return m_metadata.keyPath; }
-    const bool& unique() { return m_metadata.unique; }
-    const bool& multiEntry() { return m_metadata.multiEntry; }
-
-private:
-    IDBIndexBackendImpl(const IDBDatabaseBackendImpl*, const IDBIndexMetadata&);
-
-    static const int64_t InvalidId = 0;
-
-    PassRefPtr<IDBBackingStore> backingStore() const { return m_database->backingStore(); }
-    int64_t databaseId() const { return m_database->id(); }
-
-    const IDBDatabaseBackendImpl* m_database;
-
-    IDBIndexMetadata m_metadata;
-};
-
-} // namespace WebCore
-
-#endif
-
-#endif // IDBIndexBackendImpl_h
index 891253d..f50fe1e 100644 (file)
@@ -49,13 +49,11 @@ namespace WebCore {
 
 static const unsigned short defaultDirection = IDBCursor::NEXT;
 
-IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetadata& metadata, PassRefPtr<IDBObjectStoreBackendInterface> idbObjectStore, IDBTransaction* transaction)
+IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetadata& metadata, IDBTransaction* transaction)
     : m_metadata(metadata)
-    , m_backend(idbObjectStore)
     , m_transaction(transaction)
     , m_deleted(false)
 {
-    ASSERT(m_backend);
     ASSERT(m_transaction);
     // We pass a reference to this object before it can be adopted.
     relaxAdoptionRequirement();
@@ -385,9 +383,7 @@ PassRefPtr<IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext* context
     }
 
     int64_t indexId = m_metadata.maxIndexId + 1;
-    m_backend->createIndex(indexId, name, keyPath, unique, multiEntry, m_transaction->backend(), ec);
-    if (ec)
-        return 0;
+    backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath, unique, multiEntry);
 
     ++m_metadata.maxIndexId;
 
@@ -466,14 +462,13 @@ void IDBObjectStore::deleteIndex(const String& name, ExceptionCode& ec)
         return;
     }
 
-    m_backend->deleteIndex(indexId, m_transaction->backend(), ec);
-    if (!ec) {
-        IDBIndexMap::iterator it = m_indexMap.find(name);
-        if (it != m_indexMap.end()) {
-            m_metadata.indexes.remove(it->value->id());
-            it->value->markDeleted();
-            m_indexMap.remove(name);
-        }
+    backendDB()->deleteIndex(m_transaction->id(), id(), indexId);
+
+    IDBIndexMap::iterator it = m_indexMap.find(name);
+    if (it != m_indexMap.end()) {
+        m_metadata.indexes.remove(it->value->id());
+        it->value->markDeleted();
+        m_indexMap.remove(name);
     }
 }
 
index 7e2f72f..6dfd978 100644 (file)
@@ -29,7 +29,6 @@
 #include "Dictionary.h"
 #include "IDBCursor.h"
 #include "IDBIndex.h"
-#include "IDBIndexBackendInterface.h"
 #include "IDBKey.h"
 #include "IDBKeyRange.h"
 #include "IDBMetadata.h"
@@ -52,9 +51,9 @@ class IDBAny;
 
 class IDBObjectStore : public ScriptWrappable, public RefCounted<IDBObjectStore> {
 public:
-    static PassRefPtr<IDBObjectStore> create(const IDBObjectStoreMetadata& metadata, PassRefPtr<IDBObjectStoreBackendInterface> backend, IDBTransaction* transaction)
+    static PassRefPtr<IDBObjectStore> create(const IDBObjectStoreMetadata& metadata, IDBTransaction* transaction)
     {
-        return adoptRef(new IDBObjectStore(metadata, backend, transaction));
+        return adoptRef(new IDBObjectStore(metadata, transaction));
     }
     ~IDBObjectStore() { }
 
@@ -109,7 +108,7 @@ public:
     IDBDatabaseBackendInterface* backendDB() const;
 
 private:
-    IDBObjectStore(const IDBObjectStoreMetadata&, PassRefPtr<IDBObjectStoreBackendInterface>, IDBTransaction*);
+    IDBObjectStore(const IDBObjectStoreMetadata&, IDBTransaction*);
 
     int64_t findIndexId(const String& name) const;
     bool containsIndex(const String& name) const
@@ -118,7 +117,6 @@ private:
     }
 
     IDBObjectStoreMetadata m_metadata;
-    RefPtr<IDBObjectStoreBackendInterface> m_backend;
     RefPtr<IDBTransaction> m_transaction;
     bool m_deleted;
 
index e6ce83c..d24b67f 100644 (file)
@@ -34,7 +34,6 @@
 #include "IDBCursorBackendImpl.h"
 #include "IDBDatabaseBackendImpl.h"
 #include "IDBDatabaseException.h"
-#include "IDBIndexBackendImpl.h"
 #include "IDBKey.h"
 #include "IDBKeyPath.h"
 #include "IDBKeyRange.h"
 
 namespace WebCore {
 
-class IDBObjectStoreBackendImpl::CreateIndexOperation : public IDBTransactionBackendImpl::Operation {
-public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-    {
-        return adoptPtr(new CreateIndexOperation(objectStore, index));
-    }
-    virtual void perform(IDBTransactionBackendImpl*);
-private:
-    CreateIndexOperation(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-        : m_objectStore(objectStore)
-        , m_index(index)
-    {
-    }
-
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
-    RefPtr<IDBIndexBackendImpl> m_index;
-};
-
-class IDBObjectStoreBackendImpl::DeleteIndexOperation : public IDBTransactionBackendImpl::Operation {
-public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-    {
-        return adoptPtr(new DeleteIndexOperation(objectStore, index));
-    }
-    virtual void perform(IDBTransactionBackendImpl*);
-private:
-    DeleteIndexOperation(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-        : m_objectStore(objectStore)
-        , m_index(index)
-    {
-    }
-
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
-    RefPtr<IDBIndexBackendImpl> m_index;
-};
-
-class IDBObjectStoreBackendImpl::CreateIndexAbortOperation : public IDBTransactionBackendImpl::Operation {
-public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-    {
-        return adoptPtr(new CreateIndexAbortOperation(objectStore, index));
-    }
-    virtual void perform(IDBTransactionBackendImpl*);
-private:
-    CreateIndexAbortOperation(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-        : m_objectStore(objectStore)
-        , m_index(index)
-    {
-    }
-
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
-    RefPtr<IDBIndexBackendImpl> m_index;
-};
-
-class IDBObjectStoreBackendImpl::DeleteIndexAbortOperation : public IDBTransactionBackendImpl::Operation {
-public:
-    static PassOwnPtr<IDBTransactionBackendImpl::Operation> create(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-    {
-        return adoptPtr(new DeleteIndexAbortOperation(objectStore, index));
-    }
-    virtual void perform(IDBTransactionBackendImpl*);
-private:
-    DeleteIndexAbortOperation(PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index)
-        : m_objectStore(objectStore)
-        , m_index(index)
-    {
-    }
-
-    RefPtr<IDBObjectStoreBackendImpl> m_objectStore;
-    RefPtr<IDBIndexBackendImpl> m_index;
-};
-
-
-IDBObjectStoreBackendImpl::~IDBObjectStoreBackendImpl()
-{
-}
-
-IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl* database, const IDBObjectStoreMetadata& metadata)
-    : m_database(database)
-    , m_metadata(metadata)
-{
-    loadIndexes();
-}
-
-IDBObjectStoreMetadata IDBObjectStoreBackendImpl::metadata() const
-{
-    IDBObjectStoreMetadata metadata(m_metadata);
-    for (IndexMap::const_iterator it = m_indexes.begin(); it != m_indexes.end(); ++it)
-        metadata.indexes.set(it->key, it->value->metadata());
-    return metadata;
-}
-
 bool IDBObjectStoreBackendImpl::IndexWriter::verifyIndexKeys(IDBBackingStore& backingStore, IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, bool& canAddKeys, const IDBKey* primaryKey, String* errorMessage) const
 {
     canAddKeys = false;
@@ -212,86 +119,6 @@ bool IDBObjectStoreBackendImpl::makeIndexWriters(PassRefPtr<IDBTransactionBacken
     return true;
 }
 
-PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(int64_t id, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
-{
-    ASSERT_WITH_MESSAGE(!m_indexes.contains(id), "Indexes already contain '%s'", name.utf8().data());
-
-    RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_database, IDBIndexMetadata(name, id, keyPath, unique, multiEntry));
-    ASSERT(index->name() == name);
-
-    RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
-    ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
-    ASSERT(id > m_metadata.maxIndexId);
-    m_metadata.maxIndexId = id;
-
-    if (!transaction->scheduleTask(CreateIndexOperation::create(this, index), CreateIndexAbortOperation::create(this, index))) {
-        ec = IDBDatabaseException::TransactionInactiveError;
-        return 0;
-    }
-
-    m_indexes.set(id, index);
-    return index.release();
-}
-
-void IDBObjectStoreBackendImpl::CreateIndexOperation::perform(IDBTransactionBackendImpl* transaction)
-{
-    IDB_TRACE("CreateIndexOperation");
-    if (!m_objectStore->backingStore()->createIndex(transaction->backingStoreTransaction(), m_objectStore->databaseId(), m_objectStore->id(), m_index->id(), m_index->name(), m_index->keyPath(), m_index->unique(), m_index->multiEntry())) {
-        transaction->abort(IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error when trying to create index '%s'.", m_index->name().utf8().data())));
-        return;
-    }
-}
-
-PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::index(int64_t indexId)
-{
-    RefPtr<IDBIndexBackendInterface> index = m_indexes.get(indexId);
-    ASSERT(index);
-    return index.release();
-}
-
-void IDBObjectStoreBackendImpl::deleteIndex(int64_t indexId, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
-{
-    ASSERT(m_indexes.contains(indexId));
-
-    RefPtr<IDBIndexBackendImpl> index = m_indexes.get(indexId);
-    RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
-    ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);
-
-    if (!transaction->scheduleTask(DeleteIndexOperation::create(this, index), DeleteIndexAbortOperation::create(this, index))) {
-        ec = IDBDatabaseException::TransactionInactiveError;
-        return;
-    }
-    m_indexes.remove(indexId);
-}
-
-void IDBObjectStoreBackendImpl::DeleteIndexOperation::perform(IDBTransactionBackendImpl* transaction)
-{
-    IDB_TRACE("DeleteIndexOperation");
-    m_objectStore->backingStore()->deleteIndex(transaction->backingStoreTransaction(), m_objectStore->databaseId(), m_objectStore->id(), m_index->id());
-}
-
-void IDBObjectStoreBackendImpl::loadIndexes()
-{
-    Vector<IDBIndexMetadata> indexes = backingStore()->getIndexes(databaseId(), m_metadata.id);
-
-    for (size_t i = 0; i < indexes.size(); ++i)
-        m_indexes.set(indexes[i].id, IDBIndexBackendImpl::create(m_database, indexes[i]));
-}
-
-void IDBObjectStoreBackendImpl::CreateIndexAbortOperation::perform(IDBTransactionBackendImpl* transaction)
-{
-    ASSERT(!transaction);
-    ASSERT(m_objectStore->m_indexes.contains(m_index->id()));
-    m_objectStore->m_indexes.remove(m_index->id());
-}
-
-void IDBObjectStoreBackendImpl::DeleteIndexAbortOperation::perform(IDBTransactionBackendImpl* transaction)
-{
-    ASSERT(!transaction);
-    ASSERT(!m_objectStore->m_indexes.contains(m_index->id()));
-    m_objectStore->m_indexes.set(m_index->id(), m_index);
-}
-
 PassRefPtr<IDBKey> IDBObjectStoreBackendImpl::generateKey(PassRefPtr<IDBBackingStore> backingStore, PassRefPtr<IDBTransactionBackendImpl> transaction, int64_t databaseId, int64_t objectStoreId)
 {
     const int64_t maxGeneratorValue = 9007199254740992LL; // Maximum integer storable as ECMAScript number.
index b3e2e55..970fc49 100644 (file)
 namespace WebCore {
 
 class IDBDatabaseBackendImpl;
-class IDBIndexBackendImpl;
 class IDBTransactionBackendImpl;
 class IDBTransactionBackendInterface;
 struct IDBObjectStoreMetadata;
 
-class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface {
-public:
-    static PassRefPtr<IDBObjectStoreBackendImpl> create(const IDBDatabaseBackendImpl* database, const IDBObjectStoreMetadata& metadata)
-    {
-        return adoptRef(new IDBObjectStoreBackendImpl(database, metadata));
-    }
-    virtual ~IDBObjectStoreBackendImpl();
-
-    typedef HashMap<int64_t, RefPtr<IDBIndexBackendImpl> > IndexMap;
-
-    static const int64_t InvalidId = 0;
-    int64_t id() const
-    {
-        ASSERT(m_metadata.id != InvalidId);
-        return m_metadata.id;
-    }
-
-    // IDBObjectStoreBackendInterface
-    virtual void get(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void put(PassRefPtr<SerializedScriptValue>, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, const Vector<int64_t>&, const Vector<IndexKeys>&) { ASSERT_NOT_REACHED(); }
-
-    virtual void deleteFunction(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void clear(PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-
-    virtual PassRefPtr<IDBIndexBackendInterface> createIndex(int64_t, const String& name, const IDBKeyPath&, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&);
-    virtual void setIndexKeys(PassRefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>&, const Vector<IndexKeys>&, IDBTransactionBackendInterface*) { ASSERT_NOT_REACHED(); }
-    virtual void setIndexesReady(const Vector<int64_t>&, IDBTransactionBackendInterface*) { ASSERT_NOT_REACHED(); }
-    virtual PassRefPtr<IDBIndexBackendInterface> index(int64_t);
-    virtual void deleteIndex(int64_t, IDBTransactionBackendInterface*, ExceptionCode&);
-
-    virtual void openCursor(PassRefPtr<IDBKeyRange>, IDBCursor::Direction, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface::TaskType, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-    virtual void count(PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) { ASSERT_NOT_REACHED(); }
-
-    static bool populateIndex(IDBBackingStore&, int64_t databaseId, int64_t objectStoreId, PassRefPtr<IDBIndexBackendImpl>);
-
-    IDBObjectStoreMetadata metadata() const;
-    const String& name() { return m_metadata.name; }
-    const IDBKeyPath& keyPath() const { return m_metadata.keyPath; }
-    const bool& autoIncrement() const { return m_metadata.autoIncrement; }
-
-    PassRefPtr<IDBBackingStore> backingStore() const { return m_database->backingStore(); }
-    int64_t databaseId() const { return m_database->id(); }
+// FIXME: this namespace is temporary until we move its contents out to their own home.
+namespace IDBObjectStoreBackendImpl {
 
     class IndexWriter {
     public:
@@ -109,27 +68,10 @@ public:
         IDBObjectStoreBackendInterface::IndexKeys m_indexKeys;
     };
 
-    static bool makeIndexWriters(PassRefPtr<IDBTransactionBackendImpl>, IDBBackingStore*, int64_t databaseId, const IDBObjectStoreMetadata&, PassRefPtr<IDBKey> primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIds, const Vector<IDBObjectStoreBackendInterface::IndexKeys>&, Vector<OwnPtr<IndexWriter> >* indexWriters, String* errorMessage, bool& completed) WARN_UNUSED_RETURN;
-
-    static PassRefPtr<IDBKey> generateKey(PassRefPtr<IDBBackingStore>, PassRefPtr<IDBTransactionBackendImpl>, int64_t databaseId, int64_t objectStoreId);
-    static bool updateKeyGenerator(PassRefPtr<IDBBackingStore>, PassRefPtr<IDBTransactionBackendImpl>, int64_t databaseId, int64_t objectStoreId, const IDBKey*, bool checkCurrent);
-
-private:
-    IDBObjectStoreBackendImpl(const IDBDatabaseBackendImpl*, const IDBObjectStoreMetadata&);
-
-    void loadIndexes();
-
-    class CreateIndexOperation;
-    class DeleteIndexOperation;
-
-    // When a "versionchange" transaction aborts, these restore the back-end object hierarchy.
-    class CreateIndexAbortOperation;
-    class DeleteIndexAbortOperation;
-
-    const IDBDatabaseBackendImpl* m_database;
+    bool makeIndexWriters(PassRefPtr<IDBTransactionBackendImpl>, IDBBackingStore*, int64_t databaseId, const IDBObjectStoreMetadata&, PassRefPtr<IDBKey> primaryKey, bool keyWasGenerated, const Vector<int64_t>& indexIds, const Vector<IDBObjectStoreBackendInterface::IndexKeys>&, Vector<OwnPtr<IndexWriter> >* indexWriters, String* errorMessage, bool& completed) WARN_UNUSED_RETURN;
 
-    IDBObjectStoreMetadata m_metadata;
-    IndexMap m_indexes;
+    PassRefPtr<IDBKey> generateKey(PassRefPtr<IDBBackingStore>, PassRefPtr<IDBTransactionBackendImpl>, int64_t databaseId, int64_t objectStoreId);
+    bool updateKeyGenerator(PassRefPtr<IDBBackingStore>, PassRefPtr<IDBTransactionBackendImpl>, int64_t databaseId, int64_t objectStoreId, const IDBKey*, bool checkCurrent);
 };
 
 } // namespace WebCore
index afa45e2..26efd0f 100644 (file)
@@ -122,11 +122,6 @@ IDBTransaction::~IDBTransaction()
     ASSERT(m_state == Finished);
 }
 
-IDBTransactionBackendInterface* IDBTransaction::backend() const
-{
-    return m_backend.get();
-}
-
 const String& IDBTransaction::mode() const
 {
     ExceptionCode ec = 0;
@@ -176,12 +171,9 @@ PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep
         return 0;
     }
 
-    RefPtr<IDBObjectStoreBackendInterface> objectStoreBackend = m_backend->objectStore(objectStoreId, ec);
-    ASSERT(!ec && objectStoreBackend);
-
     const IDBDatabaseMetadata& metadata = m_database->metadata();
 
-    RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectStores.get(objectStoreId), objectStoreBackend, this);
+    RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectStores.get(objectStoreId), this);
     objectStoreCreated(name, objectStore);
     return objectStore.release();
 }
index df41bbb..df3bb0c 100644 (file)
@@ -71,7 +71,6 @@ public:
     static Mode stringToMode(const String&, ScriptExecutionContext*, ExceptionCode&);
     static const AtomicString& modeToString(Mode, ExceptionCode&);
 
-    IDBTransactionBackendInterface* backend() const;
     IDBDatabaseBackendInterface* backendDB() const;
 
     int64_t id() const { return m_id; }
index 782f465..1b0ca4b 100644 (file)
@@ -32,7 +32,6 @@
 #include "IDBCursorBackendImpl.h"
 #include "IDBDatabaseBackendImpl.h"
 #include "IDBDatabaseException.h"
-#include "IDBObjectStoreBackendImpl.h"
 #include "IDBTracing.h"
 #include "IDBTransactionCoordinator.h"
 
@@ -70,18 +69,6 @@ IDBTransactionBackendImpl::~IDBTransactionBackendImpl()
     ASSERT(m_state == Finished);
 }
 
-PassRefPtr<IDBObjectStoreBackendInterface> IDBTransactionBackendImpl::objectStore(int64_t id, ExceptionCode& ec)
-{
-    if (m_state == Finished) {
-        ec = IDBDatabaseException::InvalidStateError;
-        return 0;
-    }
-
-    RefPtr<IDBObjectStoreBackendImpl> objectStore = m_database->objectStore(id);
-    ASSERT(objectStore);
-    return objectStore.release();
-}
-
 bool IDBTransactionBackendImpl::scheduleTask(TaskType type, PassOwnPtr<Operation> task, PassOwnPtr<Operation> abortTask)
 {
     if (m_state == Finished)
index c79deff..0b5b640 100644 (file)
@@ -52,7 +52,7 @@ public:
     virtual ~IDBTransactionBackendImpl();
 
     // IDBTransactionBackendInterface
-    virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(int64_t, ExceptionCode&);
+    virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(int64_t, ExceptionCode&) { ASSERT_NOT_REACHED(); return 0; }
     virtual void abort();
     void commit();
     virtual void setCallbacks(IDBTransactionCallbacks* callbacks) { m_callbacks = callbacks; }
index 519d954..a264f43 100644 (file)
@@ -3044,7 +3044,6 @@ enable?(INDEXED_DATABASE) {
         Modules/indexeddb/IDBFactoryBackendImpl.h \
         Modules/indexeddb/IDBIndex.h \
         Modules/indexeddb/IDBIndexBackendInterface.h \
-        Modules/indexeddb/IDBIndexBackendImpl.h \
         Modules/indexeddb/IDBKey.h \
         Modules/indexeddb/IDBKeyRange.h \
         Modules/indexeddb/IDBObjectStore.h \
@@ -3072,7 +3071,6 @@ enable?(INDEXED_DATABASE) {
         Modules/indexeddb/IDBFactoryBackendInterface.cpp \
         Modules/indexeddb/IDBFactoryBackendImpl.cpp \
         Modules/indexeddb/IDBIndex.cpp \
-        Modules/indexeddb/IDBIndexBackendImpl.cpp \
         Modules/indexeddb/IDBKey.cpp \
         Modules/indexeddb/IDBKeyRange.cpp \
         Modules/indexeddb/IDBObjectStore.cpp \
index cf4e9d2..0a135fc 100644 (file)
             'Modules/indexeddb/IDBFactoryBackendInterface.h',
             'Modules/indexeddb/IDBIndex.cpp',
             'Modules/indexeddb/IDBIndex.h',
-            'Modules/indexeddb/IDBIndexBackendImpl.cpp',
-            'Modules/indexeddb/IDBIndexBackendImpl.h',
             'Modules/indexeddb/IDBIndexBackendInterface.h',
             'Modules/indexeddb/IDBKey.cpp',
             'Modules/indexeddb/IDBKey.h',
             'inspector/front-end/Images/searchSmallGray.png',
             'inspector/front-end/Images/searchSmallWhite.png',
             'inspector/front-end/Images/searchNext.png',
-            'inspector/front-end/Images/searchPrev.png',            
+            'inspector/front-end/Images/searchPrev.png',
             'inspector/front-end/Images/segment.png',
             'inspector/front-end/Images/segmentEnd.png',
             'inspector/front-end/Images/segmentHover.png',
index 9b83179..20f6e17 100755 (executable)
                                        >
                                </File>
                                <File
-                                       RelativePath="..\Modules\indexeddb\IDBIndexBackendImpl.cpp"
-                                       >
-                               </File>
-                               <File
-                                       RelativePath="..\Modules\indexeddb\IDBIndexBackendImpl.h"
-                                       >
-                               </File>
-                               <File
                                        RelativePath="..\Modules\indexeddb\IDBIndexBackendInterface.h"
                                        >
                                </File>
index 7a9c608..2e200e1 100644 (file)
                9712A5D415004EDA0048AF10 /* IDBFactoryBackendInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 9712A57B15004EDA0048AF10 /* IDBFactoryBackendInterface.h */; };
                9712A5D515004EDA0048AF10 /* IDBIndex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9712A57C15004EDA0048AF10 /* IDBIndex.cpp */; };
                9712A5D615004EDA0048AF10 /* IDBIndex.h in Headers */ = {isa = PBXBuildFile; fileRef = 9712A57D15004EDA0048AF10 /* IDBIndex.h */; };
-               9712A5D815004EDA0048AF10 /* IDBIndexBackendImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9712A57F15004EDA0048AF10 /* IDBIndexBackendImpl.cpp */; };
-               9712A5D915004EDA0048AF10 /* IDBIndexBackendImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 9712A58015004EDA0048AF10 /* IDBIndexBackendImpl.h */; };
                9712A5DA15004EDA0048AF10 /* IDBIndexBackendInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 9712A58115004EDA0048AF10 /* IDBIndexBackendInterface.h */; };
                9712A5DB15004EDA0048AF10 /* IDBKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9712A58215004EDA0048AF10 /* IDBKey.cpp */; };
                9712A5DC15004EDA0048AF10 /* IDBKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 9712A58315004EDA0048AF10 /* IDBKey.h */; };
                9712A57C15004EDA0048AF10 /* IDBIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IDBIndex.cpp; path = Modules/indexeddb/IDBIndex.cpp; sourceTree = "<group>"; };
                9712A57D15004EDA0048AF10 /* IDBIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IDBIndex.h; path = Modules/indexeddb/IDBIndex.h; sourceTree = "<group>"; };
                9712A57E15004EDA0048AF10 /* IDBIndex.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = IDBIndex.idl; path = Modules/indexeddb/IDBIndex.idl; sourceTree = "<group>"; };
-               9712A57F15004EDA0048AF10 /* IDBIndexBackendImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IDBIndexBackendImpl.cpp; path = Modules/indexeddb/IDBIndexBackendImpl.cpp; sourceTree = "<group>"; };
-               9712A58015004EDA0048AF10 /* IDBIndexBackendImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IDBIndexBackendImpl.h; path = Modules/indexeddb/IDBIndexBackendImpl.h; sourceTree = "<group>"; };
                9712A58115004EDA0048AF10 /* IDBIndexBackendInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IDBIndexBackendInterface.h; path = Modules/indexeddb/IDBIndexBackendInterface.h; sourceTree = "<group>"; };
                9712A58215004EDA0048AF10 /* IDBKey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IDBKey.cpp; path = Modules/indexeddb/IDBKey.cpp; sourceTree = "<group>"; };
                9712A58315004EDA0048AF10 /* IDBKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IDBKey.h; path = Modules/indexeddb/IDBKey.h; sourceTree = "<group>"; };
                                9712A57C15004EDA0048AF10 /* IDBIndex.cpp */,
                                9712A57D15004EDA0048AF10 /* IDBIndex.h */,
                                9712A57E15004EDA0048AF10 /* IDBIndex.idl */,
-                               9712A57F15004EDA0048AF10 /* IDBIndexBackendImpl.cpp */,
-                               9712A58015004EDA0048AF10 /* IDBIndexBackendImpl.h */,
                                9712A58115004EDA0048AF10 /* IDBIndexBackendInterface.h */,
                                9712A58215004EDA0048AF10 /* IDBKey.cpp */,
                                9712A58315004EDA0048AF10 /* IDBKey.h */,
                                9712A5D215004EDA0048AF10 /* IDBFactoryBackendImpl.h in Headers */,
                                9712A5D415004EDA0048AF10 /* IDBFactoryBackendInterface.h in Headers */,
                                9712A5D615004EDA0048AF10 /* IDBIndex.h in Headers */,
-                               9712A5D915004EDA0048AF10 /* IDBIndexBackendImpl.h in Headers */,
                                9712A5DA15004EDA0048AF10 /* IDBIndexBackendInterface.h in Headers */,
                                9712A5DC15004EDA0048AF10 /* IDBKey.h in Headers */,
                                9712A5DF15004EDA0048AF10 /* IDBKeyPath.h in Headers */,
                                9712A5D115004EDA0048AF10 /* IDBFactoryBackendImpl.cpp in Sources */,
                                9712A5D315004EDA0048AF10 /* IDBFactoryBackendInterface.cpp in Sources */,
                                9712A5D515004EDA0048AF10 /* IDBIndex.cpp in Sources */,
-                               9712A5D815004EDA0048AF10 /* IDBIndexBackendImpl.cpp in Sources */,
                                9712A5DB15004EDA0048AF10 /* IDBKey.cpp in Sources */,
                                9712A5DE15004EDA0048AF10 /* IDBKeyPath.cpp in Sources */,
                                9712A5E215004EDA0048AF10 /* IDBKeyRange.cpp in Sources */,
index 9165731..6f996b2 100644 (file)
@@ -1,3 +1,15 @@
+2013-01-09  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Allow createIndex/createObjectStore to be asynchronous
+        https://bugs.webkit.org/show_bug.cgi?id=106377
+
+        Reviewed by Tony Chang.
+
+        Remove this test as it makes no sense once the objectstore/index
+        hierarchy is gone.
+
+        * tests/IDBDatabaseBackendTest.cpp:
+
 2013-01-09  Chris Rogers  <crogers@google.com>
 
         Allow live/local audio input to be enabled only when needed
index 6ef85c3..7cd644a 100644 (file)
@@ -30,8 +30,7 @@
 #include "IDBDatabaseCallbacksProxy.h"
 #include "IDBFactoryBackendImpl.h"
 #include "IDBFakeBackingStore.h"
-#include "IDBIndexBackendImpl.h"
-#include "IDBObjectStoreBackendImpl.h"
+#include "IDBTransactionBackendImpl.h"
 #include "WebIDBDatabaseCallbacksImpl.h"
 #include "WebIDBDatabaseImpl.h"
 
@@ -56,21 +55,8 @@ TEST(IDBDatabaseBackendTest, BackingStoreRetention)
     RefPtr<IDBDatabaseBackendImpl> db = IDBDatabaseBackendImpl::create("db", backingStore.get(), factory, "uniqueid");
     EXPECT_GT(backingStore->refCount(), 1);
 
-    const bool autoIncrement = false;
-    RefPtr<IDBObjectStoreBackendImpl> store = IDBObjectStoreBackendImpl::create(db.get(), IDBObjectStoreMetadata("store", 1, IDBKeyPath("keyPath"), autoIncrement, 0));
-    EXPECT_GT(backingStore->refCount(), 1);
-
-    const bool unique = false;
-    const bool multiEntry = false;
-    RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(db.get(), IDBIndexMetadata("index", -1, IDBKeyPath("keyPath"), unique, multiEntry));
-    EXPECT_GT(backingStore->refCount(), 1);
-
     db.clear();
     EXPECT_TRUE(backingStore->hasOneRef());
-    store.clear();
-    EXPECT_TRUE(backingStore->hasOneRef());
-    index.clear();
-    EXPECT_TRUE(backingStore->hasOneRef());
 }
 
 class MockIDBCallbacks : public IDBCallbacks {
index f965073..3ed724b 100644 (file)
@@ -39,7 +39,6 @@ public:
     virtual bool updateIDBDatabaseIntVersion(Transaction*, int64_t rowId, int64_t version) OVERRIDE { return false; }
     virtual bool deleteDatabase(const String& name) OVERRIDE { return false; }
 
-    virtual Vector<IDBObjectStoreMetadata> getObjectStores(int64_t databaseId) OVERRIDE { return Vector<IDBObjectStoreMetadata>(); }
     virtual bool createObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { return false; };
 
     virtual void clearObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
@@ -48,7 +47,6 @@ public:
     virtual bool maybeUpdateKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { return true; }
     virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier, bool& found) OVERRIDE { return true; }
 
-    virtual Vector<IDBIndexMetadata> getIndexes(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return Vector<IDBIndexMetadata>(); }
     virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) OVERRIDE { return false; };
     virtual void deleteIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { }
     virtual void putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier&) OVERRIDE { }