LayoutTests/ChangeLog

112015-11-02 Brady Eidson <beidson@apple.com>
22
 3 Modern IDB: IBDObjectStore.delete() support.
 4 https://bugs.webkit.org/show_bug.cgi?id=150784
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * storage/indexeddb/modern/idbobjectstore-delete-1-expected.txt: Added.
 9 * storage/indexeddb/modern/idbobjectstore-delete-1.html: Added.
 10 * storage/indexeddb/modern/idbobjectstore-delete-failures-expected.txt: Added.
 11 * storage/indexeddb/modern/idbobjectstore-delete-failures.html: Added.
 12
 132015-11-02 Brady Eidson <beidson@apple.com>
 14
315 REGRESSION (191898) idbobjectstore-*-failures.html tests fail in Release builds.
416 https://bugs.webkit.org/show_bug.cgi?id=150815
517

LayoutTests/storage/indexeddb/modern/idbobjectstore-delete-1-expected.txt

 1This test exercises various uses of IDBObjectStore.delete()
 2Initial upgrade needed: Old version - 0 New version - 1
 3Count is 113
 4Initial upgrade versionchange transaction complete
 5Deleted "Mon Jan 03 2000 16:00:00 GMT-0800 (PST)", and there should now be 1 less things total.
 6Count is 112
 7Deleted "Mon Jan 03 2000 16:00:00 GMT-0800 (PST)", and there should now be 0 less things total.
 8Count is 112
 9Deleted "balyhoo", and there should now be 0 less things total.
 10Count is 112
 11Deleted "[object IDBKeyRange]", and there should now be 0 less things total.
 12Count is 112
 13Deleted "[object IDBKeyRange]", and there should now be 1 less things total.
 14Count is 111
 15Deleted "[object IDBKeyRange]", and there should now be 1 less things total.
 16Count is 110
 17Deleted "[object IDBKeyRange]", and there should now be 5 less things total.
 18Count is 105
 19Deleted "[object IDBKeyRange]", and there should now be 98 less things total.
 20Count is 7
 21Deleted "[object IDBKeyRange]", and there should now be 3 less things total.
 22Count is 4
 23readwrite transaction complete
 24Done
 25

LayoutTests/storage/indexeddb/modern/idbobjectstore-delete-1.html

 1This test exercises various uses of IDBObjectStore.delete()<br>
 2<div id="logger"></div>
 3<script>
 4
 5if (window.testRunner) {
 6 testRunner.waitUntilDone();
 7 testRunner.dumpAsText();
 8}
 9
 10function log(message)
 11{
 12 document.getElementById("logger").innerHTML += message + "<br>";
 13}
 14
 15function logCount()
 16{
 17 var req = objectStore.count();
 18 req.onsuccess = function() {
 19 log("Count is " + req.result);
 20 }
 21}
 22
 23function done()
 24{
 25 log("Done");
 26 if (window.testRunner)
 27 testRunner.notifyDone();
 28}
 29
 30var createRequest = window.indexedDB.open("IDBObjectStoreDelete1Database", 1);
 31var database;
 32var objectStore;
 33
 34var date1 = new Date("1999-12-28T23:00:00");
 35var date2 = new Date("1999-12-29T23:00:00");
 36var date3 = new Date("1999-12-30T23:00:00");
 37var date4 = new Date("1999-12-31T23:00:00");
 38var date5 = new Date("2000-01-01T00:00:00");
 39var date6 = new Date("2000-01-02T00:00:00");
 40var date7 = new Date("2000-01-03T00:00:00");
 41var date8 = new Date("2000-01-04T00:00:00");
 42
 43createRequest.onupgradeneeded = function(event) {
 44 log("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
 45
 46 var versionTransaction = createRequest.transaction;
 47 database = event.target.result;
 48 objectStore = database.createObjectStore("TestObjectStore");
 49
 50 objectStore.put("boo", "foo");
 51 objectStore.put("bop", "fop");
 52 objectStore.put("boq", "foq");
 53 objectStore.put("bor", "for");
 54 objectStore.put("bos", "fos");
 55
 56 for (var i = 0; i < 100; ++i)
 57 objectStore.put("number " + i, i);
 58
 59 objectStore.put("date 1", date1);
 60 objectStore.put("date 2", date2);
 61 objectStore.put("date 3", date3);
 62 objectStore.put("date 4", date4);
 63 objectStore.put("date 5", date5);
 64 objectStore.put("date 6", date6);
 65 objectStore.put("date 7", date7);
 66 objectStore.put("date 8", date8);
 67
 68 logCount();
 69
 70 versionTransaction.onabort = function(event) {
 71 log("Initial upgrade versionchange transaction unexpected abort");
 72 done();
 73 }
 74
 75 versionTransaction.oncomplete = function(event) {
 76 log("Initial upgrade versionchange transaction complete");
 77 continueTest1();
 78 }
 79
 80 versionTransaction.onerror = function(event) {
 81 log("Initial upgrade versionchange transaction unexpected error" + event);
 82 done();
 83 }
 84}
 85
 86function continueTest1()
 87{
 88 var transaction = database.transaction("TestObjectStore", "readwrite");
 89 objectStore = transaction.objectStore("TestObjectStore");
 90
 91 // The pairs of things in the array are the things to delete followed by the expected decrease in the total count of objects.
 92 var thingsToDelete = [
 93 date8, 1,
 94 date8, 0,
 95 "balyhoo", 0,
 96 IDBKeyRange.bound(date6, date7, true, true), 0,
 97 IDBKeyRange.bound(date6, date7, true), 1,
 98 IDBKeyRange.bound(date5, date6, false, true), 1,
 99 IDBKeyRange.bound(date1, date6), 5,
 100 IDBKeyRange.bound(1, 98), 98,
 101 IDBKeyRange.bound("foo", "fos", true, true), 3
 102 ];
 103 var currentThing = 0;
 104
 105 var runDeleteTests = function()
 106 {
 107 if (!thingsToDelete[currentThing])
 108 return;
 109
 110 objectStore.delete(thingsToDelete[currentThing]).onsuccess = function() {
 111 log("Deleted \"" + thingsToDelete[currentThing] + "\", and there should now be " + thingsToDelete[currentThing + 1] + " less things total.");
 112 logCount();
 113 currentThing += 2;
 114 runDeleteTests();
 115 }
 116 }
 117 runDeleteTests();
 118
 119 transaction.onabort = function(event) {
 120 log("readwrite transaction unexpected abort" + event);
 121 done();
 122 }
 123
 124 transaction.oncomplete = function(event) {
 125 log("readwrite transaction complete");
 126 done();
 127 }
 128
 129 transaction.onerror = function(event) {
 130 log("readwrite transaction unexpected error" + event);
 131 done();
 132 }
 133}
 134
 135</script>

LayoutTests/storage/indexeddb/modern/idbobjectstore-delete-failures-expected.txt

 1This tests some obvious failures that can happen while calling IDBObjectStore.delete().
 2Initial upgrade needed: Old version - 0 New version - 1
 3Failed to delete record from object store with an invalid key
 4Failed to delete record from object store that has been deleted
 5Initial upgrade versionchange transaction complete
 6Failed to delete a record in read-only transaction
 7Failed to delete record with inactive transaction
 8readwrite transaction complete
 9Done
 10

LayoutTests/storage/indexeddb/modern/idbobjectstore-delete-failures.html

 1This tests some obvious failures that can happen while calling IDBObjectStore.delete().<br>
 2<div id="logger"></div>
 3<script>
 4
 5if (window.testRunner) {
 6 testRunner.waitUntilDone();
 7 testRunner.dumpAsText();
 8}
 9
 10function log(message)
 11{
 12 document.getElementById("logger").innerHTML += message + "<br>";
 13}
 14
 15function done()
 16{
 17 log("Done");
 18 if (window.testRunner)
 19 testRunner.notifyDone();
 20}
 21
 22var createRequest = window.indexedDB.open("IDBObjectStoreDeleteFailuresDatabase", 1);
 23var database;
 24
 25createRequest.onupgradeneeded = function(event) {
 26 log("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
 27
 28 var versionTransaction = createRequest.transaction;
 29 database = event.target.result;
 30 var objectStore = database.createObjectStore("TestObjectStore");
 31 var request = objectStore.put("bar", "foo");
 32
 33 request.onsuccess = function() {
 34 try {
 35 objectStore.delete(NaN);
 36 } catch(e) {
 37 log("Failed to delete record from object store with an invalid key");
 38 }
 39
 40 database.deleteObjectStore("TestObjectStore");
 41
 42 try {
 43 objectStore.delete("foo");
 44 } catch(e) {
 45 log("Failed to delete record from object store that has been deleted");
 46 }
 47
 48 // Recreate the objectstore because we'll need it in phase 2.
 49 var objectStore = database.createObjectStore("TestObjectStore");
 50 objectStore.put("bar", "foo");
 51 }
 52
 53 versionTransaction.onabort = function(event) {
 54 log("Initial upgrade versionchange transaction unexpected aborted");
 55 done();
 56 }
 57
 58 versionTransaction.oncomplete = function(event) {
 59 log("Initial upgrade versionchange transaction complete");
 60 continueTest1();
 61 }
 62
 63 versionTransaction.onerror = function(event) {
 64 log("Initial upgrade versionchange transaction unexpected error" + event);
 65 done();
 66 }
 67}
 68
 69function continueTest1()
 70{
 71 var transaction = database.transaction("TestObjectStore", "readonly");
 72 var objectStore = transaction.objectStore("TestObjectStore");
 73
 74 try {
 75 objectStore.delete("foo");
 76 } catch(e) {
 77 log("Failed to delete a record in read-only transaction");
 78 }
 79
 80 var transaction = database.transaction("TestObjectStore", "readwrite");
 81 var objectStore = transaction.objectStore("TestObjectStore");
 82
 83 // Spin the transaction with get requests to keep it alive long enough for the setTimeout to fire.
 84 var canFinish = false;
 85 var spinGet = function() {
 86 objectStore.get("foo").onsuccess = function() {
 87 if (!canFinish)
 88 spinGet();
 89 }
 90 }
 91 spinGet();
 92
 93 var testWhileInactive = function() {
 94 try {
 95 objectStore.delete("foo");
 96 } catch(e) {
 97 log("Failed to delete record with inactive transaction");
 98 }
 99 canFinish = true;
 100 }
 101
 102 setTimeout(testWhileInactive, 0);
 103
 104 transaction.onabort = function(event) {
 105 log("readwrite transaction unexpected abort" + event);
 106 done();
 107 }
 108
 109 transaction.oncomplete = function(event) {
 110 log("readwrite transaction complete");
 111 done();
 112 }
 113
 114 transaction.onerror = function(event) {
 115 log("readwrite transaction unexpected error" + event);
 116 done();
 117 }
 118}
 119
 120</script>

Source/WebCore/ChangeLog

 12015-11-02 Brady Eidson <beidson@apple.com>
 2
 3 Modern IDB: IBDObjectStore.delete() support.
 4 https://bugs.webkit.org/show_bug.cgi?id=150784
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Tests: storage/indexeddb/modern/idbobjectstore-delete-1.html
 9 storage/indexeddb/modern/idbobjectstore-delete-failures.html
 10
 11 * Modules/indexeddb/IDBKeyRangeData.cpp:
 12 (WebCore::IDBKeyRangeData::isValid):
 13 * Modules/indexeddb/IDBKeyRangeData.h:
 14
 15 * Modules/indexeddb/client/IDBConnectionToServer.cpp:
 16 (WebCore::IDBClient::IDBConnectionToServer::deleteRecord):
 17 (WebCore::IDBClient::IDBConnectionToServer::didDeleteRecord):
 18 * Modules/indexeddb/client/IDBConnectionToServer.h:
 19 * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
 20
 21 * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
 22 (WebCore::IDBClient::IDBObjectStore::get):
 23 (WebCore::IDBClient::IDBObjectStore::deleteFunction):
 24
 25 * Modules/indexeddb/client/IDBTransactionImpl.cpp:
 26 (WebCore::IDBClient::IDBTransaction::requestDeleteRecord):
 27 (WebCore::IDBClient::IDBTransaction::deleteRecordOnServer):
 28 (WebCore::IDBClient::IDBTransaction::didDeleteRecordOnServer):
 29 * Modules/indexeddb/client/IDBTransactionImpl.h:
 30
 31 * Modules/indexeddb/server/IDBBackingStore.h:
 32
 33 * Modules/indexeddb/server/IDBConnectionToClient.cpp:
 34 (WebCore::IDBServer::IDBConnectionToClient::didDeleteRecord):
 35 * Modules/indexeddb/server/IDBConnectionToClient.h:
 36 * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
 37
 38 * Modules/indexeddb/server/IDBServer.cpp:
 39 (WebCore::IDBServer::IDBServer::deleteRecord):
 40 * Modules/indexeddb/server/IDBServer.h:
 41
 42 * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
 43 (WebCore::IDBServer::MemoryIDBBackingStore::deleteRange):
 44 (WebCore::IDBServer::MemoryIDBBackingStore::deleteRecord): Deleted.
 45 * Modules/indexeddb/server/MemoryIDBBackingStore.h:
 46
 47 * Modules/indexeddb/server/MemoryObjectStore.cpp:
 48 (WebCore::IDBServer::MemoryObjectStore::deleteRange):
 49 * Modules/indexeddb/server/MemoryObjectStore.h:
 50
 51 * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
 52 (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
 53 (WebCore::IDBServer::UniqueIDBDatabase::deleteRecord):
 54 (WebCore::IDBServer::UniqueIDBDatabase::performDeleteRecord):
 55 (WebCore::IDBServer::UniqueIDBDatabase::didPerformDeleteRecord):
 56 * Modules/indexeddb/server/UniqueIDBDatabase.h:
 57
 58 * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
 59 (WebCore::IDBServer::UniqueIDBDatabaseTransaction::getCount):
 60 (WebCore::IDBServer::UniqueIDBDatabaseTransaction::deleteRecord):
 61 * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
 62
 63 * Modules/indexeddb/shared/IDBResultData.cpp:
 64 (WebCore::IDBResultData::deleteRecordSuccess):
 65 * Modules/indexeddb/shared/IDBResultData.h:
 66
 67 * Modules/indexeddb/shared/InProcessIDBServer.cpp:
 68 (WebCore::InProcessIDBServer::didDeleteRecord):
 69 (WebCore::InProcessIDBServer::deleteRecord):
 70 * Modules/indexeddb/shared/InProcessIDBServer.h:
 71
1722015-11-02 Alex Christensen <achristensen@webkit.org>
273
374 Fix Mac CMake build after r191904.

Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp

@@bool IDBKeyRangeData::isExactlyOneKey() const
7979 return !lowerKey.compare(upperKey);
8080}
8181
 82bool IDBKeyRangeData::isValid() const
 83{
 84 if (isNull)
 85 return false;
 86
 87 if (!lowerKey.isValid() && !lowerKey.isNull())
 88 return false;
 89
 90 if (!upperKey.isValid() && !upperKey.isNull())
 91 return false;
 92
 93 return true;
 94}
 95
8296} // namespace WebCore
8397
8498#endif // ENABLE(INDEXED_DATABASE)

Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h

@@struct IDBKeyRangeData {
6565 WEBCORE_EXPORT PassRefPtr<IDBKeyRange> maybeCreateIDBKeyRange() const;
6666
6767 WEBCORE_EXPORT bool isExactlyOneKey() const;
 68 bool isValid() const;
6869
6970 template<class Encoder> void encode(Encoder&) const;
7071 template<class Decoder> static bool decode(Decoder&, IDBKeyRangeData&);

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

@@void IDBConnectionToServer::didGetCount(const IDBResultData& resultData)
186186 completeOperation(resultData);
187187}
188188
 189void IDBConnectionToServer::deleteRecord(TransactionOperation& operation, const IDBKeyRangeData& keyRangeData)
 190{
 191 LOG(IndexedDB, "IDBConnectionToServer::deleteRecord");
 192
 193 ASSERT(!keyRangeData.isNull);
 194
 195 saveOperation(operation);
 196 m_delegate->deleteRecord(IDBRequestData(operation), keyRangeData);
 197}
 198
 199void IDBConnectionToServer::didDeleteRecord(const IDBResultData& resultData)
 200{
 201 LOG(IndexedDB, "IDBConnectionToServer::didDeleteRecord");
 202 completeOperation(resultData);
 203}
 204
189205void IDBConnectionToServer::establishTransaction(IDBTransaction& transaction)
190206{
191207 LOG(IndexedDB, "IDBConnectionToServer::establishTransaction");

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

@@public:
7979 void getCount(TransactionOperation&, const IDBKeyRangeData&);
8080 void didGetCount(const IDBResultData&);
8181
 82 void deleteRecord(TransactionOperation&, const IDBKeyRangeData&);
 83 void didDeleteRecord(const IDBResultData&);
 84
8285 void commitTransaction(IDBTransaction&);
8386 void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
8487

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

@@public:
6262 virtual void putOrAdd(const IDBRequestData&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode) = 0;
6363 virtual void getRecord(const IDBRequestData&, const IDBKeyRangeData&) = 0;
6464 virtual void getCount(const IDBRequestData&, const IDBKeyRangeData&) = 0;
 65 virtual void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&) = 0;
6566 virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) = 0;
6667
6768 virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) = 0;

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

@@RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context,
162162 }
163163
164164 IDBKeyRangeData keyRangeData(keyRange);
165  if (keyRangeData.isNull
166  || (!keyRangeData.lowerKey.isValid() && !keyRangeData.lowerKey.isNull())
167  || (!keyRangeData.upperKey.isValid() && !keyRangeData.upperKey.isNull())) {
 165 if (!keyRangeData.isValid()) {
168166 ec = static_cast<ExceptionCode>(IDBExceptionCode::DataError);
169167 return nullptr;
170168 }

@@RefPtr<WebCore::IDBRequest> IDBObjectStore::putOrAdd(JSC::ExecState& state, JSC:
277275}
278276
279277
280 RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext*, IDBKeyRange*, ExceptionCode&)
 278RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCode& ec)
281279{
282  RELEASE_ASSERT_NOT_REACHED();
 280 LOG(IndexedDB, "IDBObjectStore::deleteFunction");
 281
 282 if (m_transaction->isReadOnly()) {
 283 ec = static_cast<ExceptionCode>(IDBExceptionCode::ReadOnlyError);
 284 return nullptr;
 285 }
 286
 287 if (!m_transaction->isActive()) {
 288 ec = static_cast<ExceptionCode>(IDBExceptionCode::TransactionInactiveError);
 289 return nullptr;
 290 }
 291
 292 if (m_deleted) {
 293 ec = INVALID_STATE_ERR;
 294 return nullptr;
 295 }
 296
 297 IDBKeyRangeData keyRangeData(keyRange);
 298 if (!keyRangeData.isValid()) {
 299 ec = static_cast<ExceptionCode>(IDBExceptionCode::DataError);
 300 return nullptr;
 301 }
 302
 303 Ref<IDBRequest> request = m_transaction->requestDeleteRecord(*context, *this, keyRangeData);
 304 return WTF::move(request);
283305}
284306
285 RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext*, const Deprecated::ScriptValue&, ExceptionCode&)
 307RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, const Deprecated::ScriptValue& key, ExceptionCode& ec)
286308{
287  RELEASE_ASSERT_NOT_REACHED();
 309 DOMRequestState requestState(context);
 310 RefPtr<IDBKey> idbKey = scriptValueToIDBKey(&requestState, key);
 311 if (!idbKey || idbKey->type() == KeyType::Invalid) {
 312 ec = static_cast<ExceptionCode>(IDBExceptionCode::DataError);
 313 return nullptr;
 314 }
 315
 316 return deleteFunction(context, &IDBKeyRange::create(idbKey.get()).get(), ec);
288317}
289318
290319RefPtr<WebCore::IDBRequest> IDBObjectStore::clear(ScriptExecutionContext* context, ExceptionCode& ec)

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

@@void IDBTransaction::didGetCountOnServer(IDBRequest& request, const IDBResultDat
460460 request.requestCompleted(resultData);
461461}
462462
 463Ref<IDBRequest> IDBTransaction::requestDeleteRecord(ScriptExecutionContext& context, IDBObjectStore& objectStore, const IDBKeyRangeData& range)
 464{
 465 LOG(IndexedDB, "IDBTransaction::requestDeleteRecord");
 466 ASSERT(isActive());
 467 ASSERT(!range.isNull);
 468
 469 Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
 470 addRequest(request.get());
 471
 472 scheduleOperation(createTransactionOperation(*this, request.get(), &IDBTransaction::didDeleteRecordOnServer, &IDBTransaction::deleteRecordOnServer, range));
 473 return request;
 474}
 475
 476void IDBTransaction::deleteRecordOnServer(TransactionOperation& operation, const IDBKeyRangeData& keyRange)
 477{
 478 LOG(IndexedDB, "IDBTransaction::deleteRecordOnServer");
 479
 480 serverConnection().deleteRecord(operation, keyRange);
 481}
 482
 483void IDBTransaction::didDeleteRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
 484{
 485 LOG(IndexedDB, "IDBTransaction::didDeleteRecordOnServer");
 486
 487 request.setResultToUndefined();
 488 request.requestCompleted(resultData);
 489}
 490
463491Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ScriptExecutionContext& context, IDBObjectStore& objectStore)
464492{
465493 LOG(IndexedDB, "IDBTransaction::requestClearObjectStore");

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

@@public:
9191
9292 Ref<IDBRequest> requestPutOrAdd(ScriptExecutionContext&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
9393 Ref<IDBRequest> requestGetRecord(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
 94 Ref<IDBRequest> requestDeleteRecord(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
9495 Ref<IDBRequest> requestClearObjectStore(ScriptExecutionContext&, IDBObjectStore&);
9596 Ref<IDBRequest> requestCount(ScriptExecutionContext&, IDBObjectStore&, const IDBKeyRangeData&);
9697

@@private:
140141 void getCountOnServer(TransactionOperation&, const IDBKeyRangeData&);
141142 void didGetCountOnServer(IDBRequest&, const IDBResultData&);
142143
 144 void deleteRecordOnServer(TransactionOperation&, const IDBKeyRangeData&);
 145 void didDeleteRecordOnServer(IDBRequest&, const IDBResultData&);
 146
143147 void deleteObjectStoreOnServer(TransactionOperation&, const String& objectStoreName);
144148 void didDeleteObjectStoreOnServer(const IDBResultData&);
145149

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

@@public:
5757 virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) = 0;
5858 virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
5959 virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
60  virtual IDBError deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&) = 0;
 60 virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
6161 virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
6262 virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) = 0;
6363 virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;

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

@@void IDBConnectionToClient::didGetCount(const IDBResultData& result)
9393 m_delegate->didGetCount(result);
9494}
9595
 96void IDBConnectionToClient::didDeleteRecord(const IDBResultData& result)
 97{
 98 m_delegate->didDeleteRecord(result);
 99}
 100
96101void IDBConnectionToClient::didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
97102{
98103 m_delegate->didCommitTransaction(transactionIdentifier, error);

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

@@public:
5858 void didPutOrAdd(const IDBResultData&);
5959 void didGetRecord(const IDBResultData&);
6060 void didGetCount(const IDBResultData&);
 61 void didDeleteRecord(const IDBResultData&);
6162
6263 void fireVersionChangeEvent(UniqueIDBDatabaseConnection&, uint64_t requestedVersion);
6364 void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);

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

@@public:
5454 virtual void didPutOrAdd(const IDBResultData&) = 0;
5555 virtual void didGetRecord(const IDBResultData&) = 0;
5656 virtual void didGetCount(const IDBResultData&) = 0;
 57 virtual void didDeleteRecord(const IDBResultData&) = 0;
5758
5859 virtual void fireVersionChangeEvent(UniqueIDBDatabaseConnection&, uint64_t requestedVersion) = 0;
5960 virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) = 0;

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

@@void IDBServer::getCount(const IDBRequestData& requestData, const IDBKeyRangeDat
224224 transaction->getCount(requestData, keyRangeData);
225225}
226226
 227void IDBServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
 228{
 229 LOG(IndexedDB, "IDBServer::deleteRecord");
 230
 231 auto transaction = m_transactions.get(requestData.transactionIdentifier());
 232 if (!transaction)
 233 return;
 234
 235 transaction->deleteRecord(requestData, keyRangeData);
 236}
 237
227238void IDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
228239{
229240 LOG(IndexedDB, "IDBServer::establishTransaction");

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

@@public:
6565 void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
6666 void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
6767 void getCount(const IDBRequestData&, const IDBKeyRangeData&);
 68 void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&);
6869 void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
6970 void databaseConnectionClosed(uint64_t databaseConnectionIdentifier);
7071

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

2828
2929#if ENABLE(INDEXED_DATABASE)
3030
 31#include "IDBKeyRangeData.h"
3132#include "Logging.h"
3233#include "MemoryObjectStore.h"
3334

@@IDBError MemoryIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifi
210211 return IDBError();
211212}
212213
213 IDBError MemoryIDBBackingStore::deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData)
 214IDBError MemoryIDBBackingStore::deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range)
214215{
215  LOG(IndexedDB, "MemoryIDBBackingStore::deleteRecord");
 216 LOG(IndexedDB, "MemoryIDBBackingStore::deleteRange");
216217
217218 ASSERT(objectStoreIdentifier);
218219
 220 if (!m_transactions.contains(transactionIdentifier))
 221 return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral("No backing store transaction found to delete from"));
 222
219223 MemoryObjectStore* objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
220  RELEASE_ASSERT(objectStore);
221  RELEASE_ASSERT(m_transactions.contains(transactionIdentifier));
 224 if (!objectStore)
 225 return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral("No backing store object store found"));
222226
223  objectStore->deleteRecord(keyData);
 227 objectStore->deleteRange(range);
224228 return IDBError();
225229}
226230

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

@@public:
5656 virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) override final;
5757 virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) override final;
5858 virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) override final;
59  virtual IDBError deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&) override final;
 59 virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) override final;
6060 virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
6161 virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) override final;
6262 virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, uint64_t& outCount) override final;

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

@@void MemoryObjectStore::deleteRecord(const IDBKeyData& key)
106106 m_orderedKeys->erase(key);
107107}
108108
 109void MemoryObjectStore::deleteRange(const IDBKeyRangeData& inputRange)
 110{
 111 LOG(IndexedDB, "MemoryObjectStore::deleteRange");
 112
 113 ASSERT(m_writeTransaction);
 114
 115 if (inputRange.isExactlyOneKey()) {
 116 deleteRecord(inputRange.lowerKey);
 117 return;
 118 }
 119
 120 IDBKeyRangeData range = inputRange;
 121 while (true) {
 122 auto key = lowestKeyWithRecordInRange(range);
 123 if (key.isNull())
 124 break;
 125
 126 deleteRecord(key);
 127
 128 range.lowerKey = key;
 129 range.lowerOpen = true;
 130 }
 131}
 132
109133void MemoryObjectStore::putRecord(MemoryBackingStoreTransaction& transaction, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
110134{
111135 LOG(IndexedDB, "MemoryObjectStore::putRecord");

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

@@public:
5858
5959 bool containsRecord(const IDBKeyData&);
6060 void deleteRecord(const IDBKeyData&);
 61 void deleteRange(const IDBKeyRangeData&);
6162 void putRecord(MemoryBackingStoreTransaction&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
6263
6364 void setKeyValue(const IDBKeyData&, const ThreadSafeDataBuffer& value);

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

@@void UniqueIDBDatabase::performPutOrAdd(uint64_t callbackIdentifier, const IDBRe
392392 // ...If a record already exists in store ...
393393 // then remove the record from store using the steps for deleting records from an object store...
394394 // This is important because formally deleting it from from the object store also removes it from the appropriate indexes.
395  error = m_backingStore->deleteRecord(transactionIdentifier, objectStoreIdentifier, usedKey);
 395 error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, usedKey);
396396 if (!error.isNull()) {
397397 m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
398398 return;

@@void UniqueIDBDatabase::didPerformGetCount(uint64_t callbackIdentifier, const ID
473473 performCountCallback(callbackIdentifier, error, count);
474474}
475475
 476void UniqueIDBDatabase::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData, ErrorCallback callback)
 477{
 478 ASSERT(isMainThread());
 479 LOG(IndexedDB, "(main) UniqueIDBDatabase::deleteRecord");
 480
 481 uint64_t callbackID = storeCallback(callback);
 482 m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performDeleteRecord, callbackID, requestData.transactionIdentifier(), requestData.objectStoreIdentifier(), keyRangeData));
 483}
 484
 485void UniqueIDBDatabase::performDeleteRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData& range)
 486{
 487 ASSERT(!isMainThread());
 488 LOG(IndexedDB, "(db) UniqueIDBDatabase::performDeleteRecord");
 489
 490 IDBError error = m_backingStore->deleteRange(transactionIdentifier, objectStoreIdentifier, range);
 491
 492 m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteRecord, callbackIdentifier, error));
 493}
 494
 495void UniqueIDBDatabase::didPerformDeleteRecord(uint64_t callbackIdentifier, const IDBError& error)
 496{
 497 ASSERT(isMainThread());
 498 LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformDeleteRecord");
 499
 500 performErrorCallback(callbackIdentifier, error);
 501}
 502
476503void UniqueIDBDatabase::commitTransaction(UniqueIDBDatabaseTransaction& transaction, ErrorCallback callback)
477504{
478505 ASSERT(isMainThread());

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

@@public:
7676 void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode, KeyDataCallback);
7777 void getRecord(const IDBRequestData&, const IDBKeyRangeData&, ValueDataCallback);
7878 void getCount(const IDBRequestData&, const IDBKeyRangeData&, CountCallback);
 79 void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&, ErrorCallback);
7980 void commitTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
8081 void abortTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
8182 void transactionDestroyed(UniqueIDBDatabaseTransaction&);

@@private:
107108 void performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
108109 void performGetRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
109110 void performGetCount(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
 111 void performDeleteRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
110112 void performActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBTransactionInfo&);
111113
112114 // Main thread callbacks

@@private:
117119 void didPerformPutOrAdd(uint64_t callbackIdentifier, const IDBError&, const IDBKeyData&);
118120 void didPerformGetRecord(uint64_t callbackIdentifier, const IDBError&, const ThreadSafeDataBuffer&);
119121 void didPerformGetCount(uint64_t callbackIdentifier, const IDBError&, uint64_t);
 122 void didPerformDeleteRecord(uint64_t callbackIdentifier, const IDBError&);
120123 void didPerformCommitTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
121124 void didPerformAbortTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
122125 void didPerformActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBError&);

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

@@void UniqueIDBDatabaseTransaction::getCount(const IDBRequestData& requestData, c
198198 });
199199}
200200
 201void UniqueIDBDatabaseTransaction::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
 202{
 203 LOG(IndexedDB, "UniqueIDBDatabaseTransaction::deleteRecord");
 204
 205 ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
 206
 207 RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this);
 208 m_databaseConnection->database().deleteRecord(requestData, keyRangeData, [this, protectedThis, requestData](const IDBError& error) {
 209 LOG(IndexedDB, "UniqueIDBDatabaseTransaction::deleteRecord (callback)");
 210
 211 if (error.isNull())
 212 m_databaseConnection->connectionToClient().didDeleteRecord(IDBResultData::deleteRecordSuccess(requestData.requestIdentifier()));
 213 else
 214 m_databaseConnection->connectionToClient().didDeleteRecord(IDBResultData::error(requestData.requestIdentifier(), error));
 215 });
 216}
 217
201218const Vector<uint64_t>& UniqueIDBDatabaseTransaction::objectStoreIdentifiers()
202219{
203220 if (!m_objectStoreIdentifiers.isEmpty())

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

@@public:
7070 void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
7171 void getRecord(const IDBRequestData&, const IDBKeyRangeData&);
7272 void getCount(const IDBRequestData&, const IDBKeyRangeData&);
 73 void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&);
7374
7475 void didActivateInBackingStore(const IDBError&);
7576

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

@@IDBResultData IDBResultData::getCountSuccess(const IDBResourceIdentifier& reques
125125 return result;
126126}
127127
 128IDBResultData IDBResultData::deleteRecordSuccess(const IDBResourceIdentifier& requestIdentifier)
 129{
 130 return { IDBResultType::DeleteRecordSuccess, requestIdentifier };
 131}
 132
128133const IDBDatabaseInfo& IDBResultData::databaseInfo() const
129134{
130135 RELEASE_ASSERT(m_databaseInfo);

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

@@enum class IDBResultType {
5050 PutOrAddSuccess,
5151 GetRecordSuccess,
5252 GetCountSuccess,
 53 DeleteRecordSuccess,
5354};
5455
5556namespace IDBServer {

@@public:
6869 static IDBResultData putOrAddSuccess(const IDBResourceIdentifier&, const IDBKeyData&);
6970 static IDBResultData getRecordSuccess(const IDBResourceIdentifier&, const ThreadSafeDataBuffer& valueData);
7071 static IDBResultData getCountSuccess(const IDBResourceIdentifier&, uint64_t count);
 72 static IDBResultData deleteRecordSuccess(const IDBResourceIdentifier&);
7173
7274 IDBResultData(const IDBResultData&);
7375

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

@@void InProcessIDBServer::didGetCount(const IDBResultData& resultData)
167167 });
168168}
169169
 170void InProcessIDBServer::didDeleteRecord(const IDBResultData& resultData)
 171{
 172 RefPtr<InProcessIDBServer> self(this);
 173 RunLoop::current().dispatch([this, self, resultData] {
 174 m_connectionToServer->didDeleteRecord(resultData);
 175 });
 176}
 177
170178void InProcessIDBServer::abortTransaction(IDBResourceIdentifier& resourceIdentifier)
171179{
172180 RefPtr<InProcessIDBServer> self(this);

@@void InProcessIDBServer::getCount(const IDBRequestData& requestData, const IDBKe
234242 m_server->getCount(requestData, keyRangeData);
235243 });
236244}
 245
 246void InProcessIDBServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
 247{
 248 RefPtr<InProcessIDBServer> self(this);
 249
 250 RunLoop::current().dispatch([this, self, requestData, keyRangeData] {
 251 m_server->deleteRecord(requestData, keyRangeData);
 252 });
 253}
 254
237255void InProcessIDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
238256{
239257 RefPtr<InProcessIDBServer> self(this);

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

@@public:
6464 virtual void putOrAdd(const IDBRequestData&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode) override final;
6565 virtual void getRecord(const IDBRequestData&, const IDBKeyRangeData&) override final;
6666 virtual void getCount(const IDBRequestData&, const IDBKeyRangeData&) override final;
 67 virtual void deleteRecord(const IDBRequestData&, const IDBKeyRangeData&) override final;
6768 virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) override final;
6869 virtual void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) override final;
6970

@@public:
7980 virtual void didPutOrAdd(const IDBResultData&) override final;
8081 virtual void didGetRecord(const IDBResultData&) override final;
8182 virtual void didGetCount(const IDBResultData&) override final;
 83 virtual void didDeleteRecord(const IDBResultData&) override final;
8284 virtual void fireVersionChangeEvent(IDBServer::UniqueIDBDatabaseConnection&, uint64_t requestedVersion) override final;
8385 virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) override final;
8486