LayoutTests/ChangeLog

 12015-11-12 Brady Eidson <beidson@apple.com>
 2
 3 Modern IDB: Pipe through cursor functions from client to server.
 4 https://bugs.webkit.org/show_bug.cgi?id=151197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * storage/indexeddb/modern/cursor-1-expected.txt: Added.
 9 * storage/indexeddb/modern/cursor-1.html: Added.
 10 * storage/indexeddb/modern/opencursor-failures-expected.txt: Added.
 11 * storage/indexeddb/modern/opencursor-failures.html: Added.
 12
1132015-11-12 Zalan Bujtas <zalan@apple.com>
214
315 Ignore visited background color when deciding if the input renderer needs to be painted natively.

LayoutTests/storage/indexeddb/modern/cursor-1-expected.txt

 1This tests basic IDBCursor functionality
 2Initial upgrade needed: Old version - 0 New version - 1
 3Error opening cursor (expected for now)
 4Cursor is: [object IDBCursorWithValue]
 5Cursor direction is: next
 6Cursor source is: [object IDBObjectStore] (TestObjectStore)
 7Cursor key is: null
 8Cursor primary key is: null
 9Error opening cursor (expected for now)
 10Cursor is: [object IDBCursorWithValue]
 11Cursor direction is: next
 12Cursor source is: [object IDBIndex] (TestIndex1)
 13Cursor key is: null
 14Cursor primary key is: null
 15Error opening cursor (expected for now)
 16Cursor is: [object IDBCursor]
 17Cursor direction is: next
 18Cursor source is: [object IDBIndex] (TestIndex1)
 19Cursor key is: null
 20Cursor primary key is: null
 21Error opening cursor (expected for now)
 22Cursor is: [object IDBCursorWithValue]
 23Cursor direction is: nextunique
 24Cursor source is: [object IDBObjectStore] (TestObjectStore)
 25Cursor key is: null
 26Cursor primary key is: null
 27Error opening cursor (expected for now)
 28Cursor is: [object IDBCursorWithValue]
 29Cursor direction is: nextunique
 30Cursor source is: [object IDBIndex] (TestIndex1)
 31Cursor key is: null
 32Cursor primary key is: null
 33Error opening cursor (expected for now)
 34Cursor is: [object IDBCursor]
 35Cursor direction is: nextunique
 36Cursor source is: [object IDBIndex] (TestIndex1)
 37Cursor key is: null
 38Cursor primary key is: null
 39Error opening cursor (expected for now)
 40Cursor is: [object IDBCursorWithValue]
 41Cursor direction is: prev
 42Cursor source is: [object IDBObjectStore] (TestObjectStore)
 43Cursor key is: null
 44Cursor primary key is: null
 45Error opening cursor (expected for now)
 46Cursor is: [object IDBCursorWithValue]
 47Cursor direction is: prev
 48Cursor source is: [object IDBIndex] (TestIndex1)
 49Cursor key is: null
 50Cursor primary key is: null
 51Error opening cursor (expected for now)
 52Cursor is: [object IDBCursor]
 53Cursor direction is: prev
 54Cursor source is: [object IDBIndex] (TestIndex1)
 55Cursor key is: null
 56Cursor primary key is: null
 57Error opening cursor (expected for now)
 58Cursor is: [object IDBCursorWithValue]
 59Cursor direction is: prevunique
 60Cursor source is: [object IDBObjectStore] (TestObjectStore)
 61Cursor key is: null
 62Cursor primary key is: null
 63Error opening cursor (expected for now)
 64Cursor is: [object IDBCursorWithValue]
 65Cursor direction is: prevunique
 66Cursor source is: [object IDBIndex] (TestIndex1)
 67Cursor key is: null
 68Cursor primary key is: null
 69Error opening cursor (expected for now)
 70Cursor is: [object IDBCursor]
 71Cursor direction is: prevunique
 72Cursor source is: [object IDBIndex] (TestIndex1)
 73Cursor key is: null
 74Cursor primary key is: null
 75Initial upgrade versionchange transaction complete
 76Done
 77

LayoutTests/storage/indexeddb/modern/cursor-1.html

 1This tests basic IDBCursor functionality<br>
 2<div id="logger"></div>
 3<script>
 4
 5if (window.testRunner) {
 6 testRunner.waitUntilDone();
 7 testRunner.dumpAsText();
 8}
 9
 10function done()
 11{
 12 log("Done");
 13 if (window.testRunner)
 14 testRunner.notifyDone();
 15}
 16
 17function log(message)
 18{
 19 document.getElementById("logger").innerHTML += message + "<br>";
 20}
 21
 22var createRequest = window.indexedDB.open("Cursor1Database", 1);
 23
 24function logCursor(cursor)
 25{
 26 log("Cursor is: " + cursor);
 27 log("Cursor direction is: " + cursor.direction);
 28 log("Cursor source is: " + cursor.source + " (" + cursor.source.name + ")");
 29 log("Cursor key is: " + cursor.key);
 30 log("Cursor primary key is: " + cursor.primaryKey);
 31}
 32
 33function setupRequest(request)
 34{
 35 // FIXME: Right now (until https://bugs.webkit.org/show_bug.cgi?id=151196 is resolved) what should be successful cursor operations will actually always fail.
 36 request.onsuccess = function() {
 37 log("Success opening cursor");
 38 logCursor(request.result);
 39 }
 40 request.onerror = function(e) {
 41 log("Error opening cursor (expected for now)");
 42 logCursor(request.result);
 43 e.stopPropagation();
 44 }
 45}
 46
 47var objectStore;
 48var index;
 49
 50function testCursorDirection(direction)
 51{
 52 var range = IDBKeyRange.lowerBound(-Infinity);
 53 var request = objectStore.openCursor(range, direction);
 54 setupRequest(request);
 55 request = index.openCursor(range, direction);
 56 setupRequest(request);
 57 request = index.openKeyCursor(range, direction);
 58 setupRequest(request);
 59}
 60
 61createRequest.onupgradeneeded = function(event) {
 62 log("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
 63
 64 var versionTransaction = createRequest.transaction;
 65 var database = event.target.result;
 66 objectStore = database.createObjectStore("TestObjectStore");
 67 index = objectStore.createIndex("TestIndex1", "bar");
 68
 69 for (var i = 0; i < 10; ++i) {
 70 objectStore.put("Record " + i, i);
 71 }
 72 objectStore.put({ bar: "Hello" }, "foo");
 73
 74 testCursorDirection("next");
 75 testCursorDirection("nextunique");
 76 testCursorDirection("prev");
 77 testCursorDirection("prevunique");
 78
 79 versionTransaction.onabort = function(event) {
 80 log("Initial upgrade versionchange transaction unexpected aborted");
 81 done();
 82 }
 83
 84 versionTransaction.oncomplete = function(event) {
 85 log("Initial upgrade versionchange transaction complete");
 86 done();
 87 }
 88
 89 versionTransaction.onerror = function(event) {
 90 log("Initial upgrade versionchange transaction unexpected error" + event);
 91 done();
 92 }
 93}
 94
 95</script>

LayoutTests/storage/indexeddb/modern/opencursor-failures-expected.txt

 1This tests some obvious failures that can happen while opening cursors.
 2Initial upgrade needed: Old version - 0 New version - 1
 3Failed to open object store cursor with invalid keypath
 4Failed to open object store cursor with invalid direction
 5Failed to open index cursor with invalid keypath
 6Failed to open index cursor with invalid direction
 7Failed to open index key cursor with invalid keypath
 8Failed to open index key cursor with invalid direction
 9Failed to open object store cursor on deleted object store
 10Failed to open index cursor on deleted object store
 11Failed to open index key cursor on deleted object store
 12Initial upgrade versionchange transaction complete
 13Failed to open object store cursor from completed transaction
 14Failed to open index cursor from completed transaction
 15Failed to open index key cursor from completed transaction
 16Failed to open object store cursor from inactive transaction
 17Failed to open index cursor from inactive transaction
 18Failed to open index key cursor from inactive transaction
 19readonly transaction complete
 20Done
 21

LayoutTests/storage/indexeddb/modern/opencursor-failures.html

 1This tests some obvious failures that can happen while opening cursors.<br>
 2<div id="logger"></div>
 3<script>
 4
 5if (window.testRunner) {
 6 testRunner.waitUntilDone();
 7 testRunner.dumpAsText();
 8}
 9
 10function done()
 11{
 12 log("Done");
 13 if (window.testRunner)
 14 testRunner.notifyDone();
 15}
 16
 17function log(message)
 18{
 19 document.getElementById("logger").innerHTML += message + "<br>";
 20}
 21
 22var createRequest = window.indexedDB.open("OpenCursorFailuresDatabase", 1);
 23var database;
 24var objectStore;
 25var index;
 26
 27createRequest.onupgradeneeded = function(event) {
 28 log("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
 29
 30 var versionTransaction = createRequest.transaction;
 31 database = event.target.result;
 32 objectStore = database.createObjectStore("TestObjectStore");
 33 index = objectStore.createIndex("TestIndex", "bar");
 34 var request = objectStore.put({ bar: "bar" }, "foo");
 35
 36 request.onsuccess = function() {
 37 try {
 38 objectStore.openCursor(NaN);
 39 } catch(e) {
 40 log("Failed to open object store cursor with invalid keypath");
 41 }
 42
 43 try {
 44 objectStore.openCursor("foo", "invalid direction");
 45 } catch(e) {
 46 log("Failed to open object store cursor with invalid direction");
 47 }
 48
 49 try {
 50 index.openCursor(NaN);
 51 } catch(e) {
 52 log("Failed to open index cursor with invalid keypath");
 53 }
 54
 55 try {
 56 index.openCursor("foo", "invalid direction");
 57 } catch(e) {
 58 log("Failed to open index cursor with invalid direction");
 59 }
 60
 61 try {
 62 index.openKeyCursor(NaN);
 63 } catch(e) {
 64 log("Failed to open index key cursor with invalid keypath");
 65 }
 66
 67 try {
 68 index.openKeyCursor("foo", "invalid direction");
 69 } catch(e) {
 70 log("Failed to open index key cursor with invalid direction");
 71 }
 72
 73 database.deleteObjectStore("TestObjectStore");
 74
 75 try {
 76 objectStore.openCursor();
 77 } catch(e) {
 78 log("Failed to open object store cursor on deleted object store");
 79 }
 80
 81 try {
 82 index.openCursor();
 83 } catch(e) {
 84 log("Failed to open index cursor on deleted object store");
 85 }
 86
 87 try {
 88 index.openKeyCursor();
 89 } catch(e) {
 90 log("Failed to open index key cursor on deleted object store");
 91 }
 92
 93 // Recreate the objectstore because we'll need it in phase 2.
 94 objectStore = database.createObjectStore("TestObjectStore");
 95 index = objectStore.createIndex("TestIndex", "bar");
 96 objectStore.put({ bar: "bar" }, "foo");
 97 }
 98
 99 versionTransaction.onabort = function(event) {
 100 log("Initial upgrade versionchange transaction unexpected aborted");
 101 done();
 102 }
 103
 104 versionTransaction.oncomplete = function(event) {
 105 log("Initial upgrade versionchange transaction complete");
 106 continueTest1();
 107 }
 108
 109 versionTransaction.onerror = function(event) {
 110 log("Initial upgrade versionchange transaction unexpected error" + event);
 111 done();
 112 }
 113}
 114
 115function continueTest1()
 116{
 117 try {
 118 objectStore.openCursor();
 119 } catch(e) {
 120 log("Failed to open object store cursor from completed transaction");
 121 }
 122
 123 try {
 124 index.openCursor();
 125 } catch(e) {
 126 log("Failed to open index cursor from completed transaction");
 127 }
 128
 129 try {
 130 index.openKeyCursor();
 131 } catch(e) {
 132 log("Failed to open index key cursor from completed transaction");
 133 }
 134
 135 var transaction = database.transaction("TestObjectStore", "readonly");
 136 objectStore = transaction.objectStore("TestObjectStore");
 137 index = objectStore.index("TestIndex");
 138
 139 // Spin the transaction with get requests to keep it alive long enough for the setTimeout to fire.
 140 var canFinish = false;
 141 var spinGet = function() {
 142 objectStore.get("foo").onsuccess = function() {
 143 if (!canFinish)
 144 spinGet();
 145 }
 146 }
 147 spinGet();
 148
 149 var getWhileInactive = function() {
 150 try {
 151 objectStore.openCursor();
 152 } catch(e) {
 153 log("Failed to open object store cursor from inactive transaction");
 154 }
 155
 156 try {
 157 index.openCursor();
 158 } catch(e) {
 159 log("Failed to open index cursor from inactive transaction");
 160 }
 161
 162 try {
 163 index.openKeyCursor();
 164 } catch(e) {
 165 log("Failed to open index key cursor from inactive transaction");
 166 }
 167 canFinish = true;
 168 }
 169
 170 setTimeout(getWhileInactive, 0);
 171
 172 transaction.onabort = function(event) {
 173 log("readonly transaction unexpected abort" + event);
 174 done();
 175 }
 176
 177 transaction.oncomplete = function(event) {
 178 log("readonly transaction complete");
 179 done();
 180 }
 181
 182 transaction.onerror = function(event) {
 183 log("readonly transaction unexpected error" + event);
 184 done();
 185 }
 186}
 187
 188</script>

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
912912 Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp
913913 Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp
914914
 915 Modules/indexeddb/shared/IDBCursorInfo.cpp
915916 Modules/indexeddb/shared/IDBDatabaseInfo.cpp
916917 Modules/indexeddb/shared/IDBError.cpp
917918 Modules/indexeddb/shared/IDBIndexInfo.cpp

Source/WebCore/ChangeLog

 12015-11-12 Brady Eidson <beidson@apple.com>
 2
 3 Modern IDB: Pipe through cursor functions from client to server.
 4 https://bugs.webkit.org/show_bug.cgi?id=151197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Tests: storage/indexeddb/modern/cursor-1.html
 9 storage/indexeddb/modern/opencursor-failures.html
 10
 11 This patch implements most IDBCursor considerations at the IDL level, as well as pipes the
 12 appropriate messages through from client to server.
 13
 14 All operations currently end in errors. Bug 151196 will fix that by making cursors functional.
 15
 16 * CMakeLists.txt:
 17 * WebCore.xcodeproj/project.pbxproj:
 18
 19 * Modules/indexeddb/IDBCursor.h:
 20 (WebCore::IDBCursor::isKeyCursor): Deleted.
 21 * Modules/indexeddb/IDBCursorWithValue.h:
 22
 23 * Modules/indexeddb/IDBGetResult.h:
 24
 25 * Modules/indexeddb/IDBKeyData.h:
 26 (WebCore::IDBKeyData::string):
 27 (WebCore::IDBKeyData::date):
 28 (WebCore::IDBKeyData::number):
 29 (WebCore::IDBKeyData::array):
 30
 31 * Modules/indexeddb/IndexedDB.h:
 32
 33 * Modules/indexeddb/client/IDBAnyImpl.cpp:
 34 (WebCore::IDBClient::IDBAny::IDBAny):
 35 (WebCore::IDBClient::IDBAny::idbCursor):
 36 (WebCore::IDBClient::IDBAny::idbCursorWithValue):
 37 (WebCore::IDBClient::IDBAny::idbIndex):
 38 (WebCore::IDBClient::IDBAny::idbObjectStore):
 39 (WebCore::IDBClient::IDBAny::modernIDBCursor):
 40 * Modules/indexeddb/client/IDBAnyImpl.h:
 41 (WebCore::IDBClient::IDBAny::create):
 42
 43 * Modules/indexeddb/client/IDBConnectionToServer.cpp:
 44 (WebCore::IDBClient::IDBConnectionToServer::openCursor):
 45 (WebCore::IDBClient::IDBConnectionToServer::didOpenCursor):
 46 (WebCore::IDBClient::IDBConnectionToServer::iterateCursor):
 47 (WebCore::IDBClient::IDBConnectionToServer::didIterateCursor):
 48 * Modules/indexeddb/client/IDBConnectionToServer.h:
 49 * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
 50
 51 * Modules/indexeddb/client/IDBCursorImpl.cpp:
 52 (WebCore::IDBClient::IDBCursor::create):
 53 (WebCore::IDBClient::IDBCursor::IDBCursor):
 54 (WebCore::IDBClient::IDBCursor::sourcesDeleted):
 55 (WebCore::IDBClient::IDBCursor::effectiveObjectStore):
 56 (WebCore::IDBClient::IDBCursor::transaction):
 57 (WebCore::IDBClient::IDBCursor::direction):
 58 (WebCore::IDBClient::IDBCursor::key):
 59 (WebCore::IDBClient::IDBCursor::primaryKey):
 60 (WebCore::IDBClient::IDBCursor::value):
 61 (WebCore::IDBClient::IDBCursor::source):
 62 (WebCore::IDBClient::IDBCursor::update):
 63 (WebCore::IDBClient::IDBCursor::advance):
 64 (WebCore::IDBClient::IDBCursor::continueFunction):
 65 (WebCore::IDBClient::IDBCursor::uncheckedIteratorCursor):
 66 (WebCore::IDBClient::IDBCursor::deleteFunction):
 67 (WebCore::IDBClient::IDBCursor::setGetResult):
 68 * Modules/indexeddb/client/IDBCursorImpl.h:
 69 (WebCore::IDBClient::IDBCursor::info):
 70 (WebCore::IDBClient::IDBCursor::setRequest):
 71 (WebCore::IDBClient::IDBCursor::clearRequest):
 72 (WebCore::IDBClient::IDBCursor::request):
 73
 74 * Modules/indexeddb/client/IDBCursorWithValueImpl.cpp:
 75 (WebCore::IDBClient::IDBCursorWithValue::create):
 76 (WebCore::IDBClient::IDBCursorWithValue::IDBCursorWithValue):
 77 (WebCore::IDBClient::IDBCursorWithValue::~IDBCursorWithValue):
 78 * Modules/indexeddb/client/IDBCursorWithValueImpl.h:
 79
 80 * Modules/indexeddb/client/IDBIndexImpl.cpp:
 81 (WebCore::IDBClient::IDBIndex::openCursor):
 82 (WebCore::IDBClient::IDBIndex::openKeyCursor):
 83 * Modules/indexeddb/client/IDBIndexImpl.h:
 84 (WebCore::IDBClient::IDBIndex::modernObjectStore):
 85 (WebCore::IDBClient::IDBIndex::isDeleted):
 86
 87 * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
 88 (WebCore::IDBClient::IDBObjectStore::openCursor):
 89 (WebCore::IDBClient::IDBObjectStore::deleteFunction):
 90 * Modules/indexeddb/client/IDBObjectStoreImpl.h:
 91
 92 * Modules/indexeddb/client/IDBRequestImpl.cpp:
 93 (WebCore::IDBClient::IDBRequest::create):
 94 (WebCore::IDBClient::IDBRequest::IDBRequest):
 95 (WebCore::IDBClient::IDBRequest::~IDBRequest):
 96 (WebCore::IDBClient::IDBRequest::source):
 97 (WebCore::IDBClient::IDBRequest::resultCursor):
 98 (WebCore::IDBClient::IDBRequest::willIterateCursor):
 99 (WebCore::IDBClient::IDBRequest::didOpenOrIterateCursor):
 100 (WebCore::IDBClient::IDBRequest::requestCompleted):
 101 * Modules/indexeddb/client/IDBRequestImpl.h:
 102 (WebCore::IDBClient::IDBRequest::modernResult):
 103
 104 * Modules/indexeddb/client/IDBTransactionImpl.cpp:
 105 (WebCore::IDBClient::IDBTransaction::requestOpenCursor):
 106 (WebCore::IDBClient::IDBTransaction::doRequestOpenCursor):
 107 (WebCore::IDBClient::IDBTransaction::openCursorOnServer):
 108 (WebCore::IDBClient::IDBTransaction::didOpenCursorOnServer):
 109 (WebCore::IDBClient::IDBTransaction::iterateCursor):
 110 (WebCore::IDBClient::IDBTransaction::iterateCursorOnServer):
 111 (WebCore::IDBClient::IDBTransaction::didIterateCursorOnServer):
 112 * Modules/indexeddb/client/IDBTransactionImpl.h:
 113
 114 * Modules/indexeddb/client/TransactionOperation.h:
 115 (WebCore::IDBClient::createTransactionOperation):
 116
 117 * Modules/indexeddb/legacy/LegacyCursor.cpp:
 118 (WebCore::LegacyCursor::source):
 119 * Modules/indexeddb/legacy/LegacyCursor.h:
 120 (WebCore::LegacyCursor::continueFunction): Deleted.
 121 (WebCore::LegacyCursor::isKeyCursor): Deleted.
 122 * Modules/indexeddb/legacy/LegacyCursorWithValue.h:
 123
 124 * Modules/indexeddb/server/IDBBackingStore.h:
 125
 126 * Modules/indexeddb/server/IDBConnectionToClient.cpp:
 127 (WebCore::IDBServer::IDBConnectionToClient::didOpenCursor):
 128 (WebCore::IDBServer::IDBConnectionToClient::didIterateCursor):
 129 * Modules/indexeddb/server/IDBConnectionToClient.h:
 130 * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
 131
 132 * Modules/indexeddb/server/IDBServer.cpp:
 133 (WebCore::IDBServer::IDBServer::openCursor):
 134 (WebCore::IDBServer::IDBServer::iterateCursor):
 135 * Modules/indexeddb/server/IDBServer.h:
 136
 137 * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
 138 (WebCore::IDBServer::MemoryIDBBackingStore::openCursor):
 139 (WebCore::IDBServer::MemoryIDBBackingStore::iterateCursor):
 140 * Modules/indexeddb/server/MemoryIDBBackingStore.h:
 141
 142 * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
 143 (WebCore::IDBServer::UniqueIDBDatabase::openCursor):
 144 (WebCore::IDBServer::UniqueIDBDatabase::performOpenCursor):
 145 (WebCore::IDBServer::UniqueIDBDatabase::didPerformOpenCursor):
 146 (WebCore::IDBServer::UniqueIDBDatabase::iterateCursor):
 147 (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor):
 148 (WebCore::IDBServer::UniqueIDBDatabase::didPerformIterateCursor):
 149 * Modules/indexeddb/server/UniqueIDBDatabase.h:
 150
 151 * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
 152 (WebCore::IDBServer::UniqueIDBDatabaseTransaction::deleteRecord):
 153 (WebCore::IDBServer::UniqueIDBDatabaseTransaction::openCursor):
 154 (WebCore::IDBServer::UniqueIDBDatabaseTransaction::iterateCursor):
 155 * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
 156
 157 * Modules/indexeddb/shared/IDBCursorInfo.cpp: Added.
 158 (WebCore::IDBCursorInfo::objectStoreCursor):
 159 (WebCore::IDBCursorInfo::indexCursor):
 160 (WebCore::IDBCursorInfo::IDBCursorInfo):
 161 (WebCore::IDBCursorInfo::isDirectionForward):
 162 (WebCore::IDBCursorInfo::isolatedCopy):
 163 * Modules/indexeddb/shared/IDBCursorInfo.h: Added.
 164 (WebCore::IDBCursorInfo::identifier):
 165 (WebCore::IDBCursorInfo::sourceIdentifier):
 166 (WebCore::IDBCursorInfo::cursorSource):
 167 (WebCore::IDBCursorInfo::cursorDirection):
 168 (WebCore::IDBCursorInfo::cursorType):
 169
 170 * Modules/indexeddb/shared/IDBResultData.cpp:
 171 (WebCore::IDBResultData::openCursorSuccess):
 172 (WebCore::IDBResultData::iterateCursorSuccess):
 173 * Modules/indexeddb/shared/IDBResultData.h:
 174
 175 * Modules/indexeddb/shared/InProcessIDBServer.cpp:
 176 (WebCore::InProcessIDBServer::didOpenCursor):
 177 (WebCore::InProcessIDBServer::didIterateCursor):
 178 (WebCore::InProcessIDBServer::openCursor):
 179 (WebCore::InProcessIDBServer::iterateCursor):
 180 * Modules/indexeddb/shared/InProcessIDBServer.h:
 181
 182 * bindings/js/IDBBindingUtilities.cpp:
 183 (WebCore::idbKeyDataToJSValue):
 184 * bindings/js/IDBBindingUtilities.h:
 185
 186 * platform/CrossThreadCopier.cpp:
 187 (WebCore::IDBCursorInfo>::copy):
 188 * platform/CrossThreadCopier.h:
 189
11902015-11-12 Zalan Bujtas <zalan@apple.com>
2191
3192 Ignore visited background color when deciding if the input renderer needs to be painted natively.

Source/WebCore/Modules/indexeddb/IDBCursor.h

@@public:
6363 virtual const Deprecated::ScriptValue& key() const = 0;
6464 virtual const Deprecated::ScriptValue& primaryKey() const = 0;
6565 virtual const Deprecated::ScriptValue& value() const = 0;
66  virtual IDBAny* source() const = 0;
 66 virtual IDBAny* source() = 0;
6767
6868 virtual RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) = 0;
6969 virtual void advance(unsigned long, ExceptionCode&) = 0;

@@public:
7272 virtual void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) = 0;
7373 virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&) = 0;
7474
 75 virtual bool isKeyCursor() const = 0;
 76
7577protected:
7678 IDBCursor();
77 
78  virtual bool isKeyCursor() const { return true; }
7979};
8080
8181} // namespace WebCore

Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h

@@public:
3838
3939protected:
4040 IDBCursorWithValue();
41 
42  virtual bool isKeyCursor() const override { return false; }
4341};
4442
4543} // namespace WebCore

Source/WebCore/Modules/indexeddb/IDBGetResult.h

@@struct IDBGetResult {
8989
9090 ThreadSafeDataBuffer valueBuffer;
9191 IDBKeyData keyData;
 92 IDBKeyData primaryKeyData;
9293 IDBKeyPath keyPath;
9394};
9495

Source/WebCore/Modules/indexeddb/IDBKeyData.h

@@public:
128128 static IDBKeyData deletedValue();
129129 bool isDeletedValue() const { return m_isDeletedValue; }
130130
 131 String string() const
 132 {
 133 ASSERT(m_type == KeyType::String);
 134 return m_stringValue;
 135 }
 136
 137 double date() const
 138 {
 139 ASSERT(m_type == KeyType::Date);
 140 return m_numberValue;
 141 }
 142
 143 double number() const
 144 {
 145 ASSERT(m_type == KeyType::Number);
 146 return m_numberValue;
 147 }
 148
 149 const Vector<IDBKeyData>& array() const
 150 {
 151 ASSERT(m_type == KeyType::Array);
 152 return m_arrayValue;
 153 }
 154
131155private:
132156 KeyType m_type;
133157 Vector<IDBKeyData> m_arrayValue;

Source/WebCore/Modules/indexeddb/IndexedDB.h

@@enum class CursorType {
6161};
6262const unsigned CursorTypeMaximum = 1;
6363
 64enum class CursorSource {
 65 Index,
 66 ObjectStore,
 67};
 68
6469enum class VersionNullness {
6570 Null,
6671 NonNull,

Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.cpp

2929#if ENABLE(INDEXED_DATABASE)
3030
3131#include "IDBAny.h"
32 #include "IDBCursorWithValue.h"
 32#include "IDBCursorImpl.h"
3333#include "IDBFactory.h"
3434#include "IDBIndex.h"
3535

@@IDBAny::IDBAny(Ref<IDBIndex>&& index)
5959{
6060}
6161
 62IDBAny::IDBAny(Ref<IDBCursor>&& cursor)
 63{
 64 if (cursor->isKeyCursor()) {
 65 m_type = IDBAny::Type::IDBCursor;
 66 m_cursor = WTF::move(cursor);
 67 } else {
 68 m_type = IDBAny::Type::IDBCursorWithValue;
 69 m_cursorWithValue = WTF::move(cursor);
 70 }
 71}
 72
6273IDBAny::IDBAny(const IDBKeyPath& keyPath)
6374 : m_type(IDBAny::Type::KeyPath)
6475 , m_idbKeyPath(keyPath)

@@RefPtr<WebCore::DOMStringList> IDBAny::domStringList()
8899
89100RefPtr<WebCore::IDBCursor> IDBAny::idbCursor()
90101{
91  return nullptr;
 102 ASSERT(m_type == IDBAny::Type::IDBCursor || m_type == IDBAny::Type::IDBCursorWithValue);
 103 return m_cursor.get();
92104}
93105
94106RefPtr<WebCore::IDBCursorWithValue> IDBAny::idbCursorWithValue()
95107{
96  return nullptr;
 108 ASSERT(m_type == IDBAny::Type::IDBCursorWithValue);
 109 return m_cursorWithValue.get();
97110}
98111
99112RefPtr<WebCore::IDBFactory> IDBAny::idbFactory()

@@RefPtr<WebCore::IDBFactory> IDBAny::idbFactory()
103116
104117RefPtr<WebCore::IDBIndex> IDBAny::idbIndex()
105118{
106  return nullptr;
 119 ASSERT(m_type == IDBAny::Type::IDBIndex);
 120 return m_index.get();
107121}
108122
109123RefPtr<WebCore::IDBObjectStore> IDBAny::idbObjectStore()
110124{
111  return nullptr;
 125 ASSERT(m_type == IDBAny::Type::IDBObjectStore);
 126 return m_objectStore.get();
112127}
113128
114129IDBObjectStore* IDBAny::modernIDBObjectStore()

@@IDBIndex* IDBAny::modernIDBIndex()
123138 return m_index.get();
124139}
125140
 141IDBCursor* IDBAny::modernIDBCursor()
 142{
 143 ASSERT(m_type == IDBAny::Type::IDBCursor || m_type == IDBAny::Type::IDBCursorWithValue);
 144 return m_cursor.get();
 145}
 146
126147RefPtr<WebCore::IDBTransaction> IDBAny::idbTransaction()
127148{
128149 return nullptr;

Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.h

@@public:
5353 return adoptRef(new IDBAny(WTF::move(index)));
5454 }
5555
 56 static RefPtr<IDBAny> create(Ref<IDBCursor>&& cursor)
 57 {
 58 return adoptRef(new IDBAny(WTF::move(cursor)));
 59 }
 60
5661 static RefPtr<IDBAny> create(const IDBKeyPath& keyPath)
5762 {
5863 return adoptRef(new IDBAny(keyPath));

@@public:
8691
8792 IDBObjectStore* modernIDBObjectStore();
8893 IDBIndex* modernIDBIndex();
 94 IDBCursor* modernIDBCursor();
8995
9096private:
9197 explicit IDBAny(IDBAny::Type);
9298 explicit IDBAny(Ref<IDBDatabase>&&);
9399 explicit IDBAny(Ref<IDBObjectStore>&&);
94100 explicit IDBAny(Ref<IDBIndex>&&);
 101 explicit IDBAny(Ref<IDBCursor>&&);
95102 explicit IDBAny(const IDBKeyPath&);
96103 explicit IDBAny(const Deprecated::ScriptValue&);
97104

@@private:
99106 RefPtr<IDBDatabase> m_database;
100107 RefPtr<IDBObjectStore> m_objectStore;
101108 RefPtr<IDBIndex> m_index;
 109 RefPtr<IDBCursor> m_cursor;
 110 RefPtr<IDBCursor> m_cursorWithValue;
102111
103112 const IDBKeyPath m_idbKeyPath;
104113 const Deprecated::ScriptValue m_scriptValue;

Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp

@@void IDBConnectionToServer::didDeleteRecord(const IDBResultData& resultData)
217217 completeOperation(resultData);
218218}
219219
 220void IDBConnectionToServer::openCursor(TransactionOperation& operation, const IDBCursorInfo& info)
 221{
 222 LOG(IndexedDB, "IDBConnectionToServer::openCursor");
 223
 224 saveOperation(operation);
 225 m_delegate->openCursor(IDBRequestData(operation), info);
 226}
 227
 228void IDBConnectionToServer::didOpenCursor(const IDBResultData& resultData)
 229{
 230 LOG(IndexedDB, "IDBConnectionToServer::didOpenCursor");
 231 completeOperation(resultData);
 232}
 233
 234void IDBConnectionToServer::iterateCursor(TransactionOperation& operation, const IDBKeyData& key, unsigned long count)
 235{
 236 LOG(IndexedDB, "IDBConnectionToServer::iterateCursor");
 237
 238 saveOperation(operation);
 239 m_delegate->iterateCursor(IDBRequestData(operation), key, count);
 240}
 241
 242void IDBConnectionToServer::didIterateCursor(const IDBResultData& resultData)
 243{
 244 LOG(IndexedDB, "IDBConnectionToServer::didIterateCursor");
 245 completeOperation(resultData);
 246}
 247
220248void IDBConnectionToServer::establishTransaction(IDBTransaction& transaction)
221249{
222250 LOG(IndexedDB, "IDBConnectionToServer::establishTransaction");

Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h

3838
3939namespace WebCore {
4040
 41class IDBCursorInfo;
4142class IDBError;
4243class IDBObjectStoreInfo;
4344class IDBResultData;

@@public:
8586 void deleteRecord(TransactionOperation&, const IDBKeyRangeData&);
8687 void didDeleteRecord(const IDBResultData&);
8788
 89 void openCursor(TransactionOperation&, const IDBCursorInfo&);
 90 void didOpenCursor(const IDBResultData&);
 91
 92 void iterateCursor(TransactionOperation&, const IDBKeyData&, unsigned long count);
 93 void didIterateCursor(const IDBResultData&);
 94
8895 void commitTransaction(IDBTransaction&);
8996 void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
9097

Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h

3232
3333namespace WebCore {
3434
 35class IDBCursorInfo;
3536class IDBIndexInfo;
3637class IDBKey;
 38class IDBKeyData;
3739class IDBObjectStoreInfo;
3840class IDBRequestData;
3941class IDBResourceIdentifier;

@@public:
6567 virtual void getRecord(const IDBRequestData&, const IDBKeyRangeData&) = 0;
6668 virtual void getCount(const IDBRequestData&, const IDBKeyRangeData&) = 0;
6769 virtual void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&) = 0;
 70 virtual void openCursor(const IDBRequestData&, const IDBCursorInfo&) = 0;
 71 virtual void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count) = 0;
 72
6873 virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) = 0;
6974
7075 virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) = 0;

Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp

2828
2929#if ENABLE(INDEXED_DATABASE)
3030
 31#include "DOMRequestState.h"
 32#include "ExceptionCode.h"
 33#include "IDBBindingUtilities.h"
 34#include "IDBDatabaseException.h"
 35#include "IDBGetResult.h"
 36#include "Logging.h"
 37#include "ScriptExecutionContext.h"
 38
3139namespace WebCore {
3240namespace IDBClient {
3341
 42Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
 43{
 44 return adoptRef(*new IDBCursor(transaction, index, info));
 45}
 46
 47IDBCursor::IDBCursor(IDBTransaction&, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 48 : m_info(info)
 49 , m_source(adoptRef(*IDBAny::create(objectStore).leakRef()))
 50 , m_objectStore(&objectStore)
 51{
 52}
 53
 54IDBCursor::IDBCursor(IDBTransaction&, IDBIndex& index, const IDBCursorInfo& info)
 55 : m_info(info)
 56 , m_source(adoptRef(*IDBAny::create(index).leakRef()))
 57 , m_index(&index)
 58{
 59}
 60
3461IDBCursor::~IDBCursor()
3562{
3663}
3764
 65bool IDBCursor::sourcesDeleted() const
 66{
 67 if (m_objectStore)
 68 return m_objectStore->isDeleted();
 69
 70 ASSERT(m_index);
 71 return m_index->isDeleted() || m_index->modernObjectStore().isDeleted();
 72}
 73
 74IDBObjectStore& IDBCursor::effectiveObjectStore() const
 75{
 76 if (m_objectStore)
 77 return *m_objectStore;
 78
 79 ASSERT(m_index);
 80 return m_index->modernObjectStore();
 81}
 82
 83IDBTransaction& IDBCursor::transaction() const
 84{
 85 return effectiveObjectStore().modernTransaction();
 86}
 87
3888const String& IDBCursor::direction() const
3989{
40  RELEASE_ASSERT_NOT_REACHED();
 90 return IDBCursor::directionToString(m_info.cursorDirection());
4191}
4292
4393const Deprecated::ScriptValue& IDBCursor::key() const
4494{
45  RELEASE_ASSERT_NOT_REACHED();
 95 return m_deprecatedCurrentKey;
4696}
4797
4898const Deprecated::ScriptValue& IDBCursor::primaryKey() const
4999{
50  RELEASE_ASSERT_NOT_REACHED();
 100 return m_deprecatedCurrentPrimaryKey;
51101}
52102
53103const Deprecated::ScriptValue& IDBCursor::value() const
54104{
55  RELEASE_ASSERT_NOT_REACHED();
 105 return m_deprecatedCurrentValue;
 106}
 107
 108IDBAny* IDBCursor::source()
 109{
 110 return &m_source.get();
 111}
 112
 113RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCode& ec)
 114{
 115 LOG(IndexedDB, "IDBCursor::advance");
 116
 117 if (sourcesDeleted()) {
 118 ec = IDBDatabaseException::InvalidStateError;
 119 return nullptr;
 120 }
 121
 122 if (!transaction().isActive()) {
 123 ec = IDBDatabaseException::TransactionInactiveError;
 124 return nullptr;
 125 }
 126
 127 if (transaction().isReadOnly()) {
 128 ec = IDBDatabaseException::ReadOnlyError;
 129 return nullptr;
 130 }
 131
 132 if (!m_gotValue) {
 133 ec = IDBDatabaseException::InvalidStateError;
 134 return nullptr;
 135 }
 136
 137 if (isKeyCursor()) {
 138 ec = IDBDatabaseException::InvalidStateError;
 139 return nullptr;
 140 }
 141
 142 return effectiveObjectStore().put(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
 143}
 144
 145void IDBCursor::advance(unsigned long count, ExceptionCode& ec)
 146{
 147 LOG(IndexedDB, "IDBCursor::advance");
 148
 149 if (!m_request) {
 150 ec = IDBDatabaseException::InvalidStateError;
 151 return;
 152 }
 153
 154 if (!count) {
 155 ec = TypeError;
 156 return;
 157 }
 158
 159 if (sourcesDeleted()) {
 160 ec = IDBDatabaseException::InvalidStateError;
 161 return;
 162 }
 163
 164 if (!transaction().isActive()) {
 165 ec = IDBDatabaseException::TransactionInactiveError;
 166 return;
 167 }
 168
 169 if (!m_gotValue) {
 170 ec = IDBDatabaseException::InvalidStateError;
 171 return;
 172 }
 173
 174 uncheckedIteratorCursor(IDBKeyData(), count);
56175}
57176
58 IDBAny* IDBCursor::source() const
 177void IDBCursor::continueFunction(ScriptExecutionContext* context, ExceptionCode& ec)
59178{
60  RELEASE_ASSERT_NOT_REACHED();
 179 if (!context) {
 180 ec = IDBDatabaseException::InvalidStateError;
 181 return;
 182 }
 183
 184 continueFunction(IDBKeyData(), ec);
61185}
62186
63 RefPtr<IDBRequest> IDBCursor::update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&)
 187void IDBCursor::continueFunction(ScriptExecutionContext* context, const Deprecated::ScriptValue& keyValue, ExceptionCode& ec)
64188{
65  RELEASE_ASSERT_NOT_REACHED();
 189 if (!context) {
 190 ec = IDBDatabaseException::InvalidStateError;
 191 return;
 192 }
 193
 194 DOMRequestState requestState(context);
 195 RefPtr<IDBKey> key = scriptValueToIDBKey(&requestState, keyValue);
 196 continueFunction(key.get(), ec);
66197}
67198
68 void IDBCursor::advance(unsigned long, ExceptionCode&)
 199void IDBCursor::continueFunction(const IDBKeyData& key, ExceptionCode& ec)
69200{
70  RELEASE_ASSERT_NOT_REACHED();
 201 LOG(IndexedDB, "IDBCursor::continueFunction");
 202
 203 if (!m_request) {
 204 ec = IDBDatabaseException::InvalidStateError;
 205 return;
 206 }
 207
 208 if (sourcesDeleted()) {
 209 ec = IDBDatabaseException::InvalidStateError;
 210 return;
 211 }
 212
 213 if (!transaction().isActive()) {
 214 ec = IDBDatabaseException::TransactionInactiveError;
 215 return;
 216 }
 217
 218 if (!m_gotValue) {
 219 ec = IDBDatabaseException::InvalidStateError;
 220 return;
 221 }
 222
 223 if (!key.isValid()) {
 224 ec = IDBDatabaseException::DataError;
 225 return;
 226 }
 227
 228 if (m_info.isDirectionForward()) {
 229 if (key.compare(m_currentPrimaryKeyData) <= 0) {
 230 ec = IDBDatabaseException::DataError;
 231 return;
 232 }
 233 } else if (key.compare(m_currentPrimaryKeyData) >= 0) {
 234 ec = IDBDatabaseException::DataError;
 235 return;
 236 }
 237
 238 uncheckedIteratorCursor(key, 0);
71239}
72240
73 void IDBCursor::continueFunction(ScriptExecutionContext*, ExceptionCode&)
 241void IDBCursor::uncheckedIteratorCursor(const IDBKeyData& key, unsigned long count)
74242{
75  RELEASE_ASSERT_NOT_REACHED();
 243 m_request->willIterateCursor(*this);
 244 transaction().iterateCursor(*this, key, count);
76245}
77246
78 void IDBCursor::continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue&, ExceptionCode&)
 247RefPtr<WebCore::IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionCode& ec)
79248{
80  RELEASE_ASSERT_NOT_REACHED();
 249 LOG(IndexedDB, "IDBCursor::deleteFunction");
 250
 251 if (!context) {
 252 ec = IDBDatabaseException::InvalidStateError;
 253 return nullptr;
 254 }
 255
 256 if (sourcesDeleted()) {
 257 ec = IDBDatabaseException::InvalidStateError;
 258 return nullptr;
 259 }
 260
 261 if (!transaction().isActive()) {
 262 ec = IDBDatabaseException::TransactionInactiveError;
 263 return nullptr;
 264 }
 265
 266 if (transaction().isReadOnly()) {
 267 ec = IDBDatabaseException::ReadOnlyError;
 268 return nullptr;
 269 }
 270
 271 if (!m_gotValue) {
 272 ec = IDBDatabaseException::InvalidStateError;
 273 return nullptr;
 274 }
 275
 276 return effectiveObjectStore().deleteFunction(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec);
81277}
82278
83 RefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext*, ExceptionCode&)
 279void IDBCursor::setGetResult(const IDBGetResult&)
84280{
85  RELEASE_ASSERT_NOT_REACHED();
 281 LOG(IndexedDB, "IDBCursor::setGetResult");
 282
 283 // FIXME: Implement.
 284
 285 m_gotValue = true;
86286}
87287
88288} // namespace IDBClient

Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h

2828
2929#if ENABLE(INDEXED_DATABASE)
3030
 31#include "IDBAnyImpl.h"
 32#include "IDBCursorInfo.h"
3133#include "IDBCursorWithValue.h"
3234
3335namespace WebCore {
 36
 37struct IDBGetResult;
 38
3439namespace IDBClient {
3540
 41class IDBIndex;
 42class IDBObjectStore;
 43class IDBTransaction;
 44
3645class IDBCursor : public WebCore::IDBCursorWithValue {
3746public:
 47 static Ref<IDBCursor> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
 48
3849 virtual ~IDBCursor();
3950
4051 // Implement the IDL

@@public:
4253 virtual const Deprecated::ScriptValue& key() const override final;
4354 virtual const Deprecated::ScriptValue& primaryKey() const override final;
4455 virtual const Deprecated::ScriptValue& value() const override final;
45  virtual IDBAny* source() const override final;
 56 virtual IDBAny* source() override final;
4657
47  virtual RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override final;
 58 virtual RefPtr<WebCore::IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override final;
4859 virtual void advance(unsigned long, ExceptionCode&) override final;
4960 virtual void continueFunction(ScriptExecutionContext*, ExceptionCode&) override final;
5061 virtual void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
51  virtual RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&) override final;
 62 virtual RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&) override final;
 63
 64 void continueFunction(const IDBKeyData&, ExceptionCode&);
 65
 66 const IDBCursorInfo& info() const { return m_info; }
 67
 68 void setRequest(IDBRequest& request) { m_request = &request; }
 69 void clearRequest() { m_request = nullptr; }
 70 IDBRequest* request() { return m_request; }
 71
 72 void setGetResult(const IDBGetResult&);
 73
 74 virtual bool isKeyCursor() const override { return true; }
5275
5376protected:
54  IDBCursor();
 77 IDBCursor(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
 78 IDBCursor(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
 79
 80private:
 81 IDBCursorInfo m_info;
 82 Ref<IDBAny> m_source;
 83 IDBObjectStore* m_objectStore { nullptr };
 84 IDBIndex* m_index { nullptr };
 85 IDBRequest* m_request;
 86
 87 bool sourcesDeleted() const;
 88 IDBObjectStore& effectiveObjectStore() const;
 89 IDBTransaction& transaction() const;
 90
 91 void uncheckedIteratorCursor(const IDBKeyData&, unsigned long count);
 92
 93 bool m_gotValue { false };
 94
 95 IDBKeyData m_currentPrimaryKeyData;
 96
 97 // FIXME: When ditching Legacy IDB and combining this implementation with the abstract IDBCursor,
 98 // these Deprecated::ScriptValue members should be JSValues instead.
 99 Deprecated::ScriptValue m_deprecatedCurrentKey;
 100 Deprecated::ScriptValue m_deprecatedCurrentPrimaryKey;
 101 Deprecated::ScriptValue m_deprecatedCurrentValue;
55102};
56103
57104} // namespace IDBClient

Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.cpp

2929#if ENABLE(INDEXED_DATABASE)
3030
3131namespace WebCore {
 32namespace IDBClient {
3233
 34Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 35{
 36 return adoptRef(*new IDBCursorWithValue(transaction, objectStore, info));
 37}
 38
 39Ref<IDBCursorWithValue> IDBCursorWithValue::create(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
 40{
 41 return adoptRef(*new IDBCursorWithValue(transaction, index, info));
 42}
 43
 44IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 45 : IDBCursor(transaction, objectStore, info)
 46{
 47}
 48
 49IDBCursorWithValue::IDBCursorWithValue(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
 50 : IDBCursor(transaction, index, info)
 51{
 52}
 53
 54IDBCursorWithValue::~IDBCursorWithValue()
 55{
 56}
 57
 58} // namespace IDBClient
3359} // namespace WebCore
3460
3561#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/client/IDBCursorWithValueImpl.h

@@namespace IDBClient {
3535
3636class IDBCursorWithValue : public IDBCursor {
3737public:
 38 static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
 39 static Ref<IDBCursorWithValue> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
 40
3841 virtual ~IDBCursorWithValue();
3942
 43 virtual bool isKeyCursor() const override final { return false; }
 44
4045private:
41  IDBCursorWithValue();
 46 IDBCursorWithValue(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
 47 IDBCursorWithValue(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
4248};
4349
4450} // namespace IDBClient

Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.cpp

3131#include "DOMRequestState.h"
3232#include "IDBAnyImpl.h"
3333#include "IDBBindingUtilities.h"
 34#include "IDBCursorImpl.h"
 35#include "IDBDatabaseException.h"
3436#include "IDBKeyRangeData.h"
3537#include "IDBObjectStoreImpl.h"
3638#include "IDBTransactionImpl.h"

@@bool IDBIndex::multiEntry() const
8486 return m_info.multiEntry();
8587}
8688
87 RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext*, IDBKeyRange*, const String&, ExceptionCode&)
 89RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, IDBKeyRange* range, const String& directionString, ExceptionCode& ec)
8890{
89  RELEASE_ASSERT_NOT_REACHED();
 91 LOG(IndexedDB, "IDBIndex::openCursor");
 92
 93 if (m_deleted || m_objectStore->isDeleted()) {
 94 ec = IDBDatabaseException::InvalidStateError;
 95 return nullptr;
 96 }
 97
 98 if (!m_objectStore->modernTransaction().isActive()) {
 99 ec = IDBDatabaseException::TransactionInactiveError;
 100 return nullptr;
 101 }
 102
 103 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec);
 104 if (ec)
 105 return nullptr;
 106
 107 auto info = IDBCursorInfo::indexCursor(m_objectStore->modernTransaction(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyAndValue);
 108 Ref<IDBRequest> request = m_objectStore->modernTransaction().requestOpenCursor(*context, *this, info);
 109 return WTF::move(request);
90110}
91111
92 RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue&, const String&, ExceptionCode&)
 112RefPtr<WebCore::IDBRequest> IDBIndex::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode& ec)
93113{
94  RELEASE_ASSERT_NOT_REACHED();
 114 LOG(IndexedDB, "IDBIndex::openCursor");
 115 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
 116 if (ec)
 117 return nullptr;
 118
 119 return openCursor(context, keyRange.get(), direction, ec);
95120}
96121
97122RefPtr<WebCore::IDBRequest> IDBIndex::count(ScriptExecutionContext* context, ExceptionCode& ec)

@@RefPtr<WebCore::IDBRequest> IDBIndex::doCount(ScriptExecutionContext& context, c
159184 return transaction.requestCount(context, *this, range);
160185}
161186
162 RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext*, IDBKeyRange*, const String&, ExceptionCode&)
 187RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, IDBKeyRange* range, const String& directionString, ExceptionCode& ec)
163188{
164  RELEASE_ASSERT_NOT_REACHED();
 189 LOG(IndexedDB, "IDBIndex::openKeyCursor");
 190
 191 if (m_deleted || m_objectStore->isDeleted()) {
 192 ec = IDBDatabaseException::InvalidStateError;
 193 return nullptr;
 194 }
 195
 196 if (!m_objectStore->modernTransaction().isActive()) {
 197 ec = IDBDatabaseException::TransactionInactiveError;
 198 return nullptr;
 199 }
 200
 201 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec);
 202 if (ec)
 203 return nullptr;
 204
 205 auto info = IDBCursorInfo::indexCursor(m_objectStore->modernTransaction(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly);
 206 Ref<IDBRequest> request = m_objectStore->modernTransaction().requestOpenCursor(*context, *this, info);
 207 return WTF::move(request);
165208}
166209
167 RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext*, const Deprecated::ScriptValue&, const String&, ExceptionCode&)
 210RefPtr<WebCore::IDBRequest> IDBIndex::openKeyCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode& ec)
168211{
169  RELEASE_ASSERT_NOT_REACHED();
 212 LOG(IndexedDB, "IDBIndex::openKeyCursor");
 213 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
 214 if (ec)
 215 return nullptr;
 216
 217 return openKeyCursor(context, keyRange.get(), direction, ec);
170218}
171219
172220RefPtr<WebCore::IDBRequest> IDBIndex::get(ScriptExecutionContext* context, IDBKeyRange* range, ExceptionCode& ec)

Source/WebCore/Modules/indexeddb/client/IDBIndexImpl.h

@@public:
7777
7878 const IDBIndexInfo& info() const { return m_info; }
7979
 80 IDBObjectStore& modernObjectStore() { return m_objectStore.get(); }
 81 bool isDeleted() const { return m_deleted; }
 82
8083private:
8184 IDBIndex(const IDBIndexInfo&, IDBObjectStore&);
8285

Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp

3030
3131#include "DOMRequestState.h"
3232#include "IDBBindingUtilities.h"
 33#include "IDBCursorImpl.h"
3334#include "IDBDatabaseException.h"
3435#include "IDBError.h"
3536#include "IDBIndexImpl.h"

@@bool IDBObjectStore::autoIncrement() const
8990 return m_info.autoIncrement();
9091}
9192
92 RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext*, ExceptionCode&)
 93RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, ExceptionCode& ec)
9394{
94  RELEASE_ASSERT_NOT_REACHED();
 95 return openCursor(context, static_cast<IDBKeyRange*>(nullptr), ec);
9596}
9697
97 RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&)
 98RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCode& ec)
9899{
99  RELEASE_ASSERT_NOT_REACHED();
 100 return openCursor(context, keyRange, IDBCursor::directionNext(), ec);
100101}
101102
102 RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue&, ExceptionCode&)
 103RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec)
103104{
104  RELEASE_ASSERT_NOT_REACHED();
 105 return openCursor(context, key, IDBCursor::directionNext(), ec);
105106}
106107
107 RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext*, IDBKeyRange*, const String&, ExceptionCode&)
 108RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, IDBKeyRange* range, const String& directionString, ExceptionCode& ec)
108109{
109  RELEASE_ASSERT_NOT_REACHED();
 110 LOG(IndexedDB, "IDBObjectStore::openCursor");
 111
 112 if (m_deleted) {
 113 ec = IDBDatabaseException::InvalidStateError;
 114 return nullptr;
 115 }
 116
 117 if (!m_transaction->isActive()) {
 118 ec = IDBDatabaseException::TransactionInactiveError;
 119 return nullptr;
 120 }
 121
 122 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directionString, ec);
 123 if (ec)
 124 return nullptr;
 125
 126 auto info = IDBCursorInfo::objectStoreCursor(m_transaction.get(), m_info.identifier(), range, direction);
 127 Ref<IDBRequest> request = m_transaction->requestOpenCursor(*context, *this, info);
 128 return WTF::move(request);
110129}
111130
112 RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext*, const Deprecated::ScriptValue&, const String&, ExceptionCode&)
 131RefPtr<WebCore::IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, const String& direction, ExceptionCode& ec)
113132{
114  RELEASE_ASSERT_NOT_REACHED();
 133 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::only(context, key, ec);
 134 if (ec)
 135 return 0;
 136
 137 return openCursor(context, keyRange.get(), direction, ec);
115138}
116139
117140RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec)

@@RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContex
308331
309332RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec)
310333{
 334 return deleteFunction(context, key.jsValue(), ec);
 335}
 336
 337RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, JSC::JSValue key, ExceptionCode& ec)
 338{
311339 DOMRequestState requestState(context);
312340 RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
313341 if (!idbKey || idbKey->type() == KeyType::Invalid) {

Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h

@@public:
7878 virtual RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&) override final;
7979 virtual RefPtr<WebCore::IDBRequest> count(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override final;
8080
 81 RefPtr<WebCore::IDBRequest> deleteFunction(ScriptExecutionContext*, JSC::JSValue key, ExceptionCode&);
 82
8183 void markAsDeleted();
8284 bool isDeleted() const { return m_deleted; }
8385

Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp

3131#include "DOMRequestState.h"
3232#include "EventQueue.h"
3333#include "IDBBindingUtilities.h"
 34#include "IDBCursorImpl.h"
3435#include "IDBEventDispatcher.h"
3536#include "IDBKeyData.h"
3637#include "IDBResultData.h"

@@Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBObjectSto
4748 return adoptRef(*new IDBRequest(context, objectStore, transaction));
4849}
4950
 51Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
 52{
 53 return adoptRef(*new IDBRequest(context, cursor, transaction));
 54}
 55
5056Ref<IDBRequest> IDBRequest::createCount(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
5157{
5258 return adoptRef(*new IDBRequest(context, index, transaction));

@@IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectSt
7581 suspendIfNeeded();
7682}
7783
 84IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
 85 : IDBOpenDBRequest(&context)
 86 , m_transaction(&transaction)
 87 , m_connection(transaction.serverConnection())
 88 , m_resourceIdentifier(transaction.serverConnection())
 89 , m_pendingCursor(&cursor)
 90{
 91 suspendIfNeeded();
 92
 93 cursor.setRequest(*this);
 94
 95 auto* cursorSource = cursor.source();
 96 ASSERT(cursorSource);
 97 ASSERT(cursorSource->type() == IDBAny::Type::IDBObjectStore || cursorSource->type() == IDBAny::Type::IDBIndex);
 98 m_source = cursorSource;
 99}
 100
78101IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
79102 : IDBOpenDBRequest(&context)
80103 , m_transaction(&transaction)

@@IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, Indexed
93116
94117IDBRequest::~IDBRequest()
95118{
 119 if (m_result) {
 120 auto type = m_result->type();
 121 if (type == IDBAny::Type::IDBCursor || type == IDBAny::Type::IDBCursorWithValue)
 122 m_result->modernIDBCursor()->clearRequest();
 123 }
96124}
97125
98126RefPtr<WebCore::IDBAny> IDBRequest::result(ExceptionCode&) const

@@RefPtr<DOMError> IDBRequest::error(ExceptionCode&) const
112140
113141RefPtr<WebCore::IDBAny> IDBRequest::source() const
114142{
115  return nullptr;
 143 return m_source;
116144}
117145
118146RefPtr<WebCore::IDBTransaction> IDBRequest::transaction() const

@@void IDBRequest::setResultToUndefined()
261289 m_result = IDBAny::createUndefined();
262290}
263291
 292IDBCursor* IDBRequest::resultCursor()
 293{
 294 if (!m_result)
 295 return nullptr;
 296 if (m_result->type() == IDBAny::Type::IDBCursor || m_result->type() == IDBAny::Type::IDBCursorWithValue)
 297 return m_result->modernIDBCursor();
 298 return nullptr;
 299}
 300
 301void IDBRequest::willIterateCursor(IDBCursor& cursor)
 302{
 303 ASSERT(m_readyState == IDBRequestReadyState::Done);
 304 ASSERT(scriptExecutionContext());
 305 ASSERT(m_transaction);
 306 ASSERT(!m_pendingCursor);
 307 ASSERT(&cursor == resultCursor());
 308
 309 m_pendingCursor = &cursor;
 310 m_result = nullptr;
 311 m_readyState = IDBRequestReadyState::Pending;
 312 m_domError = nullptr;
 313 m_idbError = { };
 314}
 315
 316void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
 317{
 318 ASSERT(m_pendingCursor);
 319 if (resultData.type() == IDBResultType::IterateCursorSuccess)
 320 m_pendingCursor->setGetResult(resultData.getResult());
 321
 322 m_result = IDBAny::create(*m_pendingCursor);
 323 m_pendingCursor = nullptr;
 324
 325 requestCompleted(resultData);
 326}
 327
264328void IDBRequest::requestCompleted(const IDBResultData& resultData)
265329{
 330 m_readyState = IDBRequestReadyState::Done;
 331
266332 m_idbError = resultData.error();
267333 if (!m_idbError.isNull())
268334 onError();

Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h

@@class IDBConnectionToServer;
5252class IDBRequest : public WebCore::IDBOpenDBRequest, public RefCounted<IDBRequest> {
5353public:
5454 static Ref<IDBRequest> create(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&);
 55 static Ref<IDBRequest> create(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
5556 static Ref<IDBRequest> createCount(ScriptExecutionContext&, IDBIndex&, IDBTransaction&);
5657 static Ref<IDBRequest> createGet(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
5758

@@public:
8990 void setResultToStructuredClone(const ThreadSafeDataBuffer&);
9091 void setResultToUndefined();
9192
 93 IDBAny* modernResult() { return m_result.get(); }
 94
 95 void willIterateCursor(IDBCursor&);
 96 void didOpenOrIterateCursor(const IDBResultData&);
 97
9298protected:
9399 IDBRequest(IDBConnectionToServer&, ScriptExecutionContext*);
94100 IDBRequest(ScriptExecutionContext&, IDBObjectStore&, IDBTransaction&);
 101 IDBRequest(ScriptExecutionContext&, IDBCursor&, IDBTransaction&);
95102 IDBRequest(ScriptExecutionContext&, IDBIndex&, IDBTransaction&);
96103 IDBRequest(ScriptExecutionContext&, IDBIndex&, IndexedDB::IndexRecordType, IDBTransaction&);
97104

@@private:
114121 void onError();
115122 void onSuccess();
116123
 124 IDBCursor* resultCursor();
 125
117126 IDBConnectionToServer& m_connection;
118127 IDBResourceIdentifier m_resourceIdentifier;
119128 RefPtr<IDBAny> m_source;
120129 bool m_hasPendingActivity { true };
121130 IndexedDB::IndexRecordType m_requestedIndexRecordType;
 131
 132 RefPtr<IDBCursor> m_pendingCursor;
122133};
123134
124135} // namespace IDBClient

Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp

3030
3131#include "DOMError.h"
3232#include "EventQueue.h"
 33#include "IDBCursorWithValueImpl.h"
3334#include "IDBDatabaseImpl.h"
3435#include "IDBError.h"
3536#include "IDBEventDispatcher.h"
 37#include "IDBKeyData.h"
3638#include "IDBKeyRangeData.h"
3739#include "IDBObjectStore.h"
3840#include "IDBRequestImpl.h"

@@void IDBTransaction::didCreateIndexOnServer(const IDBResultData& resultData)
431433 ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateIndexSuccess);
432434}
433435
 436Ref<IDBRequest> IDBTransaction::requestOpenCursor(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 437{
 438 LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
 439
 440 return doRequestOpenCursor(context, IDBCursorWithValue::create(*this, objectStore, info));
 441}
 442
 443Ref<IDBRequest> IDBTransaction::requestOpenCursor(ScriptExecutionContext& context, IDBIndex& index, const IDBCursorInfo& info)
 444{
 445 LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
 446
 447 if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
 448 return doRequestOpenCursor(context, IDBCursor::create(*this, index, info));
 449
 450 return doRequestOpenCursor(context, IDBCursorWithValue::create(*this, index, info));
 451}
 452
 453Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(ScriptExecutionContext& context, Ref<IDBCursor>&& cursor)
 454{
 455 ASSERT(isActive());
 456
 457 Ref<IDBRequest> request = IDBRequest::create(context, cursor.get(), *this);
 458 addRequest(request.get());
 459
 460 auto operation = createTransactionOperation(*this, request.get(), &IDBTransaction::didOpenCursorOnServer, &IDBTransaction::openCursorOnServer, cursor->info());
 461 scheduleOperation(WTF::move(operation));
 462
 463 return WTF::move(request);
 464}
 465
 466void IDBTransaction::openCursorOnServer(TransactionOperation& operation, const IDBCursorInfo& info)
 467{
 468 LOG(IndexedDB, "IDBTransaction::openCursorOnServer");
 469
 470 m_database->serverConnection().openCursor(operation, info);
 471}
 472
 473void IDBTransaction::didOpenCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
 474{
 475 LOG(IndexedDB, "IDBTransaction::didOpenCursorOnServer");
 476
 477 request.didOpenOrIterateCursor(resultData);
 478}
 479
 480void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBKeyData& key, unsigned long count)
 481{
 482 LOG(IndexedDB, "IDBTransaction::iterateCursor");
 483 ASSERT(isActive());
 484 ASSERT(cursor.request());
 485
 486 addRequest(*cursor.request());
 487
 488 auto operation = createTransactionOperation(*this, *cursor.request(), &IDBTransaction::didIterateCursorOnServer, &IDBTransaction::iterateCursorOnServer, key, count);
 489 scheduleOperation(WTF::move(operation));
 490}
 491
 492void IDBTransaction::iterateCursorOnServer(TransactionOperation& operation, const IDBKeyData& key, const unsigned long& count)
 493{
 494 LOG(IndexedDB, "IDBTransaction::iterateCursorOnServer");
 495
 496 serverConnection().iterateCursor(operation, key, count);
 497}
 498
 499void IDBTransaction::didIterateCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
 500{
 501 LOG(IndexedDB, "IDBTransaction::didIterateCursorOnServer");
 502
 503 request.didOpenOrIterateCursor(resultData);
 504}
 505
434506Ref<IDBRequest> IDBTransaction::requestGetRecord(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBKeyRangeData& keyRangeData)
435507{
436508 LOG(IndexedDB, "IDBTransaction::requestGetRecord");

Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h

4141
4242namespace WebCore {
4343
 44class IDBCursorInfo;
4445class IDBIndexInfo;
 46class IDBKeyData;
4547class IDBObjectStoreInfo;
4648class IDBResultData;
4749

@@struct IDBKeyRangeData;
4951
5052namespace IDBClient {
5153
 54class IDBCursor;
5255class IDBDatabase;
5356class IDBIndex;
5457class TransactionOperation;

@@public:
101104 Ref<IDBRequest> requestCount(ScriptExecutionContext&, IDBIndex&, const IDBKeyRangeData&);
102105 Ref<IDBRequest> requestGetValue(ScriptExecutionContext&, IDBIndex&, const IDBKeyRangeData&);
103106 Ref<IDBRequest> requestGetKey(ScriptExecutionContext&, IDBIndex&, const IDBKeyRangeData&);
 107 Ref<IDBRequest> requestOpenCursor(ScriptExecutionContext&, IDBObjectStore&, const IDBCursorInfo&);
 108 Ref<IDBRequest> requestOpenCursor(ScriptExecutionContext&, IDBIndex&, const IDBCursorInfo&);
 109 void iterateCursor(IDBCursor&, const IDBKeyData&, unsigned long count);
104110
105111 void deleteObjectStore(const String& objectStoreName);
106112

@@private:
159165 void deleteObjectStoreOnServer(TransactionOperation&, const String& objectStoreName);
160166 void didDeleteObjectStoreOnServer(const IDBResultData&);
161167
 168 Ref<IDBRequest> doRequestOpenCursor(ScriptExecutionContext&, Ref<IDBCursor>&&);
 169 void openCursorOnServer(TransactionOperation&, const IDBCursorInfo&);
 170 void didOpenCursorOnServer(IDBRequest&, const IDBResultData&);
 171
 172 void iterateCursorOnServer(TransactionOperation&, const IDBKeyData&, const unsigned long& count);
 173 void didIterateCursorOnServer(IDBRequest&, const IDBResultData&);
 174
162175 void establishOnServer();
163176
164177 void scheduleOperationTimer();

Source/WebCore/Modules/indexeddb/client/TransactionOperation.h

@@RefPtr<TransactionOperation> createTransactionOperation(
148148 return adoptRef(operation);
149149}
150150
 151template<typename MP1, typename P1, typename MP2, typename P2>
 152RefPtr<TransactionOperation> createTransactionOperation(
 153 IDBTransaction& transaction,
 154 IDBRequest& request,
 155 void (IDBTransaction::*complete)(IDBRequest&, const IDBResultData&),
 156 void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2),
 157 const P1& parameter1,
 158 const P2& parameter2)
 159{
 160 auto operation = new TransactionOperationImpl<MP1, MP2>(transaction, request, complete, perform, parameter1, parameter2);
 161 return adoptRef(operation);
 162}
 163
151164template<typename MP1, typename MP2, typename MP3, typename P1, typename P2, typename P3>
152165RefPtr<TransactionOperation> createTransactionOperation(
153166 IDBTransaction& transaction,

Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.cpp

@@const Deprecated::ScriptValue& LegacyCursor::value() const
9191 return m_currentValue;
9292}
9393
94 IDBAny* LegacyCursor::source() const
 94IDBAny* LegacyCursor::source()
9595{
9696 return m_source.get();
9797}

Source/WebCore/Modules/indexeddb/legacy/LegacyCursor.h

@@public:
5555 virtual ~LegacyCursor();
5656
5757 // Implement the IDL
58  const String& direction() const;
59  const Deprecated::ScriptValue& key() const;
60  const Deprecated::ScriptValue& primaryKey() const;
61  const Deprecated::ScriptValue& value() const;
62  IDBAny* source() const;
63 
64  RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&);
65  void advance(unsigned long, ExceptionCode&);
 58 const String& direction() const override;
 59 const Deprecated::ScriptValue& key() const override;
 60 const Deprecated::ScriptValue& primaryKey() const override;
 61 const Deprecated::ScriptValue& value() const override;
 62 IDBAny* source() override;
 63
 64 RefPtr<IDBRequest> update(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&) override;
 65 void advance(unsigned long, ExceptionCode&) override;
6666 // FIXME: Try to modify the code generator so this overload is unneeded.
67  void continueFunction(ScriptExecutionContext*, ExceptionCode& ec) { continueFunction(static_cast<IDBKey*>(nullptr), ec); }
68  void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&);
69  RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&);
 67 void continueFunction(ScriptExecutionContext*, ExceptionCode& ec) override { continueFunction(static_cast<IDBKey*>(nullptr), ec); }
 68 void continueFunction(ScriptExecutionContext*, const Deprecated::ScriptValue& key, ExceptionCode&) override;
 69 RefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, ExceptionCode&) override;
7070
7171 void continueFunction(PassRefPtr<IDBKey>, ExceptionCode&);
7272 void postSuccessHandlerCallback();

@@public:
7474 void setValueReady(DOMRequestState*, PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, Deprecated::ScriptValue&);
7575 PassRefPtr<IDBKey> idbPrimaryKey() { return m_currentPrimaryKey; }
7676
 77 virtual bool isKeyCursor() const override { return true; }
 78
7779protected:
7880 LegacyCursor(PassRefPtr<IDBCursorBackend>, IndexedDB::CursorDirection, LegacyRequest*, LegacyAny* source, LegacyTransaction*);
79  virtual bool isKeyCursor() const { return true; }
8081
8182private:
8283 PassRefPtr<LegacyObjectStore> effectiveObjectStore();

Source/WebCore/Modules/indexeddb/legacy/LegacyCursorWithValue.h

@@public:
4141 // The value attribute defined in the IDL is simply implemented in LegacyCursor (but not exposed via
4242 // its IDL). This is to make the implementation more simple while matching what the spec says.
4343
44 protected:
45  virtual bool isKeyCursor() const override { return false; }
 44 virtual bool isKeyCursor() const override final { return false; }
4645
4746private:
4847 LegacyCursorWithValue(PassRefPtr<IDBCursorBackend>, IndexedDB::CursorDirection, LegacyRequest*, LegacyAny* source, LegacyTransaction*);

Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h

3333
3434namespace WebCore {
3535
 36class IDBCursorInfo;
3637class IDBIndexInfo;
3738class IDBKeyData;
3839class IDBObjectStoreInfo;

@@public:
7071 virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
7172 virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
7273 virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) = 0;
73 
 74 virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) = 0;
 75 virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBKeyData&, unsigned long count, IDBGetResult& outResult) = 0;
7476};
7577
7678} // namespace IDBServer

Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp

@@void IDBConnectionToClient::didDeleteRecord(const IDBResultData& result)
103103 m_delegate->didDeleteRecord(result);
104104}
105105
 106void IDBConnectionToClient::didOpenCursor(const IDBResultData& result)
 107{
 108 m_delegate->didOpenCursor(result);
 109}
 110
 111void IDBConnectionToClient::didIterateCursor(const IDBResultData& result)
 112{
 113 m_delegate->didIterateCursor(result);
 114}
 115
106116void IDBConnectionToClient::didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
107117{
108118 m_delegate->didCommitTransaction(transactionIdentifier, error);

Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h

@@public:
6060 void didGetRecord(const IDBResultData&);
6161 void didGetCount(const IDBResultData&);
6262 void didDeleteRecord(const IDBResultData&);
 63 void didOpenCursor(const IDBResultData&);
 64 void didIterateCursor(const IDBResultData&);
6365
6466 void fireVersionChangeEvent(UniqueIDBDatabaseConnection&, uint64_t requestedVersion);
6567 void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);

Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h

@@public:
5656 virtual void didGetRecord(const IDBResultData&) = 0;
5757 virtual void didGetCount(const IDBResultData&) = 0;
5858 virtual void didDeleteRecord(const IDBResultData&) = 0;
 59 virtual void didOpenCursor(const IDBResultData&) = 0;
 60 virtual void didIterateCursor(const IDBResultData&) = 0;
5961
6062 virtual void fireVersionChangeEvent(UniqueIDBDatabaseConnection&, uint64_t requestedVersion) = 0;
6163 virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) = 0;

Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

@@void IDBServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRang
247247 transaction->deleteRecord(requestData, keyRangeData);
248248}
249249
 250void IDBServer::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info)
 251{
 252 LOG(IndexedDB, "IDBServer::openCursor");
 253
 254 auto transaction = m_transactions.get(requestData.transactionIdentifier());
 255 if (!transaction)
 256 return;
 257
 258 transaction->openCursor(requestData, info);
 259}
 260
 261void IDBServer::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count)
 262{
 263 LOG(IndexedDB, "IDBServer::iterateCursor");
 264
 265 auto transaction = m_transactions.get(requestData.transactionIdentifier());
 266 if (!transaction)
 267 return;
 268
 269 transaction->iterateCursor(requestData, key, count);
 270}
 271
250272void IDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
251273{
252274 LOG(IndexedDB, "IDBServer::establishTransaction");

Source/WebCore/Modules/indexeddb/server/IDBServer.h

4343namespace WebCore {
4444
4545class CrossThreadTask;
 46class IDBCursorInfo;
4647class IDBRequestData;
4748
4849namespace IDBServer {

@@public:
6768 void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
6869 void getCount(const IDBRequestData&, const IDBKeyRangeData&);
6970 void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&);
 71 void openCursor(const IDBRequestData&, const IDBCursorInfo&);
 72 void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count);
 73
7074 void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
7175 void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
7276

Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

@@IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier& t
329329 return IDBError();
330330}
331331
 332IDBError MemoryIDBBackingStore::openCursor(const IDBResourceIdentifier&, const IDBCursorInfo&, IDBGetResult&)
 333{
 334 LOG(IndexedDB, "MemoryIDBBackingStore::openCursor");
 335
 336 // FIXME: Implement.
 337
 338 return { IDBExceptionCode::Unknown };
 339}
 340
 341IDBError MemoryIDBBackingStore::iterateCursor(const IDBResourceIdentifier&, const IDBKeyData&, unsigned long, IDBGetResult&)
 342{
 343 LOG(IndexedDB, "MemoryIDBBackingStore::iterateCursor");
 344
 345 // FIXME: Implement.
 346
 347 return { IDBExceptionCode::Unknown };
 348}
 349
332350void MemoryIDBBackingStore::registerObjectStore(std::unique_ptr<MemoryObjectStore>&& objectStore)
333351{
334352 ASSERT(objectStore);

Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h

@@public:
6363 virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) override final;
6464 virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) override final;
6565 virtual IDBError generateKeyNumber(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t& keyNumber) override final;
 66 virtual IDBError openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&, IDBGetResult& outResult) override final;
 67 virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBKeyData&, unsigned long count, IDBGetResult& outResult) override final;
6668
6769 void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
6870 void restoreObjectStoreForVersionChangeAbort(std::unique_ptr<MemoryObjectStore>&&);

Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

2828
2929#if ENABLE(INDEXED_DATABASE)
3030
 31#include "IDBCursorInfo.h"
3132#include "IDBKeyRangeData.h"
3233#include "IDBResultData.h"
3334#include "IDBServer.h"

@@void UniqueIDBDatabase::didPerformDeleteRecord(uint64_t callbackIdentifier, cons
552553 performErrorCallback(callbackIdentifier, error);
553554}
554555
 556void UniqueIDBDatabase::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info, GetResultCallback callback)
 557{
 558 ASSERT(isMainThread());
 559 LOG(IndexedDB, "(main) UniqueIDBDatabase::openCursor");
 560
 561 uint64_t callbackID = storeCallback(callback);
 562 m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performOpenCursor, callbackID, requestData.transactionIdentifier(), info));
 563}
 564
 565void UniqueIDBDatabase::performOpenCursor(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info)
 566{
 567 ASSERT(!isMainThread());
 568 LOG(IndexedDB, "(db) UniqueIDBDatabase::performOpenCursor");
 569
 570 IDBGetResult result;
 571 IDBError error = m_backingStore->openCursor(transactionIdentifier, info, result);
 572
 573 m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformOpenCursor, callbackIdentifier, error, result));
 574}
 575
 576void UniqueIDBDatabase::didPerformOpenCursor(uint64_t callbackIdentifier, const IDBError& error, const IDBGetResult& result)
 577{
 578 ASSERT(isMainThread());
 579 LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformOpenCursor");
 580
 581 performGetResultCallback(callbackIdentifier, error, result);
 582}
 583
 584void UniqueIDBDatabase::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count, GetResultCallback callback)
 585{
 586 ASSERT(isMainThread());
 587 LOG(IndexedDB, "(main) UniqueIDBDatabase::iterateCursor");
 588
 589 uint64_t callbackID = storeCallback(callback);
 590 m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performIterateCursor, callbackID, requestData.transactionIdentifier(), key, count));
 591}
 592
 593void UniqueIDBDatabase::performIterateCursor(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBKeyData& key, unsigned long count)
 594{
 595 ASSERT(!isMainThread());
 596 LOG(IndexedDB, "(db) UniqueIDBDatabase::performIterateCursor");
 597
 598 IDBGetResult result;
 599 IDBError error = m_backingStore->iterateCursor(transactionIdentifier, key, count, result);
 600
 601 m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformIterateCursor, callbackIdentifier, error, result));
 602}
 603
 604void UniqueIDBDatabase::didPerformIterateCursor(uint64_t callbackIdentifier, const IDBError& error, const IDBGetResult& result)
 605{
 606 ASSERT(isMainThread());
 607 LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformIterateCursor");
 608
 609 performGetResultCallback(callbackIdentifier, error, result);
 610}
 611
555612void UniqueIDBDatabase::commitTransaction(UniqueIDBDatabaseTransaction& transaction, ErrorCallback callback)
556613{
557614 ASSERT(isMainThread());

Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h

@@public:
8383 void getRecord(const IDBRequestData&, const IDBKeyRangeData&, GetResultCallback);
8484 void getCount(const IDBRequestData&, const IDBKeyRangeData&, CountCallback);
8585 void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&, ErrorCallback);
 86 void openCursor(const IDBRequestData&, const IDBCursorInfo&, GetResultCallback);
 87 void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count, GetResultCallback);
8688 void commitTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
8789 void abortTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
8890 void transactionDestroyed(UniqueIDBDatabaseTransaction&);

@@private:
117119 void performGetIndexRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&);
118120 void performGetCount(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&);
119121 void performDeleteRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
 122 void performOpenCursor(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo&);
 123 void performIterateCursor(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBKeyData&, unsigned long count);
120124 void performActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBTransactionInfo&);
121125
122126 // Main thread callbacks

@@private:
129133 void didPerformGetRecord(uint64_t callbackIdentifier, const IDBError&, const IDBGetResult&);
130134 void didPerformGetCount(uint64_t callbackIdentifier, const IDBError&, uint64_t);
131135 void didPerformDeleteRecord(uint64_t callbackIdentifier, const IDBError&);
 136 void didPerformOpenCursor(uint64_t callbackIdentifier, const IDBError&, const IDBGetResult&);
 137 void didPerformIterateCursor(uint64_t callbackIdentifier, const IDBError&, const IDBGetResult&);
132138 void didPerformCommitTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
133139 void didPerformAbortTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
134140 void didPerformActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBError&);

Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp

@@void UniqueIDBDatabaseTransaction::deleteRecord(const IDBRequestData& requestDat
232232 });
233233}
234234
 235void UniqueIDBDatabaseTransaction::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info)
 236{
 237 LOG(IndexedDB, "UniqueIDBDatabaseTransaction::openCursor");
 238
 239 ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
 240
 241 RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this);
 242 m_databaseConnection->database().openCursor(requestData, info, [this, protectedThis, requestData](const IDBError& error, const IDBGetResult& result) {
 243 LOG(IndexedDB, "UniqueIDBDatabaseTransaction::openCursor (callback)");
 244
 245 if (error.isNull())
 246 m_databaseConnection->connectionToClient().didOpenCursor(IDBResultData::openCursorSuccess(requestData.requestIdentifier(), result));
 247 else
 248 m_databaseConnection->connectionToClient().didOpenCursor(IDBResultData::error(requestData.requestIdentifier(), error));
 249 });
 250}
 251
 252void UniqueIDBDatabaseTransaction::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count)
 253{
 254 LOG(IndexedDB, "UniqueIDBDatabaseTransaction::iterateCursor");
 255
 256 ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
 257
 258 RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this);
 259 m_databaseConnection->database().iterateCursor(requestData, key, count, [this, protectedThis, requestData](const IDBError& error, const IDBGetResult& result) {
 260 LOG(IndexedDB, "UniqueIDBDatabaseTransaction::openCursor (callback)");
 261
 262 if (error.isNull())
 263 m_databaseConnection->connectionToClient().didIterateCursor(IDBResultData::iterateCursorSuccess(requestData.requestIdentifier(), result));
 264 else
 265 m_databaseConnection->connectionToClient().didIterateCursor(IDBResultData::error(requestData.requestIdentifier(), error));
 266 });
 267}
 268
235269const Vector<uint64_t>& UniqueIDBDatabaseTransaction::objectStoreIdentifiers()
236270{
237271 if (!m_objectStoreIdentifiers.isEmpty())

Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h

3535
3636namespace WebCore {
3737
 38class IDBCursorInfo;
3839class IDBDatabaseInfo;
3940class IDBError;
4041class IDBIndexInfo;

@@public:
7374 void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
7475 void getCount(const IDBRequestData&, const IDBKeyRangeData&);
7576 void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&);
 77 void openCursor(const IDBRequestData&, const IDBCursorInfo&);
 78 void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count);
7679
7780 void didActivateInBackingStore(const IDBError&);
7881

Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp

 1/*
 2 * Copyright (C) 2015 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "IDBCursorInfo.h"
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBTransactionImpl.h"
 32#include "IndexedDB.h"
 33
 34namespace WebCore {
 35
 36IDBCursorInfo IDBCursorInfo::objectStoreCursor(IDBClient::IDBTransaction& transaction, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range, IndexedDB::CursorDirection direction)
 37{
 38 return { transaction, IndexedDB::CursorSource::ObjectStore, objectStoreIdentifier, range, direction, IndexedDB::CursorType::KeyAndValue };
 39}
 40
 41IDBCursorInfo IDBCursorInfo::indexCursor(IDBClient::IDBTransaction& transaction, uint64_t indexIdentifier, const IDBKeyRangeData& range, IndexedDB::CursorDirection direction, IndexedDB::CursorType type)
 42{
 43 return { transaction, IndexedDB::CursorSource::Index, indexIdentifier, range, direction, type };
 44}
 45
 46IDBCursorInfo::IDBCursorInfo(IDBClient::IDBTransaction& transaction, IndexedDB::CursorSource source, uint64_t sourceIdentifier, const IDBKeyRangeData& range, IndexedDB::CursorDirection direction, IndexedDB::CursorType type)
 47 : m_cursorIdentifier(transaction.serverConnection())
 48 , m_transactionIdentifier(transaction.info().identifier())
 49 , m_sourceIdentifier(sourceIdentifier)
 50 , m_range(range)
 51 , m_source(source)
 52 , m_direction(direction)
 53 , m_type(type)
 54{
 55}
 56
 57IDBCursorInfo::IDBCursorInfo(const IDBResourceIdentifier& cursorIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t sourceIdentifier, const IDBKeyRangeData& range, IndexedDB::CursorSource source, IndexedDB::CursorDirection direction, IndexedDB::CursorType type)
 58 : m_cursorIdentifier(cursorIdentifier)
 59 , m_transactionIdentifier(transactionIdentifier)
 60 , m_sourceIdentifier(sourceIdentifier)
 61 , m_range(range)
 62 , m_source(source)
 63 , m_direction(direction)
 64 , m_type(type)
 65{
 66}
 67
 68bool IDBCursorInfo::isDirectionForward() const
 69{
 70 return m_direction == IndexedDB::CursorDirection::Next || m_direction == IndexedDB::CursorDirection::NextNoDuplicate;
 71}
 72
 73IDBCursorInfo IDBCursorInfo::isolatedCopy() const
 74{
 75 return { m_cursorIdentifier.isolatedCopy(), m_transactionIdentifier.isolatedCopy(), m_sourceIdentifier, m_range.isolatedCopy(), m_source, m_direction, m_type };
 76}
 77
 78} // namespace WebCore
 79
 80#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h

 1/*
 2 * Copyright (C) 2015 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef IDBCursorInfo_h
 27#define IDBCursorInfo_h
 28
 29#if ENABLE(INDEXED_DATABASE)
 30
 31#include "IDBKeyRangeData.h"
 32#include "IDBResourceIdentifier.h"
 33
 34namespace WebCore {
 35
 36namespace IDBClient {
 37class IDBTransaction;
 38}
 39
 40namespace IndexedDB {
 41enum class CursorDirection;
 42enum class CursorSource;
 43enum class CursorType;
 44}
 45
 46struct IDBKeyRangeData;
 47
 48class IDBCursorInfo {
 49public:
 50 static IDBCursorInfo objectStoreCursor(IDBClient::IDBTransaction&, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, IndexedDB::CursorDirection);
 51 static IDBCursorInfo indexCursor(IDBClient::IDBTransaction&, uint64_t indexIdentifier, const IDBKeyRangeData&, IndexedDB::CursorDirection, IndexedDB::CursorType);
 52
 53 IDBResourceIdentifier identifier() const { return m_cursorIdentifier; }
 54 uint64_t sourceIdentifier() const { return m_sourceIdentifier; }
 55
 56 IndexedDB::CursorSource cursorSource() const { return m_source; }
 57 IndexedDB::CursorDirection cursorDirection() const { return m_direction; }
 58 IndexedDB::CursorType cursorType() const { return m_type; }
 59
 60 bool isDirectionForward() const;
 61
 62 IDBCursorInfo isolatedCopy() const;
 63
 64private:
 65 IDBCursorInfo(IDBClient::IDBTransaction&, IndexedDB::CursorSource, uint64_t sourceIdentifier, const IDBKeyRangeData&, IndexedDB::CursorDirection, IndexedDB::CursorType);
 66 IDBCursorInfo(const IDBResourceIdentifier&, const IDBResourceIdentifier&, uint64_t, const IDBKeyRangeData&, IndexedDB::CursorSource, IndexedDB::CursorDirection, IndexedDB::CursorType);
 67
 68 IDBResourceIdentifier m_cursorIdentifier;
 69 IDBResourceIdentifier m_transactionIdentifier;
 70 uint64_t m_sourceIdentifier;
 71
 72 IDBKeyRangeData m_range;
 73
 74 IndexedDB::CursorSource m_source;
 75 IndexedDB::CursorDirection m_direction;
 76 IndexedDB::CursorType m_type;
 77};
 78
 79} // namespace WebCore
 80
 81#endif // ENABLE(INDEXED_DATABASE)
 82#endif // IDBCursorInfo_h

Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp

@@IDBResultData IDBResultData::deleteRecordSuccess(const IDBResourceIdentifier& re
136136 return { IDBResultType::DeleteRecordSuccess, requestIdentifier };
137137}
138138
 139IDBResultData IDBResultData::openCursorSuccess(const IDBResourceIdentifier& requestIdentifier, const IDBGetResult& getResult)
 140{
 141 IDBResultData result(IDBResultType::OpenCursorSuccess, requestIdentifier);
 142 result.m_getResult = std::make_unique<IDBGetResult>(getResult);
 143 return result;
 144}
 145
 146IDBResultData IDBResultData::iterateCursorSuccess(const IDBResourceIdentifier& requestIdentifier, const IDBGetResult& getResult)
 147{
 148 IDBResultData result(IDBResultType::IterateCursorSuccess, requestIdentifier);
 149 result.m_getResult = std::make_unique<IDBGetResult>(getResult);
 150 return result;
 151}
 152
139153const IDBDatabaseInfo& IDBResultData::databaseInfo() const
140154{
141155 RELEASE_ASSERT(m_databaseInfo);

Source/WebCore/Modules/indexeddb/shared/IDBResultData.h

@@enum class IDBResultType {
5353 GetCountSuccess,
5454 DeleteRecordSuccess,
5555 CreateIndexSuccess,
 56 OpenCursorSuccess,
 57 IterateCursorSuccess,
5658};
5759
5860namespace IDBServer {

@@public:
7375 static IDBResultData getRecordSuccess(const IDBResourceIdentifier&, const IDBGetResult&);
7476 static IDBResultData getCountSuccess(const IDBResourceIdentifier&, uint64_t count);
7577 static IDBResultData deleteRecordSuccess(const IDBResourceIdentifier&);
 78 static IDBResultData openCursorSuccess(const IDBResourceIdentifier&, const IDBGetResult&);
 79 static IDBResultData iterateCursorSuccess(const IDBResourceIdentifier&, const IDBGetResult&);
7680
7781 IDBResultData(const IDBResultData&);
7882

Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp

3030
3131#include "IDBConnectionToClient.h"
3232#include "IDBConnectionToServer.h"
 33#include "IDBCursorInfo.h"
3334#include "IDBKeyRangeData.h"
3435#include "IDBOpenDBRequestImpl.h"
3536#include "IDBRequestData.h"

@@void InProcessIDBServer::didDeleteRecord(const IDBResultData& resultData)
183184 });
184185}
185186
 187void InProcessIDBServer::didOpenCursor(const IDBResultData& resultData)
 188{
 189 RefPtr<InProcessIDBServer> self(this);
 190 RunLoop::current().dispatch([this, self, resultData] {
 191 m_connectionToServer->didOpenCursor(resultData);
 192 });
 193}
 194
 195void InProcessIDBServer::didIterateCursor(const IDBResultData& resultData)
 196{
 197 RefPtr<InProcessIDBServer> self(this);
 198 RunLoop::current().dispatch([this, self, resultData] {
 199 m_connectionToServer->didIterateCursor(resultData);
 200 });
 201}
 202
186203void InProcessIDBServer::abortTransaction(IDBResourceIdentifier& resourceIdentifier)
187204{
188205 RefPtr<InProcessIDBServer> self(this);

@@void InProcessIDBServer::deleteRecord(const IDBRequestData& requestData, const I
268285 });
269286}
270287
 288void InProcessIDBServer::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info)
 289{
 290 RefPtr<InProcessIDBServer> self(this);
 291
 292 RunLoop::current().dispatch([this, self, requestData, info] {
 293 m_server->openCursor(requestData, info);
 294 });
 295}
 296
 297void InProcessIDBServer::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count)
 298{
 299 RefPtr<InProcessIDBServer> self(this);
 300
 301 RunLoop::current().dispatch([this, self, requestData, key, count] {
 302 m_server->iterateCursor(requestData, key, count);
 303 });
 304}
 305
271306void InProcessIDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
272307{
273308 RefPtr<InProcessIDBServer> self(this);

Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h

@@public:
6666 virtual void getRecord(const IDBRequestData&, const IDBKeyRangeData&) override final;
6767 virtual void getCount(const IDBRequestData&, const IDBKeyRangeData&) override final;
6868 virtual void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&) override final;
 69 virtual void openCursor(const IDBRequestData&, const IDBCursorInfo&) override final;
 70 virtual void iterateCursor(const IDBRequestData&, const IDBKeyData&, unsigned long count) override final;
6971 virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) override final;
7072 virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) override final;
7173

@@public:
8385 virtual void didGetRecord(const IDBResultData&) override final;
8486 virtual void didGetCount(const IDBResultData&) override final;
8587 virtual void didDeleteRecord(const IDBResultData&) override final;
 88 virtual void didOpenCursor(const IDBResultData&) override final;
 89 virtual void didIterateCursor(const IDBResultData&) override final;
8690 virtual void fireVersionChangeEvent(IDBServer::UniqueIDBDatabaseConnection&, uint64_t requestedVersion) override final;
8791 virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) override final;
8892

Source/WebCore/WebCore.xcodeproj/project.pbxproj

20542054 517138F01BED1D1A000D5F01 /* IndexKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 517138EE1BED1D17000D5F01 /* IndexKey.h */; };
20552055 517138F71BF128BB000D5F01 /* IndexValueStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517138F51BF12262000D5F01 /* IndexValueStore.cpp */; };
20562056 517138F81BF128BB000D5F01 /* IndexValueStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 517138F61BF12262000D5F01 /* IndexValueStore.h */; };
 2057 517138FB1BF3ADF4000D5F01 /* IDBCursorInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517138F91BF3ADAC000D5F01 /* IDBCursorInfo.cpp */; };
 2058 517138FC1BF3ADF4000D5F01 /* IDBCursorInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 517138FA1BF3ADAC000D5F01 /* IDBCursorInfo.h */; };
20572059 51741D0F0B07259A00ED442C /* BackForwardClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51741D0B0B07259A00ED442C /* BackForwardClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
20582060 51741D110B07259A00ED442C /* HistoryItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 51741D0D0B07259A00ED442C /* HistoryItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
20592061 51741D120B07259A00ED442C /* HistoryItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51741D0E0B07259A00ED442C /* HistoryItem.cpp */; };

95129514 517138EE1BED1D17000D5F01 /* IndexKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexKey.h; sourceTree = "<group>"; };
95139515 517138F51BF12262000D5F01 /* IndexValueStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IndexValueStore.cpp; sourceTree = "<group>"; };
95149516 517138F61BF12262000D5F01 /* IndexValueStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexValueStore.h; sourceTree = "<group>"; };
 9517 517138F91BF3ADAC000D5F01 /* IDBCursorInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBCursorInfo.cpp; sourceTree = "<group>"; };
 9518 517138FA1BF3ADAC000D5F01 /* IDBCursorInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursorInfo.h; sourceTree = "<group>"; };
95159519 51741D0B0B07259A00ED442C /* BackForwardClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackForwardClient.h; sourceTree = "<group>"; };
95169520 51741D0D0B07259A00ED442C /* HistoryItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HistoryItem.h; sourceTree = "<group>"; };
95179521 51741D0E0B07259A00ED442C /* HistoryItem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HistoryItem.cpp; sourceTree = "<group>"; };

1687816882 510A58E11BAA409800C19282 /* shared */ = {
1687916883 isa = PBXGroup;
1688016884 children = (
 16885 517138F91BF3ADAC000D5F01 /* IDBCursorInfo.cpp */,
 16886 517138FA1BF3ADAC000D5F01 /* IDBCursorInfo.h */,
1688116887 51BA4AC11BBB5CBF00DF3D6D /* IDBDatabaseInfo.cpp */,
1688216888 51BA4AC21BBB5CBF00DF3D6D /* IDBDatabaseInfo.h */,
1688316889 5148453C1BB9D076006A72ED /* IDBError.cpp */,

2516225168 854075200AD6C5FB00620C57 /* DOMEventTarget.h in Headers */,
2516325169 85C78A680ABDE1B40044FC16 /* DOMException.h in Headers */,
2516425170 BC1A37B5097C715F0019F3D8 /* DOMExtensions.h in Headers */,
 25171 517138FC1BF3ADF4000D5F01 /* IDBCursorInfo.h in Headers */,
2516525172 BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */,
2516625173 2E3BC108117D479800B9409A /* DOMFileError.h in Headers */,
2516725174 2E3BC10B117D47C800B9409A /* DOMFileErrorInternal.h in Headers */,

2963029637 316FE0730E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp in Sources */,
2963129638 BC46C2000C0DDC8F0020CFC3 /* JSCSSMediaRule.cpp in Sources */,
2963229639 BC46C2020C0DDC8F0020CFC3 /* JSCSSPageRule.cpp in Sources */,
 29640 517138FB1BF3ADF4000D5F01 /* IDBCursorInfo.cpp in Sources */,
2963329641 930705E909E0C9F000B17FE4 /* JSCSSPrimitiveValue.cpp in Sources */,
2963429642 14CF7B3309F6ECD700EB3665 /* JSCSSRule.cpp in Sources */,
2963529643 BC46C1EE0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp in Sources */,

Source/WebCore/bindings/js/IDBBindingUtilities.cpp

@@static bool set(ExecState* exec, JSValue& object, const String& keyPathElement,
7878 return true;
7979}
8080
 81JSValue idbKeyDataToJSValue(JSC::ExecState& exec, const IDBKeyData& keyData)
 82{
 83 if (keyData.isNull())
 84 return jsUndefined();
 85
 86 Locker<JSLock> locker(exec.vm().apiLock());
 87
 88 switch (keyData.type()) {
 89 case KeyType::Array:
 90 {
 91 const Vector<IDBKeyData>& inArray = keyData.array();
 92 size_t size = inArray.size();
 93 JSArray* outArray = constructEmptyArray(&exec, 0, exec.lexicalGlobalObject(), size);
 94 for (size_t i = 0; i < size; ++i) {
 95 auto& arrayKey = inArray.at(i);
 96 outArray->putDirectIndex(&exec, i, idbKeyDataToJSValue(exec, arrayKey));
 97 }
 98 return JSValue(outArray);
 99 }
 100 case KeyType::String:
 101 return jsStringWithCache(&exec, keyData.string());
 102 case KeyType::Date:
 103 return jsDateOrNull(&exec, keyData.date());
 104 case KeyType::Number:
 105 return jsNumber(keyData.number());
 106 case KeyType::Min:
 107 case KeyType::Max:
 108 case KeyType::Invalid:
 109 ASSERT_NOT_REACHED();
 110 return jsUndefined();
 111 }
 112
 113 ASSERT_NOT_REACHED();
 114 return jsUndefined();
 115
 116}
 117
81118static JSValue idbKeyToJSValue(ExecState* exec, JSDOMGlobalObject* globalObject, IDBKey* key)
82119{
83120 if (!key || !exec) {

Source/WebCore/bindings/js/IDBBindingUtilities.h

@@Deprecated::ScriptValue idbKeyDataToScriptValue(ScriptExecutionContext*, const I
7070
7171JSC::JSValue idbValueDataToJSValue(JSC::ExecState&, const ThreadSafeDataBuffer& valueData);
7272void generateIndexKeyForValue(JSC::ExecState&, const IDBIndexInfo&, JSC::JSValue, IndexKey& outKey);
 73JSC::JSValue idbKeyDataToJSValue(JSC::ExecState&, const IDBKeyData&);
7374
7475}
7576

Source/WebCore/platform/CrossThreadCopier.cpp

4343#include <wtf/text/WTFString.h>
4444
4545#if ENABLE(INDEXED_DATABASE)
 46#include "IDBCursorInfo.h"
4647#include "IDBDatabaseIdentifier.h"
4748#include "IDBDatabaseInfo.h"
4849#include "IDBDatabaseMetadata.h"

@@CrossThreadCopierBase<false, false, IDBIndexInfo>::Type CrossThreadCopierBase<fa
175176 return info.isolatedCopy();
176177}
177178
 179CrossThreadCopierBase<false, false, IDBCursorInfo>::Type CrossThreadCopierBase<false, false, IDBCursorInfo>::copy(const IDBCursorInfo& info)
 180{
 181 return info.isolatedCopy();
 182}
 183
178184#endif // ENABLE(INDEXED_DATABASE)
179185
180186// Test CrossThreadCopier using COMPILE_ASSERT.

Source/WebCore/platform/CrossThreadCopier.h

@@namespace WebCore {
239239 static Type copy(const IDBIndexInfo&);
240240 };
241241
 242 class IDBCursorInfo;
 243 template<> struct WEBCORE_EXPORT CrossThreadCopierBase<false, false, IDBCursorInfo> {
 244 typedef IDBCursorInfo Type;
 245 static Type copy(const IDBCursorInfo&);
 246 };
 247
242248#endif
243249
244250 template<typename T>