Diff
Modified: trunk/LayoutTests/ChangeLog (191825 => 191826)
--- trunk/LayoutTests/ChangeLog 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/LayoutTests/ChangeLog 2015-10-30 23:20:02 UTC (rev 191826)
@@ -1,3 +1,17 @@
+2015-10-30 Brady Eidson <[email protected]>
+
+ Modern IDB: IDBObjectStore.clear() support.
+ https://bugs.webkit.org/show_bug.cgi?id=150733
+
+ Reviewed by Alex Christensen.
+
+ * storage/indexeddb/modern/idbobjectstore-clear-1-expected.txt: Added.
+ * storage/indexeddb/modern/idbobjectstore-clear-1.html: Added.
+ * storage/indexeddb/modern/idbobjectstore-clear-2-expected.txt: Added.
+ * storage/indexeddb/modern/idbobjectstore-clear-2.html: Added.
+ * storage/indexeddb/modern/idbobjectstore-put-and-clear-failures-expected.txt: Added.
+ * storage/indexeddb/modern/idbobjectstore-put-and-clear-failures.html: Added.
+
2015-10-30 Ryan Haddad <[email protected]>
Marking imported/w3c/web-platform-tests/XMLHttpRequest/send-timeout-events.htm as flaky on win
Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-1-expected.txt (0 => 191826)
--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-1-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-1-expected.txt 2015-10-30 23:20:02 UTC (rev 191826)
@@ -0,0 +1,27 @@
+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Success opening database connection - Starting readwrite transaction
+ALERT: Value gotten was bar1
+ALERT: Value gotten was bar2
+ALERT: Value gotten was bar3
+ALERT: Value gotten was bar4
+ALERT: Value gotten was bar5
+ALERT: Value gotten was bar6
+ALERT: Value gotten was bar7
+ALERT: Value gotten was bar8
+ALERT: Value gotten was bar9
+ALERT: Object store cleared
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Readwrite transaction complete
+ALERT: Done
+This test creates an object store then populates it.
+It then clears it and makes sure it has nothing left in it.
+
Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-1.html (0 => 191826)
--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-1.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-1.html 2015-10-30 23:20:02 UTC (rev 191826)
@@ -0,0 +1,111 @@
+This test creates an object store then populates it.<br>
+It then clears it and makes sure it has nothing left in it.<br>
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open("IDBObjectStoreClearDatabase", 1);
+
+createRequest._onupgradeneeded_ = function(event) {
+ alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var versionTransaction = createRequest.transaction;
+ var database = event.target.result;
+ var objectStore = database.createObjectStore("TestObjectStore", { autoIncrement: true });
+ var request = objectStore.put("bar1");
+ var request = objectStore.put("bar2");
+ var request = objectStore.put("bar3");
+ var request = objectStore.put("bar4");
+ var request = objectStore.put("bar5");
+ var request = objectStore.put("bar6");
+ var request = objectStore.put("bar7");
+ var request = objectStore.put("bar8");
+ var request = objectStore.put("bar9");
+
+ versionTransaction._onabort_ = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected aborted");
+ done();
+ }
+
+ versionTransaction._oncomplete_ = function(event) {
+ alert("Initial upgrade versionchange transaction complete");
+ continueTest1();
+ database.close();
+ }
+
+ versionTransaction._onerror_ = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected error" + event);
+ done();
+ }
+}
+
+function getChecker(event) {
+ alert("Value gotten was " + event.target.result);
+}
+
+function continueTest1()
+{
+ var openRequest = window.indexedDB.open("IDBObjectStoreClearDatabase", 1);
+
+ openRequest._onerror_ = function(event) {
+ alert("Request unexpected error - " + event);
+ done();
+ }
+ openRequest._onblocked_ = function(event) {
+ alert("Request unexpected blocked - " + event);
+ done();
+ }
+ openRequest._onupgradeneeded_ = function(event) {
+ alert("Request unexpected upgradeneeded - " + event);
+ done();
+ }
+
+ openRequest._onsuccess_ = function(event) {
+ alert("Success opening database connection - Starting readwrite transaction");
+ var database = event.target.result;
+ var transaction = database.transaction("TestObjectStore", "readwrite");
+ var objectStore = transaction.objectStore("TestObjectStore");
+
+ var request;
+ for (var i = 1; i <= 9; ++i) {
+ request = objectStore.get(i);
+ request._onsuccess_ = getChecker;
+ }
+
+ request = objectStore.clear();
+ request._onsuccess_ = function() {
+ alert("Object store cleared");
+ var newRequests;
+ for (var i = 1; i <= 9; ++i) {
+ newRequests = objectStore.get(i);
+ newRequests._onsuccess_ = getChecker;
+ }
+ }
+
+ transaction._onabort_ = function(event) {
+ alert("Readwrite transaction unexpected abort");
+ done();
+ }
+
+ transaction._oncomplete_ = function(event) {
+ alert("Readwrite transaction complete");
+ done();
+ }
+
+ transaction._onerror_ = function(event) {
+ alert("Readwrite transaction unexpected error - " + event);
+ done();
+ }
+ }
+}
+</script>
Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-2-expected.txt (0 => 191826)
--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-2-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-2-expected.txt 2015-10-30 23:20:02 UTC (rev 191826)
@@ -0,0 +1,39 @@
+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Success opening database connection - Starting readwrite transaction
+ALERT: Value gotten was bar1
+ALERT: Value gotten was bar2
+ALERT: Value gotten was bar3
+ALERT: Value gotten was bar4
+ALERT: Value gotten was bar5
+ALERT: Value gotten was bar6
+ALERT: Value gotten was bar7
+ALERT: Value gotten was bar8
+ALERT: Value gotten was bar9
+ALERT: Object store cleared, making sure its all gone.
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Value gotten was undefined
+ALERT: Readwrite transaction abort
+ALERT: Success opening database connection - Starting final transaction
+ALERT: Value gotten was bar1
+ALERT: Value gotten was bar2
+ALERT: Value gotten was bar3
+ALERT: Value gotten was bar4
+ALERT: Value gotten was bar5
+ALERT: Value gotten was bar6
+ALERT: Value gotten was bar7
+ALERT: Value gotten was bar8
+ALERT: Value gotten was bar9
+ALERT: Readwrite transaction complete
+ALERT: Done
+This test creates an object store then populates it, then commits that transaction.
+It then clears it, but aborts that transaction.
+Finally it checks to make sure everything from step 1 is still in there.
+
Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-2.html (0 => 191826)
--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-2.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-clear-2.html 2015-10-30 23:20:02 UTC (rev 191826)
@@ -0,0 +1,167 @@
+This test creates an object store then populates it, then commits that transaction.<br>
+It then clears it, but aborts that transaction.<br>
+Finally it checks to make sure everything from step 1 is still in there.<br>
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open("IDBObjectStoreClear2Database", 1);
+
+createRequest._onupgradeneeded_ = function(event) {
+ alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var versionTransaction = createRequest.transaction;
+ var database = event.target.result;
+ var objectStore = database.createObjectStore("TestObjectStore", { autoIncrement: true });
+ var request = objectStore.put("bar1");
+ var request = objectStore.put("bar2");
+ var request = objectStore.put("bar3");
+ var request = objectStore.put("bar4");
+ var request = objectStore.put("bar5");
+ var request = objectStore.put("bar6");
+ var request = objectStore.put("bar7");
+ var request = objectStore.put("bar8");
+ var request = objectStore.put("bar9");
+
+ versionTransaction._onabort_ = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected aborted");
+ done();
+ }
+
+ versionTransaction._oncomplete_ = function(event) {
+ alert("Initial upgrade versionchange transaction complete");
+ continueTest1();
+ database.close();
+ }
+
+ versionTransaction._onerror_ = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected error" + event);
+ done();
+ }
+}
+
+function getChecker(event) {
+ alert("Value gotten was " + event.target.result);
+}
+
+function continueTest1()
+{
+ var openRequest = window.indexedDB.open("IDBObjectStoreClear2Database", 1);
+
+ openRequest._onerror_ = function(event) {
+ alert("Request unexpected error - " + event);
+ done();
+ }
+ openRequest._onblocked_ = function(event) {
+ alert("Request unexpected blocked - " + event);
+ done();
+ }
+ openRequest._onupgradeneeded_ = function(event) {
+ alert("Request unexpected upgradeneeded - " + event);
+ done();
+ }
+
+ openRequest._onsuccess_ = function(event) {
+ alert("Success opening database connection - Starting readwrite transaction");
+ var database = event.target.result;
+ var transaction = database.transaction("TestObjectStore", "readwrite");
+ var objectStore = transaction.objectStore("TestObjectStore");
+
+ var request;
+ for (var i = 1; i <= 9; ++i) {
+ request = objectStore.get(i);
+ request._onsuccess_ = getChecker;
+ }
+
+ request = objectStore.clear();
+ request._onsuccess_ = function() {
+ alert("Object store cleared, making sure its all gone.");
+ var newRequests;
+ for (var i = 1; i <= 9; ++i) {
+ newRequests = objectStore.get(i);
+ newRequests._onsuccess_ = getChecker;
+ }
+
+ // We'll be on the last request here, can just override it.
+ newRequests._onsuccess_ = function(event) {
+ getChecker(event);
+ transaction.abort();
+ }
+ }
+
+ // Just for fun clear it twice, won't change anything
+ objectStore.clear();
+
+ transaction._onabort_ = function(event) {
+ alert("Readwrite transaction abort");
+ continueTest2();
+ }
+
+ transaction._oncomplete_ = function(event) {
+ alert("Readwrite transaction unexpected complete");
+ done();
+ }
+
+ transaction._onerror_ = function(event) {
+ alert("Readwrite transaction unexpected error - " + event);
+ done();
+ }
+ }
+}
+
+function continueTest2()
+{
+ var openRequest = window.indexedDB.open("IDBObjectStoreClear2Database", 1);
+
+ openRequest._onerror_ = function(event) {
+ alert("Request unexpected error - " + event);
+ done();
+ }
+ openRequest._onblocked_ = function(event) {
+ alert("Request unexpected blocked - " + event);
+ done();
+ }
+ openRequest._onupgradeneeded_ = function(event) {
+ alert("Request unexpected upgradeneeded - " + event);
+ done();
+ }
+
+ openRequest._onsuccess_ = function(event) {
+ alert("Success opening database connection - Starting final transaction");
+ var database = event.target.result;
+ var transaction = database.transaction("TestObjectStore", "readwrite");
+ var objectStore = transaction.objectStore("TestObjectStore");
+
+ var request;
+ for (var i = 1; i <= 9; ++i) {
+ request = objectStore.get(i);
+ request._onsuccess_ = getChecker;
+ }
+
+ transaction._onabort_ = function(event) {
+ alert("Readwrite transaction unexpected abort");
+ done();
+ }
+
+ transaction._oncomplete_ = function(event) {
+ alert("Readwrite transaction complete");
+ done();
+ }
+
+ transaction._onerror_ = function(event) {
+ alert("Readwrite transaction unexpected error - " + event);
+ done();
+ }
+ }
+}
+</script>
Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-put-and-clear-failures-expected.txt (0 => 191826)
--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-put-and-clear-failures-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-put-and-clear-failures-expected.txt 2015-10-30 23:20:02 UTC (rev 191826)
@@ -0,0 +1,11 @@
+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Failed to put record into object store with an invalid key
+ALERT: Failed to put record into object store that has been deleted
+ALERT: Failed to clear object store that has been deleted
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Failed to clear object store in read-only transaction
+ALERT: Failed to put record into object store with inactive transaction
+ALERT: Failed to clear object store with inactive transaction
+ALERT: readwrite transaction complete
+ALERT: Done
+This tests some obvious failures that can happen while calling IDBObjectStore.put() and IDBObjectStore.clear().
Added: trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-put-and-clear-failures.html (0 => 191826)
--- trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-put-and-clear-failures.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/idbobjectstore-put-and-clear-failures.html 2015-10-30 23:20:02 UTC (rev 191826)
@@ -0,0 +1,119 @@
+This tests some obvious failures that can happen while calling IDBObjectStore.put() and IDBObjectStore.clear().
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open("IDBObjectStorePutAndClearFailuresDatabase", 1);
+var database;
+
+createRequest._onupgradeneeded_ = function(event) {
+ alert("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var versionTransaction = createRequest.transaction;
+ database = event.target.result;
+ var objectStore = database.createObjectStore("TestObjectStore");
+ var request = objectStore.put("bar", "foo");
+
+ request._onsuccess_ = function() {
+ try {
+ objectStore.put("bar", NaN);
+ } catch(e) {
+ alert("Failed to put record into object store with an invalid key");
+ }
+
+ database.deleteObjectStore("TestObjectStore");
+
+ try {
+ objectStore.put("bar", "foo");
+ } catch(e) {
+ alert("Failed to put record into object store that has been deleted");
+ }
+
+ try {
+ objectStore.clear();
+ } catch(e) {
+ alert("Failed to clear object store that has been deleted");
+ }
+
+ // Recreate the objectstore because we'll need it in phase 2.
+ var objectStore = database.createObjectStore("TestObjectStore");
+ objectStore.put("bar", "foo");
+ }
+
+ versionTransaction._onabort_ = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected aborted");
+ done();
+ }
+
+ versionTransaction._oncomplete_ = function(event) {
+ alert("Initial upgrade versionchange transaction complete");
+ continueTest1();
+ }
+
+ versionTransaction._onerror_ = function(event) {
+ alert("Initial upgrade versionchange transaction unexpected error" + event);
+ done();
+ }
+}
+
+function continueTest1()
+{
+ var transaction = database.transaction("TestObjectStore", "readonly");
+ var objectStore = transaction.objectStore("TestObjectStore");
+
+ try {
+ objectStore.clear();
+ } catch(e) {
+ alert("Failed to clear object store in read-only transaction");
+ }
+
+ var transaction = database.transaction("TestObjectStore", "readwrite");
+ var objectStore = transaction.objectStore("TestObjectStore");
+
+ // Queue up a whole bunch of gets to keep the transaction alive for awhile
+ for (var i = 0; i < 10; ++i)
+ objectStore.get("foo");
+
+ var testWhileInactive = function() {
+ try {
+ objectStore.put("bar", "foo");
+ } catch(e) {
+ alert("Failed to put record into object store with inactive transaction");
+ }
+
+ try {
+ objectStore.clear();
+ } catch(e) {
+ alert("Failed to clear object store with inactive transaction");
+ }
+ }
+
+ setTimeout(testWhileInactive, 0);
+
+ transaction._onabort_ = function(event) {
+ alert("readwrite transaction unexpected abort" + event);
+ done();
+ }
+
+ transaction._oncomplete_ = function(event) {
+ alert("readwrite transaction complete");
+ done();
+ }
+
+ transaction._onerror_ = function(event) {
+ alert("readwrite transaction unexpected error" + event);
+ done();
+ }
+}
+
+</script>
Modified: trunk/Source/WebCore/ChangeLog (191825 => 191826)
--- trunk/Source/WebCore/ChangeLog 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/ChangeLog 2015-10-30 23:20:02 UTC (rev 191826)
@@ -1,3 +1,82 @@
+2015-10-30 Brady Eidson <[email protected]>
+
+ Modern IDB: IDBObjectStore.clear() support.
+ https://bugs.webkit.org/show_bug.cgi?id=150733
+
+ Reviewed by Alex Christensen.
+
+ Tests: storage/indexeddb/modern/idbobjectstore-clear-1.html
+ storage/indexeddb/modern/idbobjectstore-clear-2.html
+
+ * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+ (WebCore::IDBClient::IDBConnectionToServer::clearObjectStore):
+ (WebCore::IDBClient::IDBConnectionToServer::didClearObjectStore):
+ * Modules/indexeddb/client/IDBConnectionToServer.h:
+ * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
+
+ * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+ (WebCore::IDBClient::IDBObjectStore::clear):
+
+ * Modules/indexeddb/client/IDBRequestImpl.cpp:
+ (WebCore::IDBClient::IDBRequest::setResultToUndefined):
+ * Modules/indexeddb/client/IDBRequestImpl.h:
+
+ * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+ (WebCore::IDBClient::IDBTransaction::requestClearObjectStore):
+ (WebCore::IDBClient::IDBTransaction::clearObjectStoreOnServer):
+ (WebCore::IDBClient::IDBTransaction::didClearObjectStoreOnServer):
+ * Modules/indexeddb/client/IDBTransactionImpl.h:
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/IDBConnectionToClient.cpp:
+ (WebCore::IDBServer::IDBConnectionToClient::didClearObjectStore):
+ * Modules/indexeddb/server/IDBConnectionToClient.h:
+ * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::clearObjectStore):
+ * Modules/indexeddb/server/IDBServer.h:
+
+ * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreCleared):
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::recordValueChanged):
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
+ * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::isAborting):
+
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::clearObjectStore):
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryObjectStore.cpp:
+ (WebCore::IDBServer::MemoryObjectStore::clear):
+ (WebCore::IDBServer::MemoryObjectStore::replaceKeyValueStore):
+ * Modules/indexeddb/server/MemoryObjectStore.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::clearObjectStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::performClearObjectStore):
+ (WebCore::IDBServer::UniqueIDBDatabase::didPerformClearObjectStore):
+ * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabaseConnection::didClearObjectStore):
+ * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabaseTransaction::clearObjectStore):
+ * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
+
+ * Modules/indexeddb/shared/IDBResultData.cpp:
+ (WebCore::IDBResultData::clearObjectStoreSuccess):
+ * Modules/indexeddb/shared/IDBResultData.h:
+
+ * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+ (WebCore::InProcessIDBServer::didClearObjectStore):
+ (WebCore::InProcessIDBServer::clearObjectStore):
+ * Modules/indexeddb/shared/InProcessIDBServer.h:
+
2015-10-30 Joseph Pecoraro <[email protected]>
CSSParserVariable leaks seen on leaks bots
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -124,6 +124,21 @@
completeOperation(resultData);
}
+void IDBConnectionToServer::clearObjectStore(TransactionOperation& operation, uint64_t objectStoreIdentifier)
+{
+ LOG(IndexedDB, "IDBConnectionToServer::clearObjectStore");
+
+ saveOperation(operation);
+
+ m_delegate->clearObjectStore(IDBRequestData(operation), objectStoreIdentifier);
+}
+
+void IDBConnectionToServer::didClearObjectStore(const IDBResultData& resultData)
+{
+ LOG(IndexedDB, "IDBConnectionToServer::didClearObjectStore");
+ completeOperation(resultData);
+}
+
void IDBConnectionToServer::putOrAdd(TransactionOperation& operation, RefPtr<IDBKey>& key, RefPtr<SerializedScriptValue>& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
{
LOG(IndexedDB, "IDBConnectionToServer::putOrAdd");
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -67,6 +67,9 @@
void deleteObjectStore(TransactionOperation&, const String& objectStoreName);
void didDeleteObjectStore(const IDBResultData&);
+ void clearObjectStore(TransactionOperation&, uint64_t objectStoreIdentifier);
+ void didClearObjectStore(const IDBResultData&);
+
void putOrAdd(TransactionOperation&, RefPtr<IDBKey>&, RefPtr<SerializedScriptValue>&, const IndexedDB::ObjectStoreOverwriteMode);
void didPutOrAdd(const IDBResultData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -56,6 +56,7 @@
virtual void commitTransaction(IDBResourceIdentifier&) = 0;
virtual void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&) = 0;
virtual void deleteObjectStore(const IDBRequestData&, const String& objectStoreName) = 0;
+ virtual void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier) = 0;
virtual void putOrAdd(const IDBRequestData&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode) = 0;
virtual void getRecord(const IDBRequestData&, IDBKey*) = 0;
virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) = 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -260,9 +260,27 @@
RELEASE_ASSERT_NOT_REACHED();
}
-RefPtr<WebCore::IDBRequest> IDBObjectStore::clear(ScriptExecutionContext*, ExceptionCode&)
+RefPtr<WebCore::IDBRequest> IDBObjectStore::clear(ScriptExecutionContext* context, ExceptionCode& ec)
{
- RELEASE_ASSERT_NOT_REACHED();
+ LOG(IndexedDB, "IDBObjectStore::clear");
+
+ if (m_transaction->isReadOnly()) {
+ ec = static_cast<ExceptionCode>(IDBExceptionCode::ReadOnlyError);
+ return nullptr;
+ }
+
+ if (!m_transaction->isActive()) {
+ ec = static_cast<ExceptionCode>(IDBExceptionCode::TransactionInactiveError);
+ return nullptr;
+ }
+
+ if (m_deleted) {
+ ec = static_cast<ExceptionCode>(IDBExceptionCode::InvalidStateError);
+ return nullptr;
+ }
+
+ Ref<IDBRequest> request = m_transaction->requestClearObjectStore(*context, *this);
+ return adoptRef(request.leakRef());
}
RefPtr<WebCore::IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext*, const String&, const IDBKeyPath&, bool, bool, ExceptionCode&)
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "DOMRequestState.h"
#include "EventQueue.h"
#include "IDBBindingUtilities.h"
#include "IDBEventDispatcher.h"
@@ -191,6 +192,17 @@
m_result = IDBAny::create(WTF::move(value));
}
+void IDBRequest::setResultToUndefined()
+{
+ auto context = scriptExecutionContext();
+ if (!context)
+ return;
+
+ DOMRequestState state(context);
+ if (auto* execState = state.exec())
+ m_result = IDBAny::create(Deprecated::ScriptValue(execState->vm(), JSC::jsUndefined()));
+}
+
void IDBRequest::requestCompleted(const IDBResultData& resultData)
{
m_idbError = resultData.error();
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -79,6 +79,7 @@
void setResult(const IDBKeyData*);
void setResultToStructuredClone(const ThreadSafeDataBuffer&);
+ void setResultToUndefined();
protected:
IDBRequest(IDBConnectionToServer&, ScriptExecutionContext*);
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -414,6 +414,35 @@
request.requestCompleted(resultData);
}
+Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ScriptExecutionContext& context, IDBObjectStore& objectStore)
+{
+ LOG(IndexedDB, "IDBTransaction::requestClearObjectStore");
+ ASSERT(isActive());
+
+ Ref<IDBRequest> request = IDBRequest::create(context, objectStore, *this);
+
+ uint64_t objectStoreIdentifier = objectStore.info().identifier();
+ auto operation = createTransactionOperation(*this, request.get(), &IDBTransaction::didClearObjectStoreOnServer, &IDBTransaction::clearObjectStoreOnServer, objectStoreIdentifier);
+ scheduleOperation(WTF::move(operation));
+
+ return WTF::move(request);
+}
+
+void IDBTransaction::clearObjectStoreOnServer(TransactionOperation& operation, const uint64_t& objectStoreIdentifier)
+{
+ LOG(IndexedDB, "IDBTransaction::clearObjectStoreOnServer");
+
+ serverConnection().clearObjectStore(operation, objectStoreIdentifier);
+}
+
+void IDBTransaction::didClearObjectStoreOnServer(IDBRequest& request, const IDBResultData& resultData)
+{
+ LOG(IndexedDB, "IDBTransaction::didClearObjectStoreOnServer");
+
+ request.setResultToUndefined();
+ request.requestCompleted(resultData);
+}
+
Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBKey* key, SerializedScriptValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
{
LOG(IndexedDB, "IDBTransaction::requestPutOrAdd");
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -89,6 +89,7 @@
Ref<IDBRequest> requestPutOrAdd(ScriptExecutionContext&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
Ref<IDBRequest> requestGetRecord(ScriptExecutionContext&, IDBObjectStore&, IDBKey&);
+ Ref<IDBRequest> requestClearObjectStore(ScriptExecutionContext&, IDBObjectStore&);
void deleteObjectStore(const String& objectStoreName);
@@ -121,6 +122,9 @@
void createObjectStoreOnServer(TransactionOperation&, const IDBObjectStoreInfo&);
void didCreateObjectStoreOnServer(const IDBResultData&);
+ void clearObjectStoreOnServer(TransactionOperation&, const uint64_t& objectStoreIdentifier);
+ void didClearObjectStoreOnServer(IDBRequest&, const IDBResultData&);
+
void putOrAddOnServer(TransactionOperation&, RefPtr<IDBKey>, RefPtr<SerializedScriptValue>, const IndexedDB::ObjectStoreOverwriteMode&);
void didPutOrAddOnServer(IDBRequest&, const IDBResultData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -53,6 +53,7 @@
virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) = 0;
virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) = 0;
+ virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
virtual IDBError deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&) = 0;
virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -73,6 +73,11 @@
m_delegate->didDeleteObjectStore(result);
}
+void IDBConnectionToClient::didClearObjectStore(const IDBResultData& result)
+{
+ m_delegate->didClearObjectStore(result);
+}
+
void IDBConnectionToClient::didPutOrAdd(const IDBResultData& result)
{
m_delegate->didPutOrAdd(result);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -54,6 +54,7 @@
void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
void didCreateObjectStore(const IDBResultData&);
void didDeleteObjectStore(const IDBResultData&);
+ void didClearObjectStore(const IDBResultData&);
void didPutOrAdd(const IDBResultData&);
void didGetRecord(const IDBResultData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -50,6 +50,7 @@
virtual void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) = 0;
virtual void didCreateObjectStore(const IDBResultData&) = 0;
virtual void didDeleteObjectStore(const IDBResultData&) = 0;
+ virtual void didClearObjectStore(const IDBResultData&) = 0;
virtual void didPutOrAdd(const IDBResultData&) = 0;
virtual void didGetRecord(const IDBResultData&) = 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -180,6 +180,17 @@
transaction->deleteObjectStore(requestData, objectStoreName);
}
+void IDBServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
+{
+ LOG(IndexedDB, "IDBServer::clearObjectStore");
+
+ auto transaction = m_transactions.get(requestData.transactionIdentifier());
+ if (!transaction)
+ return;
+
+ transaction->clearObjectStore(requestData, objectStoreIdentifier);
+}
+
void IDBServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
{
LOG(IndexedDB, "IDBServer::putOrAdd");
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -61,6 +61,7 @@
void commitTransaction(const IDBResourceIdentifier&);
void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
+ void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
void getRecord(const IDBRequestData&, const IDBKeyData&);
void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -90,6 +90,27 @@
addResult.iterator->value = WTF::move(objectStore);
}
+void MemoryBackingStoreTransaction::objectStoreCleared(MemoryObjectStore& objectStore, std::unique_ptr<KeyValueMap>&& keyValueMap)
+{
+ ASSERT(m_objectStores.contains(&objectStore));
+
+ auto addResult = m_clearedKeyValueMaps.add(&objectStore, nullptr);
+
+ // If this object store has already been cleared during this transaction, we don't need to remember this clearing.
+ if (!addResult.isNewEntry)
+ return;
+
+ // If values had previously been changed during this transaction, fold those changes back into the
+ // cleared key-value map now, so we have exactly the map that will need to be restored if the transaction is aborted.
+ auto originalValues = m_originalValues.take(&objectStore);
+ if (originalValues) {
+ for (auto iterator : *originalValues)
+ keyValueMap->set(iterator.key, iterator.value);
+ }
+
+ addResult.iterator->value = WTF::move(keyValueMap);
+}
+
void MemoryBackingStoreTransaction::recordValueChanged(MemoryObjectStore& objectStore, const IDBKeyData& key)
{
ASSERT(m_objectStores.contains(&objectStore));
@@ -97,6 +118,11 @@
if (m_isAborting)
return;
+ // If this object store had been cleared during the transaction, no point in recording this
+ // individual key/value change as its entire key/value map will be restored upon abort.
+ if (m_clearedKeyValueMaps.contains(&objectStore))
+ return;
+
auto originalAddResult = m_originalValues.add(&objectStore, nullptr);
if (originalAddResult.isNewEntry)
originalAddResult.iterator->value = std::make_unique<KeyValueMap>();
@@ -138,7 +164,13 @@
ASSERT(m_originalKeyGenerators.contains(objectStore));
objectStore->setKeyGeneratorValue(m_originalKeyGenerators.get(objectStore));
- auto keyValueMap = m_originalValues.get(objectStore);
+ auto clearedKeyValueMap = m_clearedKeyValueMaps.take(objectStore);
+ if (clearedKeyValueMap) {
+ objectStore->replaceKeyValueStore(WTF::move(clearedKeyValueMap));
+ continue;
+ }
+
+ auto keyValueMap = m_originalValues.take(objectStore);
if (!keyValueMap)
continue;
@@ -146,8 +178,6 @@
objectStore->deleteRecord(entry.key);
objectStore->setKeyValue(entry.key, entry.value);
}
-
- m_originalValues.remove(objectStore);
}
finish();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -52,6 +52,7 @@
bool isVersionChange() const { return m_info.mode() == IndexedDB::TransactionMode::VersionChange; }
bool isWriting() const { return m_info.mode() != IndexedDB::TransactionMode::ReadOnly; }
+ bool isAborting() const { return m_isAborting; }
const IDBDatabaseInfo& originalDatabaseInfo() const;
@@ -59,6 +60,7 @@
void addExistingObjectStore(MemoryObjectStore&);
void recordValueChanged(MemoryObjectStore&, const IDBKeyData&);
void objectStoreDeleted(std::unique_ptr<MemoryObjectStore>);
+ void objectStoreCleared(MemoryObjectStore&, std::unique_ptr<KeyValueMap>&&);
void abort();
void commit();
@@ -82,7 +84,7 @@
HashMap<MemoryObjectStore*, uint64_t> m_originalKeyGenerators;
HashMap<String, std::unique_ptr<MemoryObjectStore>> m_deletedObjectStores;
HashMap<MemoryObjectStore*, std::unique_ptr<KeyValueMap>> m_originalValues;
-
+ HashMap<MemoryObjectStore*, std::unique_ptr<KeyValueMap>> m_clearedKeyValueMaps;
};
} // namespace IDBServer
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -161,6 +161,27 @@
return IDBError();
}
+IDBError MemoryIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
+{
+ LOG(IndexedDB, "MemoryIDBBackingStore::clearObjectStore");
+ ASSERT(objectStoreIdentifier);
+
+ ASSERT_UNUSED(transactionIdentifier, m_transactions.contains(transactionIdentifier));
+
+#ifndef NDEBUG
+ auto transaction = m_transactions.get(transactionIdentifier);
+ ASSERT(transaction->isWriting());
+#endif
+
+ auto objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
+ if (!objectStore)
+ return IDBError(IDBExceptionCode::ConstraintError);
+
+ objectStore->clear();
+
+ return IDBError();
+}
+
void MemoryIDBBackingStore::removeObjectStoreForVersionChangeAbort(MemoryObjectStore& objectStore)
{
LOG(IndexedDB, "MemoryIDBBackingStore::removeObjectStoreForVersionChangeAbort");
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -54,6 +54,7 @@
virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) override final;
virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) override final;
virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) override final;
+ virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) override final;
virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) override final;
virtual IDBError deleteRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&) override final;
virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -73,6 +73,22 @@
return m_keyValueStore->contains(key);
}
+void MemoryObjectStore::clear()
+{
+ LOG(IndexedDB, "MemoryObjectStore::clear");
+ ASSERT(m_writeTransaction);
+
+ m_writeTransaction->objectStoreCleared(*this, WTF::move(m_keyValueStore));
+}
+
+void MemoryObjectStore::replaceKeyValueStore(std::unique_ptr<KeyValueMap>&& store)
+{
+ ASSERT(m_writeTransaction);
+ ASSERT(m_writeTransaction->isAborting());
+
+ m_keyValueStore = WTF::move(store);
+}
+
void MemoryObjectStore::deleteRecord(const IDBKeyData& key)
{
LOG(IndexedDB, "MemoryObjectStore::deleteRecord");
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -63,6 +63,9 @@
uint64_t currentKeyGeneratorValue() const { return m_keyGeneratorValue; }
void setKeyGeneratorValue(uint64_t value) { m_keyGeneratorValue = value; }
+ void clear();
+ void replaceKeyValueStore(std::unique_ptr<KeyValueMap>&&);
+
ThreadSafeDataBuffer valueForKey(const IDBKeyData&) const;
const IDBObjectStoreInfo& info() const { return m_info; }
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -296,6 +296,35 @@
performErrorCallback(callbackIdentifier, error);
}
+void UniqueIDBDatabase::clearObjectStore(UniqueIDBDatabaseTransaction& transaction, uint64_t objectStoreIdentifier, ErrorCallback callback)
+{
+ ASSERT(isMainThread());
+ LOG(IndexedDB, "(main) UniqueIDBDatabase::clearObjectStore");
+
+ uint64_t callbackID = storeCallback(callback);
+ m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performClearObjectStore, callbackID, transaction.info().identifier(), objectStoreIdentifier));
+}
+
+void UniqueIDBDatabase::performClearObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
+{
+ ASSERT(!isMainThread());
+ LOG(IndexedDB, "(db) UniqueIDBDatabase::performClearObjectStore");
+
+ ASSERT(m_backingStore);
+ m_backingStore->clearObjectStore(transactionIdentifier, objectStoreIdentifier);
+
+ IDBError error;
+ m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformClearObjectStore, callbackIdentifier, error));
+}
+
+void UniqueIDBDatabase::didPerformClearObjectStore(uint64_t callbackIdentifier, const IDBError& error)
+{
+ ASSERT(isMainThread());
+ LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformClearObjectStore");
+
+ performErrorCallback(callbackIdentifier, error);
+}
+
void UniqueIDBDatabase::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode overwriteMode, KeyDataCallback callback)
{
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -71,6 +71,7 @@
void createObjectStore(UniqueIDBDatabaseTransaction&, const IDBObjectStoreInfo&, ErrorCallback);
void deleteObjectStore(UniqueIDBDatabaseTransaction&, const String& objectStoreName, ErrorCallback);
+ void clearObjectStore(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, ErrorCallback);
void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode, KeyDataCallback);
void getRecord(const IDBRequestData&, const IDBKeyData&, ValueDataCallback);
void commitTransaction(UniqueIDBDatabaseTransaction&, ErrorCallback);
@@ -100,6 +101,7 @@
void beginTransactionInBackingStore(const IDBTransactionInfo&);
void performCreateObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&);
void performDeleteObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName);
+ void performClearObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier);
void performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
void performGetRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&);
void performActivateTransactionInBackingStore(uint64_t callbackIdentifier, const IDBTransactionInfo&);
@@ -108,6 +110,7 @@
void didOpenBackingStore(const IDBDatabaseInfo&);
void didPerformCreateObjectStore(uint64_t callbackIdentifier, const IDBError&, const IDBObjectStoreInfo&);
void didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError&, const String& objectStoreName);
+ void didPerformClearObjectStore(uint64_t callbackIdentifier, const IDBError&);
void didPerformPutOrAdd(uint64_t callbackIdentifier, const IDBError&, const IDBKeyData&);
void didPerformGetRecord(uint64_t callbackIdentifier, const IDBError&, const ThreadSafeDataBuffer&);
void didPerformCommitTransaction(uint64_t callbackIdentifier, const IDBError&, const IDBResourceIdentifier& transactionIdentifier);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -146,6 +146,13 @@
m_connectionToClient.didDeleteObjectStore(resultData);
}
+void UniqueIDBDatabaseConnection::didClearObjectStore(const IDBResultData& resultData)
+{
+ LOG(IndexedDB, "UniqueIDBDatabaseConnection::didClearObjectStore");
+
+ m_connectionToClient.didClearObjectStore(resultData);
+}
+
} // namespace IDBServer
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -68,6 +68,7 @@
void didCommitTransaction(UniqueIDBDatabaseTransaction&, const IDBError&);
void didCreateObjectStore(const IDBResultData&);
void didDeleteObjectStore(const IDBResultData&);
+ void didClearObjectStore(const IDBResultData&);
private:
UniqueIDBDatabaseConnection(UniqueIDBDatabase&, IDBConnectionToClient&);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -130,7 +130,22 @@
});
}
+void UniqueIDBDatabaseTransaction::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
+{
+ LOG(IndexedDB, "UniqueIDBDatabaseTransaction::clearObjectStore");
+ ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
+
+ RefPtr<UniqueIDBDatabaseTransaction> self(this);
+ m_databaseConnection->database().clearObjectStore(*this, objectStoreIdentifier, [this, self, requestData](const IDBError& error) {
+ LOG(IndexedDB, "UniqueIDBDatabaseTransaction::clearObjectStore (callback)");
+ if (error.isNull())
+ m_databaseConnection->didClearObjectStore(IDBResultData::clearObjectStoreSuccess(requestData.requestIdentifier()));
+ else
+ m_databaseConnection->didClearObjectStore(IDBResultData::error(requestData.requestIdentifier(), error));
+ });
+}
+
void UniqueIDBDatabaseTransaction::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
{
LOG(IndexedDB, "UniqueIDBDatabaseTransaction::putOrAdd");
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -64,6 +64,7 @@
void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
+ void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
void putOrAdd(const IDBRequestData&, const IDBKeyData&, const ThreadSafeDataBuffer& valueData, IndexedDB::ObjectStoreOverwriteMode);
void getRecord(const IDBRequestData&, const IDBKeyData&);
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -98,6 +98,11 @@
return { IDBResultType::DeleteObjectStoreSuccess, requestIdentifier };
}
+IDBResultData IDBResultData::clearObjectStoreSuccess(const IDBResourceIdentifier& requestIdentifier)
+{
+ return { IDBResultType::ClearObjectStoreSuccess, requestIdentifier };
+}
+
IDBResultData IDBResultData::putOrAddSuccess(const IDBResourceIdentifier& requestIdentifier, const IDBKeyData& resultKey)
{
IDBResultData result(IDBResultType::PutOrAddSuccess, requestIdentifier);
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -46,6 +46,7 @@
OpenDatabaseUpgradeNeeded,
CreateObjectStoreSuccess,
DeleteObjectStoreSuccess,
+ ClearObjectStoreSuccess,
PutOrAddSuccess,
GetRecordSuccess,
};
@@ -62,6 +63,7 @@
static IDBResultData openDatabaseUpgradeNeeded(const IDBResourceIdentifier&, IDBServer::UniqueIDBDatabaseTransaction&);
static IDBResultData createObjectStoreSuccess(const IDBResourceIdentifier&);
static IDBResultData deleteObjectStoreSuccess(const IDBResourceIdentifier&);
+ static IDBResultData clearObjectStoreSuccess(const IDBResourceIdentifier&);
static IDBResultData putOrAddSuccess(const IDBResourceIdentifier&, const IDBKeyData&);
static IDBResultData getRecordSuccess(const IDBResourceIdentifier&, const ThreadSafeDataBuffer& valueData);
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp 2015-10-30 23:20:02 UTC (rev 191826)
@@ -135,6 +135,14 @@
});
}
+void InProcessIDBServer::didClearObjectStore(const IDBResultData& resultData)
+{
+ RefPtr<InProcessIDBServer> self(this);
+ RunLoop::current().dispatch([this, self, resultData] {
+ m_connectionToServer->didClearObjectStore(resultData);
+ });
+}
+
void InProcessIDBServer::didPutOrAdd(const IDBResultData& resultData)
{
RefPtr<InProcessIDBServer> self(this);
@@ -183,6 +191,14 @@
});
}
+void InProcessIDBServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
+{
+ RefPtr<InProcessIDBServer> self(this);
+ RunLoop::current().dispatch([this, self, requestData, objectStoreIdentifier] {
+ m_server->clearObjectStore(requestData, objectStoreIdentifier);
+ });
+}
+
void InProcessIDBServer::putOrAdd(const IDBRequestData& requestData, IDBKey* key, SerializedScriptValue& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
{
RefPtr<InProcessIDBServer> self(this);
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h (191825 => 191826)
--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h 2015-10-30 23:18:27 UTC (rev 191825)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h 2015-10-30 23:20:02 UTC (rev 191826)
@@ -60,6 +60,7 @@
virtual void commitTransaction(IDBResourceIdentifier&) override final;
virtual void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&) override final;
virtual void deleteObjectStore(const IDBRequestData&, const String& objectStoreName) override final;
+ virtual void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier) override final;
virtual void putOrAdd(const IDBRequestData&, IDBKey*, SerializedScriptValue&, const IndexedDB::ObjectStoreOverwriteMode) override final;
virtual void getRecord(const IDBRequestData&, IDBKey*) override final;
virtual void establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo&) override final;
@@ -73,6 +74,7 @@
virtual void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) override final;
virtual void didCreateObjectStore(const IDBResultData&) override final;
virtual void didDeleteObjectStore(const IDBResultData&) override final;
+ virtual void didClearObjectStore(const IDBResultData&) override final;
virtual void didPutOrAdd(const IDBResultData&) override final;
virtual void didGetRecord(const IDBResultData&) override final;
virtual void fireVersionChangeEvent(IDBServer::UniqueIDBDatabaseConnection&, uint64_t requestedVersion) override final;