IDB: ObjectStore cursor advance() support
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jan 2014 22:23:24 +0000 (22:23 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jan 2014 22:23:24 +0000 (22:23 +0000)
commit6cfbd5a1b248710cfce813f74eb70465b9790375
tree6d4186b7579596bebcff1abe174c734d56592631
parenteee71ceca62a673e90a2e6a5d71a124ee5d136cb
IDB: ObjectStore cursor advance() support
<rdar://problem/15779645> and https://bugs.webkit.org/show_bug.cgi?id=127866

Reviewed by Sam Weinig.

Source/WebCore:

Add IDBKeyData sorting for database collation:
* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::compare):
* Modules/indexeddb/IDBKeyData.h:

* WebCore.exp.in:

* platform/sql/SQLiteTransaction.h:
(WebCore::SQLiteTransaction::database):

Source/WebKit2:

Plumb calls through to the backing store:
* DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp:
(WebKit::UniqueIDBDatabase::openCursorInBackingStore):
(WebKit::UniqueIDBDatabase::advanceCursorInBackingStore):
(WebKit::UniqueIDBDatabase::iterateCursorInBackingStore):

* DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h:
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp:
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::createAndPopulateInitialMetadata): Update schema
  for Records table.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::getOrEstablishMetadata):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::establishTransaction):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::resetTransaction):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::putRecord):
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::openCursor): Create a SQLiteIDBCursor object.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::advanceCursor): Call through to that object.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::iterateCursor): Ditto.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::idbKeyCollate): Renamed for clarity.
(WebKit::UniqueIDBDatabaseBackingStoreSQLite::unregisterCursor): Cleanup open cursors.
* DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h:

* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp: Added.
(WebKit::SQLiteIDBCursor::maybeCreate):
(WebKit::SQLiteIDBCursor::SQLiteIDBCursor):
(WebKit::SQLiteIDBCursor::establishStatement):
(WebKit::SQLiteIDBCursor::createIndexCursorStatement): Stubbed for now.
(WebKit::SQLiteIDBCursor::createObjectStoreCursorStatement): Create the appropriate query for
  the passed in IDBKeyRange.
(WebKit::SQLiteIDBCursor::advance): Step through that query.
(WebKit::SQLiteIDBCursor::iterate): Stubbed for now.
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h: Added.
(WebKit::SQLiteIDBCursor::identifier):
(WebKit::SQLiteIDBCursor::transaction):
(WebKit::SQLiteIDBCursor::currentKey):
(WebKit::SQLiteIDBCursor::currentPrimaryKey):
(WebKit::SQLiteIDBCursor::currentValue):

Add infrastructure for a SQLiteIDBTransaction to keep track of (and clean up) its open cursors:
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp:
(WebKit::SQLiteIDBTransaction::SQLiteIDBTransaction):
(WebKit::SQLiteIDBTransaction::~SQLiteIDBTransaction):
(WebKit::SQLiteIDBTransaction::reset):
(WebKit::SQLiteIDBTransaction::openCursor):
(WebKit::SQLiteIDBTransaction::clearCursors):
* DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.h:
(WebKit::SQLiteIDBTransaction::create):
(WebKit::SQLiteIDBTransaction::sqliteTransaction):

Add accessors for the two fields:
* DatabaseProcess/IndexedDB/IDBIdentifier.h:
(WebKit::IDBIdentifier::connection):
(WebKit::IDBIdentifier::id):

* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBKeyData.cpp
Source/WebCore/Modules/indexeddb/IDBKeyData.h
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/sql/SQLiteTransaction.h
Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/IndexedDB/IDBIdentifier.h
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabase.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/UniqueIDBDatabaseBackingStore.h
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.cpp [new file with mode: 0644]
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBCursor.h [new file with mode: 0644]
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/SQLiteIDBTransaction.h
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.cpp
Source/WebKit2/DatabaseProcess/IndexedDB/sqlite/UniqueIDBDatabaseBackingStoreSQLite.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj