Title: [195517] trunk
Revision
195517
Author
beid...@apple.com
Date
2016-01-24 15:42:11 -0800 (Sun, 24 Jan 2016)

Log Message

Modern IDB: Support IDBObjectStore.createIndex in the SQLite backing store.
https://bugs.webkit.org/show_bug.cgi?id=153410

Reviewed by Darin Adler.

Source/WebCore:

No new tests (Covered by unskipping many existing tests).

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::~SQLiteIDBBackingStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedHasIndexRecord):
(WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexRecord):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:

* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::SQLiteIDBCursor::maybeCreateBackingStoreCursor):
(WebCore::IDBServer::SQLiteIDBCursor::SQLiteIDBCursor):
* Modules/indexeddb/server/SQLiteIDBCursor.h:

* Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
(WebCore::IDBServer::SQLiteIDBTransaction::maybeOpenBackingStoreCursor):
* Modules/indexeddb/server/SQLiteIDBTransaction.h:

LayoutTests:

* platform/mac-wk1/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195516 => 195517)


--- trunk/LayoutTests/ChangeLog	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/LayoutTests/ChangeLog	2016-01-24 23:42:11 UTC (rev 195517)
@@ -1,3 +1,12 @@
+2016-01-24  Brady Eidson  <beid...@apple.com>
+
+        Modern IDB: Support IDBObjectStore.createIndex in the SQLite backing store.
+        https://bugs.webkit.org/show_bug.cgi?id=153410
+
+        Reviewed by Darin Adler.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-01-24  Simon Fraser  <simon.fra...@apple.com>
 
         Make the dumped display list representation a bit more compact

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (195516 => 195517)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-24 23:42:11 UTC (rev 195517)
@@ -439,7 +439,6 @@
 imported/w3c/indexeddb/value.htm [ Failure ]
 imported/w3c/indexeddb/value_recursive.htm [ Failure ]
 imported/w3c/indexeddb/writer-starvation.htm [ Failure ]
-storage/indexeddb/createIndex-after-failure.html [ Failure ]
 storage/indexeddb/cursor-added-bug.html [ Failure ]
 storage/indexeddb/cursor-advance.html [ Failure ]
 storage/indexeddb/cursor-basics.html [ Failure ]
@@ -460,13 +459,10 @@
 storage/indexeddb/cursor-update-value-argument-required.html [ Failure ]
 storage/indexeddb/cursor-update.html [ Failure ]
 storage/indexeddb/cursor-value.html [ Failure ]
-storage/indexeddb/database-wrapper.html [ Failure ]
 storage/indexeddb/delete-range.html [ Failure ]
-storage/indexeddb/deleteIndex.html [ Failure ]
 storage/indexeddb/deleted-objects.html [ Failure ]
 storage/indexeddb/duplicates.html [ Failure ]
 storage/indexeddb/exceptions.html [ Failure ]
-storage/indexeddb/factory-deletedatabase.html [ Failure ]
 storage/indexeddb/get-keyrange.html [ Failure ]
 storage/indexeddb/index-basics.html [ Failure ]
 storage/indexeddb/index-count.html [ Failure ]
@@ -484,12 +480,7 @@
 storage/indexeddb/keypath-intrinsic-properties.html [ Failure ]
 storage/indexeddb/lazy-index-population.html [ Failure ]
 storage/indexeddb/lazy-index-types.html [ Failure ]
-storage/indexeddb/list-ordering.html [ Failure ]
-storage/indexeddb/metadata-race.html [ Failure ]
-storage/indexeddb/metadata.html [ Failure ]
-storage/indexeddb/modern/abort-objectstore-info.html [ Failure ]
 storage/indexeddb/modern/autoincrement-abort.html [ Failure ]
-storage/indexeddb/modern/create-index-failures.html [ Failure ]
 storage/indexeddb/modern/cursor-1.html [ Failure ]
 storage/indexeddb/modern/cursor-2.html [ Failure ]
 storage/indexeddb/modern/cursor-3.html [ Failure ]
@@ -500,9 +491,7 @@
 storage/indexeddb/modern/cursor-8.html [ Failure ]
 storage/indexeddb/modern/deleteindex-1.html [ Failure ]
 storage/indexeddb/modern/deleteindex-2.html [ Failure ]
-storage/indexeddb/modern/get-index-failures.html [ Failure ]
 storage/indexeddb/modern/get-keyrange.html [ Failure ]
-storage/indexeddb/modern/idbindex-properties-basic.html [ Failure ]
 storage/indexeddb/modern/idbobjectstore-clear-1.html [ Failure ]
 storage/indexeddb/modern/idbobjectstore-clear-2.html [ Failure ]
 storage/indexeddb/modern/idbobjectstore-count-1.html [ Failure ]
@@ -516,16 +505,11 @@
 storage/indexeddb/modern/index-cursor-3.html [ Failure ]
 storage/indexeddb/modern/index-get-count-basic.html [ Failure ]
 storage/indexeddb/modern/index-get-count-failures.html [ Failure ]
-storage/indexeddb/modern/memory-index-not-deleted-with-objectstore.html [ Failure ]
-storage/indexeddb/modern/objectstore-attributes.html [ Failure ]
 storage/indexeddb/modern/objectstore-cursor-advance-failures.html [ Failure ]
 storage/indexeddb/modern/objectstore-cursor-continue-failures.html [ Failure ]
-storage/indexeddb/modern/opencursor-failures.html [ Failure ]
 storage/indexeddb/modern/request-readystate.html [ Failure ]
-storage/indexeddb/modern/transactions-stop-on-navigation.html [ Failure ]
 storage/indexeddb/mozilla/autoincrement-indexes.html [ Failure ]
 storage/indexeddb/mozilla/clear.html [ Failure ]
-storage/indexeddb/mozilla/create-index-with-integer-keys.html [ Failure ]
 storage/indexeddb/mozilla/cursor-mutation-objectstore-only.html [ Failure ]
 storage/indexeddb/mozilla/cursor-mutation.html [ Failure ]
 storage/indexeddb/mozilla/cursor-update-updates-indexes.html [ Failure ]
@@ -536,7 +520,6 @@
 storage/indexeddb/mozilla/indexes.html [ Failure ]
 storage/indexeddb/mozilla/key-requirements.html [ Failure ]
 storage/indexeddb/mozilla/object-cursors.html [ Failure ]
-storage/indexeddb/mozilla/object-identity.html [ Failure ]
 storage/indexeddb/mozilla/object-store-inline-autoincrement-key-added-on-put.html [ Failure ]
 storage/indexeddb/mozilla/object-store-remove-values.html [ Failure ]
 storage/indexeddb/mozilla/odd-result-order.html [ Failure ]
@@ -549,18 +532,12 @@
 storage/indexeddb/objectstore-clear.html [ Failure ]
 storage/indexeddb/objectstore-count.html [ Failure ]
 storage/indexeddb/objectstore-cursor.html [ Failure ]
-storage/indexeddb/objectstore-removeobjectstore.html [ Failure ]
 storage/indexeddb/open-cursor.html [ Failure ]
 storage/indexeddb/opencursor-key.html [ Failure ]
 storage/indexeddb/optional-arguments.html [ Failure ]
 storage/indexeddb/prefetch-bugfix-108071.html [ Failure ]
-storage/indexeddb/queued-commands.html [ Failure ]
 storage/indexeddb/readonly.html [ Failure ]
-storage/indexeddb/structured-clone.html [ Failure ]
 storage/indexeddb/transaction-active-flag.html [ Failure ]
-storage/indexeddb/transaction-and-objectstore-calls.html [ Failure ]
-storage/indexeddb/transaction-basics.html [ Failure ]
-storage/indexeddb/transaction-error.html [ Failure ]
 storage/indexeddb/transaction-rollback.html [ Failure ]
 storage/indexeddb/value-undefined.html [ Failure ]
 storage/indexeddb/values-odd-types.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (195516 => 195517)


--- trunk/Source/WebCore/ChangeLog	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/ChangeLog	2016-01-24 23:42:11 UTC (rev 195517)
@@ -1,3 +1,28 @@
+2016-01-24  Brady Eidson  <beid...@apple.com>
+
+        Modern IDB: Support IDBObjectStore.createIndex in the SQLite backing store.
+        https://bugs.webkit.org/show_bug.cgi?id=153410
+
+        Reviewed by Darin Adler.
+
+        No new tests (Covered by unskipping many existing tests).
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::~SQLiteIDBBackingStore):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedHasIndexRecord):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedPutIndexRecord):
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+        * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
+        (WebCore::IDBServer::SQLiteIDBCursor::maybeCreateBackingStoreCursor):
+        (WebCore::IDBServer::SQLiteIDBCursor::SQLiteIDBCursor):
+        * Modules/indexeddb/server/SQLiteIDBCursor.h:
+
+        * Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
+        (WebCore::IDBServer::SQLiteIDBTransaction::maybeOpenBackingStoreCursor):
+        * Modules/indexeddb/server/SQLiteIDBTransaction.h:
+
 2016-01-24  Simon Fraser  <simon.fra...@apple.com>
 
         Make the dumped display list representation a bit more compact

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (195516 => 195517)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-01-24 23:42:11 UTC (rev 195517)
@@ -118,6 +118,11 @@
 {
     if (m_sqliteDB)
         m_sqliteDB->close();
+
+    if (m_vm) {
+        JSLockHolder locker(m_vm.get());
+        m_vm = nullptr;
+    }
 }
 
 static bool createOrMigrateRecordsTableIfNecessary(SQLiteDatabase& database)
@@ -678,11 +683,171 @@
     return { };
 }
 
-IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier&, const IDBIndexInfo&)
+IDBError SQLiteIDBBackingStore::createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo& info)
 {
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto* transaction = m_transactions.get(transactionIdentifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to create an index without an in-progress transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an index without an in-progress transaction") };
+    }
+    if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
+        LOG_ERROR("Attempt to create an index in a non-version-change transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an index in a non-version-change transaction") };
+    }
+
+    RefPtr<SharedBuffer> keyPathBlob = serializeIDBKeyPath(info.keyPath());
+    if (!keyPathBlob) {
+        LOG_ERROR("Unable to serialize IDBKeyPath to save in database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to serialize IDBKeyPath to create index in database") };
+    }
+
+    SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO IndexInfo VALUES (?, ?, ?, ?, ?, ?);"));
+    if (sql.prepare() != SQLITE_OK
+        || sql.bindInt64(1, info.identifier()) != SQLITE_OK
+        || sql.bindText(2, info.name()) != SQLITE_OK
+        || sql.bindInt64(3, info.objectStoreIdentifier()) != SQLITE_OK
+        || sql.bindBlob(4, keyPathBlob->data(), keyPathBlob->size()) != SQLITE_OK
+        || sql.bindInt(5, info.unique()) != SQLITE_OK
+        || sql.bindInt(6, info.multiEntry()) != SQLITE_OK
+        || sql.step() != SQLITE_DONE) {
+        LOG_ERROR("Could not add index '%s' to IndexInfo table (%i) - %s", info.name().utf8().data(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to create index in database") };
+    }
+
+    // Write index records for any records that already exist in this object store.
+
+    auto cursor = transaction->maybeOpenBackingStoreCursor(info.objectStoreIdentifier());
+
+    if (!cursor) {
+        LOG_ERROR("Cannot open cursor to populate indexes in database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to populate indexes in database") };
+    }
+
+    if (!m_vm) {
+        ASSERT(!m_globalObject);
+        m_vm = VM::create();
+    }
+
+    JSLockHolder locker(m_vm.get());
+
+    if (!m_globalObject)
+        m_globalObject.set(*m_vm, JSGlobalObject::create(*m_vm, JSGlobalObject::createStructure(*m_vm, jsNull())));
+
+    while (!cursor->currentKey().isNull()) {
+        auto& key = cursor->currentKey();
+        auto& valueBuffer = cursor->currentValueBuffer();
+
+        auto value = deserializeIDBValueBuffer(m_globalObject->globalExec(), Vector<uint8_t>(valueBuffer), true);
+
+        IndexKey indexKey;
+        generateIndexKeyForValue(*m_globalObject->globalExec(), info, value.jsValue(), indexKey);
+
+        if (!info.multiEntry()) {
+            IDBError error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey.asOneKey());
+            if (!error.isNull()) {
+                LOG_ERROR("Unable to put index record for newly created index");
+                return error;
+            }
+        }
+
+        Vector<IDBKeyData> indexKeys = indexKey.multiEntry();
+
+        if (info.unique()) {
+            bool hasRecord;
+            IDBError error;
+            for (auto& indexKey : indexKeys) {
+                error = uncheckedHasIndexRecord(info.identifier(), indexKey, hasRecord);
+                if (hasRecord)
+                    return IDBError(IDBDatabaseException::ConstraintError);
+                if (!error.isNull())
+                    return error;
+            }
+        }
+
+        for (auto& indexKey : indexKeys) {
+            IDBError error = uncheckedPutIndexRecord(info.objectStoreIdentifier(), info.identifier(), key, indexKey);
+            if (!error.isNull()) {
+                LOG_ERROR("Unable to put index record for newly created index");
+                return error;
+            }
+        }
+
+        if (!cursor->advance(1)) {
+            LOG_ERROR("Error advancing cursor while indexing existing records for new index.");
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Error advancing cursor while indexing existing records for new index") };
+        }
+    }
+
+    return { };
 }
 
+IDBError SQLiteIDBBackingStore::uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData& indexKey, bool& hasRecord)
+{
+    hasRecord = false;
+
+    RefPtr<SharedBuffer> indexKeyBuffer = serializeIDBKeyData(indexKey);
+    if (!indexKeyBuffer) {
+        LOG_ERROR("Unable to serialize index key to be stored in the database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to serialize IDBKey to check for index record in database") };
+    }
+
+    SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("SELECT rowid FROM IndexRecords WHERE indexID = ? AND key = CAST(? AS TEXT);"));
+    if (sql.prepare() != SQLITE_OK
+        || sql.bindInt64(1, indexID) != SQLITE_OK
+        || sql.bindBlob(2, indexKeyBuffer->data(), indexKeyBuffer->size()) != SQLITE_OK) {
+        LOG_ERROR("Error checking for index record in database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Error checking for index record in database") };
+    }
+
+    int sqlResult = sql.step();
+    if (sqlResult == SQLITE_OK || sqlResult == SQLITE_DONE)
+        return { };
+
+    if (sqlResult != SQLITE_ROW) {
+        // There was an error fetching the record from the database.
+        LOG_ERROR("Could not check if key exists in index (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Error checking for existence of IDBKey in index") };
+    }
+
+    hasRecord = true;
+    return { };
+}
+
+
+IDBError SQLiteIDBBackingStore::uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const WebCore::IDBKeyData& keyValue, const WebCore::IDBKeyData& indexKey)
+{
+    RefPtr<SharedBuffer> indexKeyBuffer = serializeIDBKeyData(indexKey);
+    if (!indexKeyBuffer) {
+        LOG_ERROR("Unable to serialize index key to be stored in the database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to serialize index key to be stored in the database") };
+    }
+
+    RefPtr<SharedBuffer> valueBuffer = serializeIDBKeyData(keyValue);
+    if (!valueBuffer) {
+        LOG_ERROR("Unable to serialize the value to be stored in the database");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to serialize value to be stored in the database") };
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO IndexRecords VALUES (?, ?, CAST(? AS TEXT), CAST(? AS TEXT));"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, indexID) != SQLITE_OK
+            || sql.bindInt64(2, objectStoreID) != SQLITE_OK
+            || sql.bindBlob(3, indexKeyBuffer->data(), indexKeyBuffer->size()) != SQLITE_OK
+            || sql.bindBlob(4, valueBuffer->data(), valueBuffer->size()) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not put index record for index %" PRIi64 " in object store %" PRIi64 " in Records table (%i) - %s", indexID, objectStoreID, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Error putting index record into database") };
+        }
+    }
+
+    return { };
+}
+
+
 IDBError SQLiteIDBBackingStore::deleteIndex(const IDBResourceIdentifier&, uint64_t, const String&)
 {
     return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (195516 => 195517)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h	2016-01-24 23:42:11 UTC (rev 195517)
@@ -33,6 +33,7 @@
 #include "IDBDatabaseInfo.h"
 #include "IDBResourceIdentifier.h"
 #include "SQLiteIDBTransaction.h"
+#include <_javascript_Core/Strong.h>
 #include <wtf/HashMap.h>
 
 namespace WebCore {
@@ -86,6 +87,8 @@
     std::unique_ptr<IDBDatabaseInfo> extractExistingDatabaseInfo();
 
     IDBError deleteRecord(SQLiteIDBTransaction&, int64_t objectStoreID, const IDBKeyData&);
+    IDBError uncheckedPutIndexRecord(int64_t objectStoreID, int64_t indexID, const IDBKeyData& keyValue, const IDBKeyData& indexKey);
+    IDBError uncheckedHasIndexRecord(int64_t indexID, const IDBKeyData&, bool& hasRecord);
 
     IDBDatabaseIdentifier m_identifier;
     std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
@@ -96,6 +99,9 @@
     HashMap<IDBResourceIdentifier, SQLiteIDBCursor*> m_cursors;
 
     String m_absoluteDatabaseDirectory;
+
+    RefPtr<JSC::VM> m_vm;
+    JSC::Strong<JSC::JSGlobalObject> m_globalObject;
 };
 
 } // namespace IDBServer

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp (195516 => 195517)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp	2016-01-24 23:42:11 UTC (rev 195517)
@@ -40,7 +40,7 @@
 
 std::unique_ptr<SQLiteIDBCursor> SQLiteIDBCursor::maybeCreate(SQLiteIDBTransaction& transaction, const IDBCursorInfo& info)
 {
-    auto cursor = std::unique_ptr<SQLiteIDBCursor>(new SQLiteIDBCursor(transaction, info));
+    auto cursor = std::make_unique<SQLiteIDBCursor>(transaction, info);
 
     if (!cursor->establishStatement())
         return nullptr;
@@ -51,6 +51,19 @@
     return cursor;
 }
 
+std::unique_ptr<SQLiteIDBCursor> SQLiteIDBCursor::maybeCreateBackingStoreCursor(SQLiteIDBTransaction& transaction, const uint64_t objectStoreIdentifier)
+{
+    auto cursor = std::make_unique<SQLiteIDBCursor>(transaction, objectStoreIdentifier);
+
+    if (!cursor->establishStatement())
+        return nullptr;
+
+    if (!cursor->advance(1))
+        return nullptr;
+
+    return cursor;
+}
+
 SQLiteIDBCursor::SQLiteIDBCursor(SQLiteIDBTransaction& transaction, const IDBCursorInfo& info)
     : m_transaction(&transaction)
     , m_cursorIdentifier(info.identifier())
@@ -58,15 +71,19 @@
     , m_indexID(info.sourceIdentifier())
     , m_cursorDirection(info.cursorDirection())
     , m_keyRange(info.range())
-    , m_currentRecordID(-1)
-    , m_statementNeedsReset(false)
-    , m_boundID(0)
-    , m_completed(false)
-    , m_errored(false)
 {
     ASSERT(m_objectStoreID);
 }
 
+SQLiteIDBCursor::SQLiteIDBCursor(SQLiteIDBTransaction& transaction, uint64_t objectStoreID)
+    : m_transaction(&transaction)
+    , m_cursorIdentifier(transaction.transactionIdentifier())
+    , m_objectStoreID(objectStoreID)
+    , m_cursorDirection(IndexedDB::CursorDirection::Next)
+{
+    ASSERT(m_objectStoreID);
+}
+
 static String buildIndexStatement(const IDBKeyRangeData& keyRange, IndexedDB::CursorDirection cursorDirection)
 {
     StringBuilder builder;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h (195516 => 195517)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h	2016-01-24 23:42:11 UTC (rev 195517)
@@ -46,7 +46,11 @@
     WTF_MAKE_NONCOPYABLE(SQLiteIDBCursor);
 public:
     static std::unique_ptr<SQLiteIDBCursor> maybeCreate(SQLiteIDBTransaction&, const IDBCursorInfo&);
+    static std::unique_ptr<SQLiteIDBCursor> maybeCreateBackingStoreCursor(SQLiteIDBTransaction&, const uint64_t objectStoreIdentifier);
 
+    SQLiteIDBCursor(SQLiteIDBTransaction&, const IDBCursorInfo&);
+    SQLiteIDBCursor(SQLiteIDBTransaction&, uint64_t objectStoreID);
+
     const IDBResourceIdentifier& identifier() const { return m_cursorIdentifier; }
     SQLiteIDBTransaction* transaction() const { return m_transaction; }
 
@@ -64,8 +68,6 @@
     void objectStoreRecordsChanged();
 
 private:
-    SQLiteIDBCursor(SQLiteIDBTransaction&, const IDBCursorInfo&);
-
     bool establishStatement();
     bool createSQLiteStatement(const String& sql);
     bool bindArguments();
@@ -85,24 +87,24 @@
     SQLiteIDBTransaction* m_transaction;
     IDBResourceIdentifier m_cursorIdentifier;
     int64_t m_objectStoreID;
-    int64_t m_indexID;
-    IndexedDB::CursorDirection m_cursorDirection;
+    int64_t m_indexID { IDBIndexMetadata::InvalidId };
+    IndexedDB::CursorDirection m_cursorDirection { IndexedDB::CursorDirection::Next };
     IDBKeyRangeData m_keyRange;
 
     IDBKeyData m_currentLowerKey;
     IDBKeyData m_currentUpperKey;
 
-    int64_t m_currentRecordID;
+    int64_t m_currentRecordID { -1 };
     IDBKeyData m_currentKey;
     IDBKeyData m_currentPrimaryKey;
     Vector<uint8_t> m_currentValueBuffer;
 
     std::unique_ptr<SQLiteStatement> m_statement;
-    bool m_statementNeedsReset;
-    int64_t m_boundID;
+    bool m_statementNeedsReset { false };
+    int64_t m_boundID { 0 };
 
-    bool m_completed;
-    bool m_errored;
+    bool m_completed { false };
+    bool m_errored { false };
 };
 
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp (195516 => 195517)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp	2016-01-24 23:42:11 UTC (rev 195517)
@@ -99,6 +99,14 @@
     clearCursors();
 }
 
+std::unique_ptr<SQLiteIDBCursor> SQLiteIDBTransaction::maybeOpenBackingStoreCursor(uint64_t objectStoreID)
+{
+    ASSERT(m_sqliteTransaction);
+    ASSERT(m_sqliteTransaction->inProgress());
+
+    return SQLiteIDBCursor::maybeCreateBackingStoreCursor(*this, objectStoreID);
+}
+
 SQLiteIDBCursor* SQLiteIDBTransaction::maybeOpenCursor(const IDBCursorInfo& info)
 {
     ASSERT(m_sqliteTransaction);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h (195516 => 195517)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h	2016-01-24 20:39:49 UTC (rev 195516)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h	2016-01-24 23:42:11 UTC (rev 195517)
@@ -59,6 +59,7 @@
     IDBError commit();
     IDBError abort();
 
+    std::unique_ptr<SQLiteIDBCursor> maybeOpenBackingStoreCursor(uint64_t objectStoreID);
     SQLiteIDBCursor* maybeOpenCursor(const IDBCursorInfo&);
 
     void closeCursor(SQLiteIDBCursor&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to