IndexedDB: Rename methods and remove dead code from IDBBackingStore
authoralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2012 08:05:58 +0000 (08:05 +0000)
committeralecflett@chromium.org <alecflett@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2012 08:05:58 +0000 (08:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101488

Reviewed by Ojan Vafai.

Source/WebCore:

In preparation for merging IDBBackingStore and IDBLevelDBBackingStore:

1) rename ObjectStoreRecordIdentifier to RecordIdentifier
2) remove IDBBackingStore::forEachRecord and friends
3) remove IDBBackingStore::Cursor::close, since it was an empty method.

No new tests as this is purely code cleanup.

* Modules/indexeddb/IDBBackingStore.cpp:
(WebCore::IDBLevelDBBackingStore::getRecord):
(WebCore):
(WebCore::IDBLevelDBBackingStore::putRecord):
(WebCore::IDBLevelDBBackingStore::createInvalidRecordIdentifier):
(WebCore::IDBLevelDBBackingStore::deleteRecord):
(WebCore::IDBLevelDBBackingStore::keyExistsInObjectStore):
(WebCore::IDBLevelDBBackingStore::putIndexDataForRecord):
(WebCore::IDBLevelDBBackingStore::deleteIndexDataForRecord):
* Modules/indexeddb/IDBBackingStore.h:
(WebCore::IDBBackingStore::RecordIdentifier::~RecordIdentifier):
(IDBBackingStore):
* Modules/indexeddb/IDBCursorBackendImpl.cpp:
(WebCore::IDBCursorBackendImpl::close):
* Modules/indexeddb/IDBIndexBackendImpl.cpp:
(WebCore::IDBIndexBackendImpl::countInternal):
(WebCore::IDBIndexBackendImpl::getInternal):
(WebCore::IDBIndexBackendImpl::getKeyInternal):
* Modules/indexeddb/IDBLevelDBBackingStore.h:
(IDBLevelDBBackingStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::getInternal):
(WebCore):
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::putInternal):
(WebCore::IDBObjectStoreBackendImpl::deleteInternal):
(WebCore::IDBObjectStoreBackendImpl::countInternal):

Source/WebKit/chromium:

Update IDBFakeBackingStore to reflect method changes in IDBBackingStore.

* tests/IDBFakeBackingStore.h:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/IDBCursorBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp
Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/IDBFakeBackingStore.h

index 3617cf9..49d774e 100644 (file)
@@ -1,3 +1,46 @@
+2012-11-08  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Rename methods and remove dead code from IDBBackingStore
+        https://bugs.webkit.org/show_bug.cgi?id=101488
+
+        Reviewed by Ojan Vafai.
+
+        In preparation for merging IDBBackingStore and IDBLevelDBBackingStore:
+
+        1) rename ObjectStoreRecordIdentifier to RecordIdentifier
+        2) remove IDBBackingStore::forEachRecord and friends
+        3) remove IDBBackingStore::Cursor::close, since it was an empty method.
+
+        No new tests as this is purely code cleanup.
+
+        * Modules/indexeddb/IDBBackingStore.cpp:
+        (WebCore::IDBLevelDBBackingStore::getRecord):
+        (WebCore):
+        (WebCore::IDBLevelDBBackingStore::putRecord):
+        (WebCore::IDBLevelDBBackingStore::createInvalidRecordIdentifier):
+        (WebCore::IDBLevelDBBackingStore::deleteRecord):
+        (WebCore::IDBLevelDBBackingStore::keyExistsInObjectStore):
+        (WebCore::IDBLevelDBBackingStore::putIndexDataForRecord):
+        (WebCore::IDBLevelDBBackingStore::deleteIndexDataForRecord):
+        * Modules/indexeddb/IDBBackingStore.h:
+        (WebCore::IDBBackingStore::RecordIdentifier::~RecordIdentifier):
+        (IDBBackingStore):
+        * Modules/indexeddb/IDBCursorBackendImpl.cpp:
+        (WebCore::IDBCursorBackendImpl::close):
+        * Modules/indexeddb/IDBIndexBackendImpl.cpp:
+        (WebCore::IDBIndexBackendImpl::countInternal):
+        (WebCore::IDBIndexBackendImpl::getInternal):
+        (WebCore::IDBIndexBackendImpl::getKeyInternal):
+        * Modules/indexeddb/IDBLevelDBBackingStore.h:
+        (IDBLevelDBBackingStore):
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::getInternal):
+        (WebCore):
+        (WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
+        (WebCore::IDBObjectStoreBackendImpl::putInternal):
+        (WebCore::IDBObjectStoreBackendImpl::deleteInternal):
+        (WebCore::IDBObjectStoreBackendImpl::countInternal):
+
 2012-11-07  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: console error after inspecting IndexedDB
index 6fd1199..6b5a62a 100644 (file)
@@ -706,9 +706,9 @@ void IDBLevelDBBackingStore::deleteObjectStore(IDBBackingStore::Transaction* tra
     clearObjectStore(transaction, databaseId, objectStoreId);
 }
 
-String IDBLevelDBBackingStore::getObjectStoreRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key)
+String IDBLevelDBBackingStore::getRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::getObjectStoreRecord");
+    IDB_TRACE("IDBLevelDBBackingStore::getRecord");
     LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
 
     const Vector<char> leveldbKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
@@ -729,7 +729,7 @@ String IDBLevelDBBackingStore::getObjectStoreRecord(IDBBackingStore::Transaction
 }
 
 namespace {
-class LevelDBRecordIdentifier : public IDBBackingStore::ObjectStoreRecordIdentifier {
+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()); }
@@ -768,9 +768,9 @@ static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t data
     return version;
 }
 
-bool IDBLevelDBBackingStore::putObjectStoreRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, ObjectStoreRecordIdentifier* recordIdentifier)
+bool IDBLevelDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::putObjectStoreRecord");
+    IDB_TRACE("IDBLevelDBBackingStore::putRecord");
     ASSERT(key.isValid());
     LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
     int64_t version = getNewVersionNumber(levelDBTransaction, databaseId, objectStoreId);
@@ -807,14 +807,14 @@ void IDBLevelDBBackingStore::clearObjectStore(IDBBackingStore::Transaction* tran
     deleteRange(levelDBTransaction, startKey, stopKey);
 }
 
-PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> IDBLevelDBBackingStore::createInvalidRecordIdentifier()
+PassRefPtr<IDBBackingStore::RecordIdentifier> IDBLevelDBBackingStore::createInvalidRecordIdentifier()
 {
     return LevelDBRecordIdentifier::create();
 }
 
-void IDBLevelDBBackingStore::deleteObjectStoreRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier* recordIdentifier)
+void IDBLevelDBBackingStore::deleteRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier* recordIdentifier)
 {
-    IDB_TRACE("IDBLevelDBBackingStore::deleteObjectStoreRecord");
+    IDB_TRACE("IDBLevelDBBackingStore::deleteRecord");
     LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
     const LevelDBRecordIdentifier* levelDBRecordIdentifier = static_cast<const LevelDBRecordIdentifier*>(recordIdentifier);
 
@@ -887,7 +887,7 @@ bool IDBLevelDBBackingStore::maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStor
     return true;
 }
 
-bool IDBLevelDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, ObjectStoreRecordIdentifier* foundRecordIdentifier)
+bool IDBLevelDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, RecordIdentifier* foundRecordIdentifier)
 {
     IDB_TRACE("IDBLevelDBBackingStore::keyExistsInObjectStore");
     LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
@@ -907,39 +907,6 @@ bool IDBLevelDBBackingStore::keyExistsInObjectStore(IDBBackingStore::Transaction
     return true;
 }
 
-bool IDBLevelDBBackingStore::forEachObjectStoreRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback& callback)
-{
-    LevelDBTransaction* levelDBTransaction = Transaction::levelDBTransactionFrom(transaction);
-    const Vector<char> startKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, minIDBKey());
-    const Vector<char> stopKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, maxIDBKey());
-
-    OwnPtr<LevelDBIterator> it = levelDBTransaction->createIterator();
-    for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) < 0; it->next()) {
-        const char* p = it->key().begin();
-        const char* limit = it->key().end();
-        ObjectStoreDataKey dataKey;
-        p = ObjectStoreDataKey::decode(p, limit, &dataKey);
-        ASSERT(p);
-
-        RefPtr<IDBKey> primaryKey = dataKey.userKey();
-
-        int64_t version;
-        const char* q = decodeVarInt(it->value().begin(), it->value().end(), version);
-        if (!q) {
-            InternalError(IDBLevelDBBackingStoreReadError);
-            return false;
-        }
-
-        RefPtr<LevelDBRecordIdentifier> ri = LevelDBRecordIdentifier::create(encodeIDBKey(*primaryKey), version);
-        String idbValue = decodeString(q, it->value().end());
-
-        if (!callback.callback(ri.get(), idbValue))
-            return false;
-    }
-
-    return true;
-}
-
 static bool checkIndexAndMetaDataKey(const LevelDBIterator* it, const Vector<char>& stopKey, int64_t indexId, unsigned char metaDataType)
 {
     if (!it->isValid() || compareKeys(it->key(), stopKey) >= 0)
@@ -1091,7 +1058,7 @@ void IDBLevelDBBackingStore::deleteIndex(IDBBackingStore::Transaction* transacti
     }
 }
 
-bool IDBLevelDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const ObjectStoreRecordIdentifier* recordIdentifier)
+bool IDBLevelDBBackingStore::putIndexDataForRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& key, const RecordIdentifier* recordIdentifier)
 {
     IDB_TRACE("IDBLevelDBBackingStore::putIndexDataForRecord");
     ASSERT(key.isValid());
@@ -1136,7 +1103,7 @@ static bool findGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction, cons
     return true;
 }
 
-bool IDBLevelDBBackingStore::deleteIndexDataForRecord(IDBBackingStore::Transaction*, int64_t, int64_t, int64_t, const ObjectStoreRecordIdentifier*)
+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;
@@ -1233,8 +1200,7 @@ public:
     virtual PassRefPtr<IDBKey> key() { return m_currentKey; }
     virtual PassRefPtr<IDBKey> primaryKey() { return m_currentKey; }
     virtual String value() = 0;
-    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0;
-    virtual void close() { }
+    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() = 0;
 
     virtual bool loadCurrentRow() = 0;
     bool firstSeek();
@@ -1425,7 +1391,7 @@ public:
 
     // CursorImplCommon
     virtual String value() { ASSERT_NOT_REACHED(); return String(); }
-    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() OVERRIDE
+    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() OVERRIDE
     {
         return m_identifier;
     }
@@ -1486,7 +1452,7 @@ public:
 
     // CursorImplCommon
     virtual String value() { return m_currentValue; }
-    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() OVERRIDE
+    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() OVERRIDE
     {
         return m_identifier;
     }
@@ -1552,7 +1518,7 @@ public:
     // CursorImplCommon
     virtual String value() { ASSERT_NOT_REACHED(); return String(); }
     virtual PassRefPtr<IDBKey> primaryKey() { return m_primaryKey; }
-    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
+    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
     virtual bool loadCurrentRow();
 
 private:
@@ -1631,7 +1597,7 @@ public:
     // CursorImplCommon
     virtual String value() { return m_value; }
     virtual PassRefPtr<IDBKey> primaryKey() { return m_primaryKey; }
-    virtual PassRefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
+    virtual PassRefPtr<IDBBackingStore::RecordIdentifier> objectStoreRecordIdentifier() { ASSERT_NOT_REACHED(); return 0; }
     bool loadCurrentRow();
 
 private:
index bfc3876..3c9451c 100644 (file)
@@ -61,33 +61,26 @@ public:
     virtual bool createObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) = 0;
     virtual void deleteObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) = 0;
 
-    class ObjectStoreRecordIdentifier : public RefCounted<ObjectStoreRecordIdentifier> {
+    class RecordIdentifier : public RefCounted<RecordIdentifier> {
     public:
         virtual bool isValid() const = 0;
-        virtual ~ObjectStoreRecordIdentifier() {}
+        virtual ~RecordIdentifier() { }
     };
-    virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() = 0;
+    virtual PassRefPtr<RecordIdentifier> createInvalidRecordIdentifier() = 0;
 
-    virtual String getObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&) = 0;
-    virtual bool putObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) = 0;
+    virtual String getRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&) = 0;
+    virtual bool putRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*) = 0;
     virtual void clearObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) = 0;
-    virtual void deleteObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) = 0;
+    virtual void deleteRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier*) = 0;
     virtual int64_t getKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId) = 0;
     virtual bool maybeUpdateKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) = 0;
-    virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) = 0;
-
-    class ObjectStoreRecordCallback {
-    public:
-         virtual bool callback(const ObjectStoreRecordIdentifier*, const String& value) = 0;
-         virtual ~ObjectStoreRecordCallback() {};
-    };
-    virtual bool forEachObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) = 0;
+    virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier) = 0;
 
     virtual Vector<IDBIndexMetadata> getIndexes(int64_t databaseId, int64_t objectStoreId) = 0;
     virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) = 0;
     virtual void deleteIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) = 0;
-    virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) = 0;
-    virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) = 0;
+    virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier*) = 0;
+    virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const RecordIdentifier*) = 0;
     virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) = 0;
     virtual bool keyExistsInIndex(Transaction*, int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) = 0;
 
@@ -104,8 +97,7 @@ public:
         virtual PassRefPtr<IDBKey> key() = 0;
         virtual PassRefPtr<IDBKey> primaryKey() = 0;
         virtual String value() = 0;
-        virtual PassRefPtr<ObjectStoreRecordIdentifier> objectStoreRecordIdentifier() = 0;
-        virtual void close() = 0;
+        virtual PassRefPtr<RecordIdentifier> objectStoreRecordIdentifier() = 0;
         virtual ~Cursor() { };
     };
 
index 428cc04..b4944ca 100644 (file)
@@ -198,8 +198,6 @@ void IDBCursorBackendImpl::close()
 {
     IDB_TRACE("IDBCursorBackendImpl::close");
     m_closed = true;
-    if (m_cursor)
-        m_cursor->close();
     m_cursor.clear();
     m_savedCursor.clear();
 }
index 402b759..13e699f 100644 (file)
@@ -126,7 +126,7 @@ void IDBIndexBackendImpl::countInternal(ScriptExecutionContext*, PassRefPtr<IDBI
     do {
         ++count;
     } while (backingStoreCursor->continueFunction(0));
-    backingStoreCursor->close();
+
     callbacks->onSuccess(count);
 }
 
@@ -155,12 +155,11 @@ void IDBIndexBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<IDBInd
             return;
         }
         key = backingStoreCursor->key();
-        backingStoreCursor->close();
     }
 
     RefPtr<IDBKey> primaryKey = index->backingStore()->getPrimaryKeyViaIndex(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), index->id(), *key);
 
-    String value = index->backingStore()->getObjectStoreRecord(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), *primaryKey);
+    String value = index->backingStore()->getRecord(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), *primaryKey);
 
     if (value.isNull()) {
         callbacks->onSuccess();
@@ -189,11 +188,9 @@ void IDBIndexBackendImpl::getKeyInternal(ScriptExecutionContext* context, PassRe
     RefPtr<IDBKey> keyResult = index->backingStore()->getPrimaryKeyViaIndex(transaction->backingStoreTransaction(), index->databaseId(), index->m_objectStoreBackend->id(), index->id(), *backingStoreCursor->key());
     if (!keyResult) {
         callbacks->onSuccess(static_cast<IDBKey*>(0));
-        backingStoreCursor->close();
         return;
     }
     callbacks->onSuccess(keyResult.get());
-    backingStoreCursor->close();
 }
 
 
index 26d6f90..1cb2725 100644 (file)
@@ -54,22 +54,20 @@ public:
     virtual Vector<IDBObjectStoreMetadata> getObjectStores(int64_t databaseId);
     virtual bool createObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement);
     virtual void deleteObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
-    virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier();
-    virtual String getObjectStoreRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&);
-    virtual bool putObjectStoreRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*);
+    virtual PassRefPtr<RecordIdentifier> createInvalidRecordIdentifier();
+    virtual String getRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&);
+    virtual bool putRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*);
     virtual void clearObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
-    virtual void deleteObjectStoreRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*);
+    virtual void deleteRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier*);
     virtual int64_t getKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
     virtual bool maybeUpdateKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newState, bool checkCurrent);
-    virtual bool keyExistsInObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier);
-
-    virtual bool forEachObjectStoreRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&);
+    virtual bool keyExistsInObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier);
 
     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 bool putIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*);
-    virtual bool deleteIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*);
+    virtual bool putIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier*);
+    virtual bool deleteIndexDataForRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const RecordIdentifier*);
     virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&);
     virtual bool keyExistsInIndex(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey);
 
index 976ad0b..4640c13 100644 (file)
@@ -89,10 +89,9 @@ void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<
             return;
         }
         key = backingStoreCursor->key();
-        backingStoreCursor->close();
     }
 
-    String wireData = objectStore->backingStore()->getObjectStoreRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key);
+    String wireData = objectStore->backingStore()->getRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key);
     if (wireData.isNull()) {
         callbacks->onSuccess();
         return;
@@ -160,7 +159,7 @@ public:
         return true;
     }
 
-    bool writeIndexKeys(const IDBBackingStore::ObjectStoreRecordIdentifier* recordIdentifier, IDBBackingStore& backingStore, IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId) const
+    bool writeIndexKeys(const IDBBackingStore::RecordIdentifier* recordIdentifier, IDBBackingStore& backingStore, IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId) const
     {
         int64_t indexId = m_indexMetadata.id;
         for (size_t i = 0; i < m_indexKeys.size(); ++i) {
@@ -237,7 +236,7 @@ void IDBObjectStoreBackendImpl::setIndexKeys(PassRefPtr<IDBKey> prpPrimaryKey, c
     RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr);
 
     // FIXME: This method could be asynchronous, but we need to evaluate if it's worth the extra complexity.
-    RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = backingStore()->createInvalidRecordIdentifier();
+    RefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier = backingStore()->createInvalidRecordIdentifier();
     if (!backingStore()->keyExistsInObjectStore(transaction->backingStoreTransaction(), databaseId(), id(), *primaryKey, recordIdentifier.get())) {
         transaction->abort();
         return;
@@ -330,7 +329,7 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
 
     ASSERT(key && key->isValid());
 
-    RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore->backingStore()->createInvalidRecordIdentifier();
+    RefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier = objectStore->backingStore()->createInvalidRecordIdentifier();
     if (putMode == AddOnly && objectStore->backingStore()->keyExistsInObjectStore(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, recordIdentifier.get())) {
         callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "Key already exists in the object store."));
         return;
@@ -345,7 +344,7 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
 
     // Before this point, don't do any mutation.  After this point, rollback the transaction in case of error.
 
-    if (!objectStore->backingStore()->putObjectStoreRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, value->toWireString(), recordIdentifier.get())) {
+    if (!objectStore->backingStore()->putRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), *key, value->toWireString(), recordIdentifier.get())) {
         RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage.");
         callbacks->onError(error);
         transaction->abort(error);
@@ -388,7 +387,7 @@ void IDBObjectStoreBackendImpl::deleteFunction(PassRefPtr<IDBKeyRange> prpKeyRan
 void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBTransactionBackendImpl> transaction)
 {
     IDB_TRACE("IDBObjectStoreBackendImpl::deleteInternal");
-    RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier;
+    RefPtr<IDBBackingStore::RecordIdentifier> recordIdentifier;
 
     RefPtr<IDBBackingStore::Cursor> backingStoreCursor = objectStore->backingStore()->openObjectStoreCursor(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), keyRange.get(), IDBCursor::NEXT);
     if (backingStoreCursor) {
@@ -401,11 +400,9 @@ void IDBObjectStoreBackendImpl::deleteInternal(ScriptExecutionContext*, PassRefP
                 ASSERT_UNUSED(success, success);
             }
 
-            objectStore->backingStore()->deleteObjectStoreRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), recordIdentifier.get());
+            objectStore->backingStore()->deleteRecord(transaction->backingStoreTransaction(), objectStore->databaseId(), objectStore->id(), recordIdentifier.get());
 
         } while (backingStoreCursor->continueFunction(0));
-
-        backingStoreCursor->close();
     }
 
     callbacks->onSuccess();
@@ -581,7 +578,6 @@ void IDBObjectStoreBackendImpl::countInternal(ScriptExecutionContext*, PassRefPt
         ++count;
     } while (backingStoreCursor->continueFunction(0));
 
-    backingStoreCursor->close();
     callbacks->onSuccess(count);
 }
 
index d17bccc..3b331c4 100644 (file)
@@ -1,3 +1,14 @@
+2012-11-08  Alec Flett  <alecflett@chromium.org>
+
+        IndexedDB: Rename methods and remove dead code from IDBBackingStore
+        https://bugs.webkit.org/show_bug.cgi?id=101488
+
+        Reviewed by Ojan Vafai.
+
+        Update IDBFakeBackingStore to reflect method changes in IDBBackingStore.
+
+        * tests/IDBFakeBackingStore.h:
+
 2012-08-20  Taiju Tsuiki  <tzik@chromium.org>
 
         Web Inspector: Drop dimmed crumb handling
index 1f16408..4e37d3e 100644 (file)
@@ -43,23 +43,21 @@ public:
     virtual bool createObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { return false; };
     virtual void deleteObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
 
-    virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() OVERRIDE { return PassRefPtr<ObjectStoreRecordIdentifier>(); }
+    virtual PassRefPtr<RecordIdentifier> createInvalidRecordIdentifier() OVERRIDE { return PassRefPtr<RecordIdentifier>(); }
 
-    virtual String getObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&) OVERRIDE { return String(); }
-    virtual bool putObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) OVERRIDE { return false; }
+    virtual String getRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&) OVERRIDE { return String(); }
+    virtual bool putRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*) OVERRIDE { return false; }
     virtual void clearObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
-    virtual void deleteObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) OVERRIDE { }
+    virtual void deleteRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier*) OVERRIDE { }
     virtual int64_t getKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0; }
     virtual bool maybeUpdateKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { return false; }
-    virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; }
-
-    virtual bool forEachObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; }
+    virtual bool keyExistsInObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, RecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; }
 
     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 bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; }
-    virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; }
+    virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const RecordIdentifier*) OVERRIDE { return false; }
+    virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const RecordIdentifier*) OVERRIDE { return false; }
     virtual PassRefPtr<IDBKey> getPrimaryKeyViaIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&) OVERRIDE { return PassRefPtr<IDBKey>(); }
     virtual bool keyExistsInIndex(Transaction*, int64_t databaseid, int64_t objectStoreId, int64_t indexId, const IDBKey& indexKey, RefPtr<IDBKey>& foundPrimaryKey) OVERRIDE { return false; }