Title: [207641] trunk
Revision
207641
Author
beid...@apple.com
Date
2016-10-20 16:03:21 -0700 (Thu, 20 Oct 2016)

Log Message

IndexedDB 2.0: Support IDBObjectStore name assignment.
<rdar://problem/28806931> and https://bugs.webkit.org/show_bug.cgi?id=163749

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/IndexedDB/idbobjectstore-rename-errors-expected.txt:
* web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt:

Source/WebCore:

Tests: storage/indexeddb/modern/objectstore-rename-1-private.html
       storage/indexeddb/modern/objectstore-rename-1.html

Touches a *lot* of code sites, but none of them are particularly interesting.
They are all just getting the new name spread out to all of the various objects that need it.

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::renameObjectStore):
* Modules/indexeddb/IDBDatabase.h:

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::setName):
* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBObjectStore.idl:

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::renameObjectStore):
(WebCore::IDBTransaction::renameObjectStoreOnServer):
(WebCore::IDBTransaction::didRenameObjectStoreOnServer):
* Modules/indexeddb/IDBTransaction.h:

* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::IDBConnectionProxy::renameObjectStore):
* Modules/indexeddb/client/IDBConnectionProxy.h:

* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::renameObjectStore):
(WebCore::IDBClient::IDBConnectionToServer::didRenameObjectStore):
* Modules/indexeddb/client/IDBConnectionToServer.h:
* Modules/indexeddb/client/IDBConnectionToServerDelegate.h:

* Modules/indexeddb/server/IDBBackingStore.h:

* Modules/indexeddb/server/IDBConnectionToClient.cpp:
(WebCore::IDBServer::IDBConnectionToClient::didDeleteObjectStore):
(WebCore::IDBServer::IDBConnectionToClient::didRenameObjectStore):
* Modules/indexeddb/server/IDBConnectionToClient.h:
* Modules/indexeddb/server/IDBConnectionToClientDelegate.h:

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

* Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
(WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreRenamed):
(WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
* Modules/indexeddb/server/MemoryBackingStoreTransaction.h:

* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::renameObjectStore):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:

* Modules/indexeddb/server/MemoryObjectStore.h:
(WebCore::IDBServer::MemoryObjectStore::rename):

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::renameObjectStore):
(WebCore::IDBServer::UniqueIDBDatabase::performRenameObjectStore):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformRenameObjectStore):
* Modules/indexeddb/server/UniqueIDBDatabase.h:

* Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseConnection::didRenameObjectStore):
* Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:

* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::renameObjectStore):
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:

* Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
(WebCore::IDBDatabaseInfo::renameObjectStore):
* Modules/indexeddb/shared/IDBDatabaseInfo.h:

* Modules/indexeddb/shared/IDBObjectStoreInfo.h:
(WebCore::IDBObjectStoreInfo::rename):

* Modules/indexeddb/shared/IDBResultData.cpp:
(WebCore::IDBResultData::renameObjectStoreSuccess):
* Modules/indexeddb/shared/IDBResultData.h:

* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::InProcessIDBServer::didRenameObjectStore):
(WebCore::InProcessIDBServer::renameObjectStore):
* Modules/indexeddb/shared/InProcessIDBServer.h:

Source/WebKit2:

* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
(WebKit::WebIDBConnectionToClient::didRenameObjectStore):
(WebKit::WebIDBConnectionToClient::renameObjectStore):
* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
* DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:

* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
(WebKit::WebIDBConnectionToServer::renameObjectStore):
(WebKit::WebIDBConnectionToServer::didRenameObjectStore):
* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in:

LayoutTests:

* storage/indexeddb/modern/objectstore-rename-1-expected.txt: Added.
* storage/indexeddb/modern/objectstore-rename-1-private-expected.txt: Added.
* storage/indexeddb/modern/objectstore-rename-1-private.html: Added.
* storage/indexeddb/modern/objectstore-rename-1.html: Added.
* storage/indexeddb/modern/resources/objectstore-rename-1.js: Added.

* storage/indexeddb/readonly-expected.txt:
* storage/indexeddb/readonly-private-expected.txt:
* storage/indexeddb/resources/readonly.js: Removed the test that verifies that object store names are
  readonly as they are no longer readonly.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207640 => 207641)


--- trunk/LayoutTests/ChangeLog	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/ChangeLog	2016-10-20 23:03:21 UTC (rev 207641)
@@ -1,3 +1,21 @@
+2016-10-20  Brady Eidson  <beid...@apple.com>
+
+        IndexedDB 2.0: Support IDBObjectStore name assignment.
+        <rdar://problem/28806931> and https://bugs.webkit.org/show_bug.cgi?id=163749
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/objectstore-rename-1-expected.txt: Added.
+        * storage/indexeddb/modern/objectstore-rename-1-private-expected.txt: Added.
+        * storage/indexeddb/modern/objectstore-rename-1-private.html: Added.
+        * storage/indexeddb/modern/objectstore-rename-1.html: Added.
+        * storage/indexeddb/modern/resources/objectstore-rename-1.js: Added.
+
+        * storage/indexeddb/readonly-expected.txt:
+        * storage/indexeddb/readonly-private-expected.txt:
+        * storage/indexeddb/resources/readonly.js: Removed the test that verifies that object store names are
+          readonly as they are no longer readonly.
+
 2016-10-20  Zalan Bujtas  <za...@apple.com>
 
         Unreviewed gardening.

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (207640 => 207641)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-20 23:03:21 UTC (rev 207641)
@@ -1,3 +1,13 @@
+2016-10-20  Brady Eidson  <beid...@apple.com>
+
+        IndexedDB 2.0: Support IDBObjectStore name assignment.
+        <rdar://problem/28806931> and https://bugs.webkit.org/show_bug.cgi?id=163749
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/IndexedDB/idbobjectstore-rename-errors-expected.txt:
+        * web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt:
+
 2016-10-20  Chris Dumez  <cdu...@apple.com>
 
         Make table.deleteRow(-1) a no-op when there are no rows

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-errors-expected.txt (207640 => 207641)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-errors-expected.txt	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-errors-expected.txt	2016-10-20 23:03:21 UTC (rev 207641)
@@ -1,10 +1,8 @@
 
-FAIL IndexedDB deleted object store rename throws assert_throws: function "() => store.name = 'renamed_books'" did not throw
-FAIL IndexedDB object store rename throws in a readonly transaction assert_throws: function "() => store.name = 'renamed_books'" did not throw
-FAIL IndexedDB object store rename throws in a readwrite transaction assert_throws: function "() => store.name = 'renamed_books'" did not throw
-FAIL IndexedDB object store rename throws in an inactive transaction assert_throws: function "() => { bookStore.name = 'renamed_books'; }" did not throw
-FAIL IndexedDB object store rename to the name of another store throws assert_throws: function "() => store.name = 'not_books'" did not throw
-FAIL IndexedDB object store rename handles exceptions when stringifying names assert_throws: IDBObjectStore rename should re-raise toString() exception function "() => {
-              store.name = {
-                toSt..." did not throw
+PASS IndexedDB deleted object store rename throws 
+PASS IndexedDB object store rename throws in a readonly transaction 
+PASS IndexedDB object store rename throws in a readwrite transaction 
+FAIL IndexedDB object store rename throws in an inactive transaction assert_throws: function "() => { bookStore.name = 'renamed_books'; }" threw object "InvalidStateError (DOM Exception 11): Failed set property..." that is not a DOMException TransactionInactiveError: property "code" is equal to 11, expected 0
+FAIL IndexedDB object store rename to the name of another store throws assert_throws: function "() => store.name = 'not_books'" threw object "InvalidStateError (DOM Exception 11): Failed set property..." that is not a DOMException ConstraintError: property "code" is equal to 11, expected 0
+PASS IndexedDB object store rename handles exceptions when stringifying names 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt (207640 => 207641)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt	2016-10-20 23:03:21 UTC (rev 207641)
@@ -1,13 +1,13 @@
 
-FAIL IndexedDB object store rename in new transaction assert_equals: IDBObjectStore name should change immediately after a rename expected "renamed_books" but got "books"
-FAIL IndexedDB object store rename in the transaction where it is created assert_equals: IDBObjectStore name should change immediately after a rename expected "renamed_books" but got "books"
-FAIL IndexedDB object store rename covers index promise_test: Unhandled rejection with value: object "NotFoundError (DOM IDBDatabase Exception 8): Failed to ex..."
-FAIL IndexedDB object store rename covers key generator promise_test: Unhandled rejection with value: object "NotFoundError (DOM IDBDatabase Exception 8): Failed to ex..."
+FAIL IndexedDB object store rename in new transaction undefined is not an object (evaluating 'actual.length')
+FAIL IndexedDB object store rename in the transaction where it is created undefined is not an object (evaluating 'actual.length')
+PASS IndexedDB object store rename covers index 
+FAIL IndexedDB object store rename covers key generator assert_equals: Renaming an object store should not change the state of its key generator expected 345680 but got 345679
 PASS IndexedDB object store rename to the same name succeeds 
-FAIL IndexedDB object store rename to the name of a deleted store succeeds assert_array_equals: IDBDatabase.objectStoreNames should immediately reflect the rename property 0, expected "not_books" but got "books"
-FAIL IndexedDB object store swapping via renames succeeds Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found.
-FAIL IndexedDB object store rename stringifies non-string names assert_equals: IDBObjectStore name should change immediately after a rename to a number expected "42" but got "books"
-FAIL IndexedDB object store can be renamed to "" assert_equals: IDBObjectStore name should change immediately after the rename expected "" but got "books"
-FAIL IndexedDB object store can be renamed to "\u0000" assert_equals: IDBObjectStore name should change immediately after the rename expected "\0" but got "books"
-FAIL IndexedDB object store can be renamed to "\uDC00\uD800" assert_equals: IDBObjectStore name should change immediately after the rename expected "í°€í €" but got "books"
+PASS IndexedDB object store rename to the name of a deleted store succeeds 
+PASS IndexedDB object store swapping via renames succeeds 
+PASS IndexedDB object store rename stringifies non-string names 
+PASS IndexedDB object store can be renamed to "" 
+PASS IndexedDB object store can be renamed to "\u0000" 
+PASS IndexedDB object store can be renamed to "\uDC00\uD800" 
 

Added: trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-expected.txt (0 => 207641)


--- trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-expected.txt	2016-10-20 23:03:21 UTC (rev 207641)
@@ -0,0 +1,25 @@
+This tests expectations with renaming existing object stores.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+Initial upgrade needed: Old version - 0 New version - 1
+Initial objectStore name: TestObjectStore
+Caught exception renaming object store to the name of another existing object store: InvalidStateError (DOM Exception 11): Failed set property 'name' on 'IDBObjectStore': The database already has an object store named 'ExistingObjectStore'.
+Renamed objectStore name: RenamedObjectStore
+Current objectStore name in a new transaction: RenamedObjectStore
+Caught exception renaming object store outside of a version change transaction: InvalidStateError (DOM Exception 11): Failed set property 'name' on 'IDBObjectStore': The object store's transaction is not a version change transaction.
+Current objectStoreNames during second upgrade transaction includes 'ExistingObjectStore': true
+Current objectStoreNames during second upgrade transaction includes 'RenamedObjectStore': true
+Renamed objectstore again to: YetAnotherName
+Aborting version change transaction...
+Current objectStoreNames during final transaction includes 'ExistingObjectStore': true
+Current objectStoreNames during final transaction includes 'RenamedObjectStore': true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-private-expected.txt (0 => 207641)


--- trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-private-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-private-expected.txt	2016-10-20 23:03:21 UTC (rev 207641)
@@ -0,0 +1,25 @@
+This tests expectations with renaming existing object stores.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+Initial upgrade needed: Old version - 0 New version - 1
+Initial objectStore name: TestObjectStore
+Caught exception renaming object store to the name of another existing object store: InvalidStateError (DOM Exception 11): Failed set property 'name' on 'IDBObjectStore': The database already has an object store named 'ExistingObjectStore'.
+Renamed objectStore name: RenamedObjectStore
+Current objectStore name in a new transaction: RenamedObjectStore
+Caught exception renaming object store outside of a version change transaction: InvalidStateError (DOM Exception 11): Failed set property 'name' on 'IDBObjectStore': The object store's transaction is not a version change transaction.
+Current objectStoreNames during second upgrade transaction includes 'ExistingObjectStore': true
+Current objectStoreNames during second upgrade transaction includes 'RenamedObjectStore': true
+Renamed objectstore again to: YetAnotherName
+Aborting version change transaction...
+Current objectStoreNames during final transaction includes 'ExistingObjectStore': true
+Current objectStoreNames during final transaction includes 'RenamedObjectStore': true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-private.html (0 => 207641)


--- trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-private.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1-private.html	2016-10-20 23:03:21 UTC (rev 207641)
@@ -0,0 +1,12 @@
+<html>
+<head>
+<script>
+enablePrivateBrowsing = true;
+</script>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1.html (0 => 207641)


--- trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/objectstore-rename-1.html	2016-10-20 23:03:21 UTC (rev 207641)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/storage/indexeddb/modern/resources/objectstore-rename-1.js (0 => 207641)


--- trunk/LayoutTests/storage/indexeddb/modern/resources/objectstore-rename-1.js	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/resources/objectstore-rename-1.js	2016-10-20 23:03:21 UTC (rev 207641)
@@ -0,0 +1,102 @@
+description("This tests expectations with renaming existing object stores.");
+
+indexedDBTest(prepareDatabase);
+
+function log(message)
+{
+    debug(message);
+}
+
+var testGenerator;
+function next()
+{
+    testGenerator.next();
+}
+
+function asyncNext()
+{
+    setTimeout("testGenerator.next();", 0);
+}
+
+var db;
+var dbName;
+var dbVersion;
+
+function prepareDatabase(event)
+{
+    log("Initial upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+    db = event.target.result;
+	dbName = db.name;
+	dbVersion = db.version;
+
+	objectStore = db.createObjectStore("ExistingObjectStore");
+
+	objectStore = db.createObjectStore("TestObjectStore");
+	log("Initial objectStore name: " + objectStore.name);
+	
+	try {
+		objectStore.name = "ExistingObjectStore";
+		log("Was incorrectly able to rename this object store to the name of another existing object store");
+	} catch(e) {
+		log("Caught exception renaming object store to the name of another existing object store: " + e);
+	}
+
+	objectStore.name = "RenamedObjectStore";
+	log("Renamed objectStore name: " + objectStore.name);
+
+    event.target._onsuccess_ = function() {
+        testGenerator = testSteps();
+        testGenerator.next();
+    };
+}
+
+function* testSteps()
+{    
+    tx = db.transaction("RenamedObjectStore", "readwrite");
+    tx._oncomplete_ = next;
+    objectStore = tx.objectStore("RenamedObjectStore");
+    log("Current objectStore name in a new transaction: " + objectStore.name);
+
+	try {
+		objectStore.name = "newName";
+		log("Renaming object store succeeded, but it shouldn't have");
+	} catch(e) {
+		log("Caught exception renaming object store outside of a version change transaction: " + e);
+	}
+    
+    yield; // For the transaction's completion.
+
+	db.close();
+    
+	upgradeOpenRequest = indexedDB.open(dbName, dbVersion + 1);
+	upgradeOpenRequest._onerror_ = next;
+	upgradeOpenRequest._onupgradeneeded_ = function() {
+		db = upgradeOpenRequest.result;
+		
+		log("Current objectStoreNames during second upgrade transaction includes 'ExistingObjectStore': " + db.objectStoreNames.contains("ExistingObjectStore"));
+		log("Current objectStoreNames during second upgrade transaction includes 'RenamedObjectStore': " + db.objectStoreNames.contains("RenamedObjectStore"));
+
+		objectStore = event.target.transaction.objectStore("RenamedObjectStore");
+		objectStore.name = "YetAnotherName";
+		
+		log("Renamed objectstore again to: " + objectStore.name);
+		log("Aborting version change transaction...");
+		event.target.transaction.abort();
+	}
+
+	yield; // For the open request's failure (due to aborting the version change transaction)
+
+	upgradeOpenRequest = indexedDB.open(dbName);
+	upgradeOpenRequest._onsuccess_ = function(event) {
+		log("Current objectStoreNames during final transaction includes 'ExistingObjectStore': " + db.objectStoreNames.contains("ExistingObjectStore"));
+		log("Current objectStoreNames during final transaction includes 'RenamedObjectStore': " + db.objectStoreNames.contains("RenamedObjectStore"));
+
+		next();
+	}
+	
+	yield; // To balance the next() above.
+	
+    finishJSTest();
+ }
+ 
\ No newline at end of file

Modified: trunk/LayoutTests/storage/indexeddb/readonly-expected.txt (207640 => 207641)


--- trunk/LayoutTests/storage/indexeddb/readonly-expected.txt	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/storage/indexeddb/readonly-expected.txt	2016-10-20 23:03:21 UTC (rev 207641)
@@ -16,9 +16,6 @@
 PASS transaction.db is still [object IDBDatabase]
 Deleted all object stores.
 objectStore = db.createObjectStore('foo');
-trying to set readonly property objectStore.name
-objectStore.name = 'bar'
-PASS objectStore.name is still foo
 trying to set readonly property objectStore.keyPath
 objectStore.keyPath = 'bar'
 PASS objectStore.keyPath is still null

Modified: trunk/LayoutTests/storage/indexeddb/readonly-private-expected.txt (207640 => 207641)


--- trunk/LayoutTests/storage/indexeddb/readonly-private-expected.txt	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/storage/indexeddb/readonly-private-expected.txt	2016-10-20 23:03:21 UTC (rev 207641)
@@ -16,9 +16,6 @@
 PASS transaction.db is still [object IDBDatabase]
 Deleted all object stores.
 objectStore = db.createObjectStore('foo');
-trying to set readonly property objectStore.name
-objectStore.name = 'bar'
-PASS objectStore.name is still foo
 trying to set readonly property objectStore.keyPath
 objectStore.keyPath = 'bar'
 PASS objectStore.keyPath is still null

Modified: trunk/LayoutTests/storage/indexeddb/resources/readonly.js (207640 => 207641)


--- trunk/LayoutTests/storage/indexeddb/resources/readonly.js	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/LayoutTests/storage/indexeddb/resources/readonly.js	2016-10-20 23:03:21 UTC (rev 207641)
@@ -30,7 +30,6 @@
 
     objectStore = evalAndLog("objectStore = db.createObjectStore('foo');");
 
-    setReadonlyProperty("objectStore.name", "'bar'");
     setReadonlyProperty("objectStore.keyPath", "'bar'");
 /* fails, split into separate test
     setReadonlyProperty("objectStore.indexNames", "['bar']");

Modified: trunk/Source/WebCore/ChangeLog (207640 => 207641)


--- trunk/Source/WebCore/ChangeLog	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/ChangeLog	2016-10-20 23:03:21 UTC (rev 207641)
@@ -1,3 +1,99 @@
+2016-10-20  Brady Eidson  <beid...@apple.com>
+
+        IndexedDB 2.0: Support IDBObjectStore name assignment.
+        <rdar://problem/28806931> and https://bugs.webkit.org/show_bug.cgi?id=163749
+
+        Reviewed by Alex Christensen.
+
+        Tests: storage/indexeddb/modern/objectstore-rename-1-private.html
+               storage/indexeddb/modern/objectstore-rename-1.html
+
+        Touches a *lot* of code sites, but none of them are particularly interesting.
+        They are all just getting the new name spread out to all of the various objects that need it.
+
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::renameObjectStore):
+        * Modules/indexeddb/IDBDatabase.h:
+
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::setName):
+        * Modules/indexeddb/IDBObjectStore.h:
+        * Modules/indexeddb/IDBObjectStore.idl:
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::renameObjectStore):
+        (WebCore::IDBTransaction::renameObjectStoreOnServer):
+        (WebCore::IDBTransaction::didRenameObjectStoreOnServer):
+        * Modules/indexeddb/IDBTransaction.h:
+
+        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+        (WebCore::IDBClient::IDBConnectionProxy::renameObjectStore):
+        * Modules/indexeddb/client/IDBConnectionProxy.h:
+
+        * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+        (WebCore::IDBClient::IDBConnectionToServer::renameObjectStore):
+        (WebCore::IDBClient::IDBConnectionToServer::didRenameObjectStore):
+        * Modules/indexeddb/client/IDBConnectionToServer.h:
+        * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
+
+        * Modules/indexeddb/server/IDBBackingStore.h:
+
+        * Modules/indexeddb/server/IDBConnectionToClient.cpp:
+        (WebCore::IDBServer::IDBConnectionToClient::didDeleteObjectStore):
+        (WebCore::IDBServer::IDBConnectionToClient::didRenameObjectStore):
+        * Modules/indexeddb/server/IDBConnectionToClient.h:
+        * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
+
+        * Modules/indexeddb/server/IDBServer.cpp:
+        (WebCore::IDBServer::IDBServer::renameObjectStore):
+        * Modules/indexeddb/server/IDBServer.h:
+
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreRenamed):
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
+
+        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+        (WebCore::IDBServer::MemoryIDBBackingStore::renameObjectStore):
+        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+        * Modules/indexeddb/server/MemoryObjectStore.h:
+        (WebCore::IDBServer::MemoryObjectStore::rename):
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::renameObjectStore):
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::renameObjectStore):
+        (WebCore::IDBServer::UniqueIDBDatabase::performRenameObjectStore):
+        (WebCore::IDBServer::UniqueIDBDatabase::didPerformRenameObjectStore):
+        * Modules/indexeddb/server/UniqueIDBDatabase.h:
+
+        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabaseConnection::didRenameObjectStore):
+        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:
+
+        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::renameObjectStore):
+        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
+
+        * Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
+        (WebCore::IDBDatabaseInfo::renameObjectStore):
+        * Modules/indexeddb/shared/IDBDatabaseInfo.h:
+
+        * Modules/indexeddb/shared/IDBObjectStoreInfo.h:
+        (WebCore::IDBObjectStoreInfo::rename):
+
+        * Modules/indexeddb/shared/IDBResultData.cpp:
+        (WebCore::IDBResultData::renameObjectStoreSuccess):
+        * Modules/indexeddb/shared/IDBResultData.h:
+
+        * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+        (WebCore::InProcessIDBServer::didRenameObjectStore):
+        (WebCore::InProcessIDBServer::renameObjectStore):
+        * Modules/indexeddb/shared/InProcessIDBServer.h:
+
 2016-10-20  Chris Dumez  <cdu...@apple.com>
 
         Make table.deleteRow(-1) a no-op when there are no rows

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -106,6 +106,17 @@
     return objectStoreNames;
 }
 
+void IDBDatabase::renameObjectStore(IDBObjectStore& objectStore, const String& newName)
+{
+    ASSERT(currentThread() == originThreadID());
+    ASSERT(m_versionChangeTransaction);
+    ASSERT(m_info.hasObjectStore(objectStore.info().name()));
+
+    m_info.renameObjectStore(objectStore.info().identifier(), newName);
+
+    m_versionChangeTransaction->renameObjectStore(objectStore, newName);
+}
+
 ExceptionOr<Ref<IDBObjectStore>> IDBDatabase::createObjectStore(const String&, const Dictionary&)
 {
     ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -62,6 +62,8 @@
     ExceptionOr<void> deleteObjectStore(const String& name);
     void close();
 
+    void renameObjectStore(IDBObjectStore&, const String& newName);
+
     // EventTarget
     EventTargetInterface eventTargetInterface() const final { return IDBDatabaseEventTargetInterfaceType; }
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -95,6 +95,31 @@
     return m_info.name();
 }
 
+ExceptionOr<void> IDBObjectStore::setName(const String& name)
+{
+    ASSERT(currentThread() == m_transaction->database().originThreadID());
+
+    if (m_deleted)
+        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBObjectStore': The object store has been deleted.") };
+
+    if (!m_transaction->isVersionChange())
+        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBObjectStore': The object store's transaction is not a version change transaction.") };
+
+    if (!m_transaction->isActive())
+        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBObjectStore': The object store's transaction is not active.") };
+
+    if (m_info.name() == name)
+        return { };
+
+    if (m_transaction->database().info().hasObjectStore(name))
+        return Exception { INVALID_STATE_ERR, makeString("Failed set property 'name' on 'IDBObjectStore': The database already has an object store named '", name, "'.") };
+
+    m_transaction->database().renameObjectStore(*this, name);
+    m_info.rename(name);
+
+    return { };
+}
+
 const IDBKeyPath& IDBObjectStore::keyPath() const
 {
     ASSERT(currentThread() == m_transaction->database().originThreadID());

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -60,6 +60,7 @@
     ~IDBObjectStore();
 
     const String& name() const;
+    ExceptionOr<void> setName(const String&);
     const IDBKeyPath& keyPath() const;
     RefPtr<DOMStringList> indexNames() const;
     IDBTransaction& transaction();

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl	2016-10-20 23:03:21 UTC (rev 207641)
@@ -30,7 +30,7 @@
     JSCustomMarkFunction,
     SkipVTableValidation,
 ] interface IDBObjectStore {
-    readonly attribute DOMString? name;
+    [SetterMayThrowException] attribute DOMString name;
     [ImplementationReturnType=IDBKeyPath] readonly attribute any keyPath;
     readonly attribute DOMStringList indexNames;
     readonly attribute IDBTransaction transaction;

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -601,6 +601,40 @@
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
+void IDBTransaction::renameObjectStore(IDBObjectStore& objectStore, const String& newName)
+{
+    LOG(IndexedDB, "IDBTransaction::renameObjectStore");
+    ASSERT(isVersionChange());
+    ASSERT(scriptExecutionContext());
+    ASSERT(currentThread() == m_database->originThreadID());
+
+    ASSERT(m_referencedObjectStores.contains(objectStore.info().name()));
+    ASSERT(!m_referencedObjectStores.contains(newName));
+    ASSERT(m_referencedObjectStores.get(objectStore.info().name()) == &objectStore);
+
+    uint64_t objectStoreIdentifier = objectStore.info().identifier();
+    auto operation = IDBClient::createTransactionOperation(*this, &IDBTransaction::didRenameObjectStoreOnServer, &IDBTransaction::renameObjectStoreOnServer, objectStoreIdentifier, newName);
+    scheduleOperation(WTFMove(operation));
+
+    m_referencedObjectStores.set(newName, m_referencedObjectStores.take(objectStore.info().name()));
+}
+
+void IDBTransaction::renameObjectStoreOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const String& newName)
+{
+    LOG(IndexedDB, "IDBTransaction::renameObjectStoreOnServer");
+    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(isVersionChange());
+
+    m_database->connectionProxy().renameObjectStore(operation, objectStoreIdentifier, newName);
+}
+
+void IDBTransaction::didRenameObjectStoreOnServer(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBTransaction::didRenameObjectStoreOnServer");
+    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::RenameObjectStoreSuccess || resultData.type() == IDBResultType::Error);
+}
+
 std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStore, const IDBIndexInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::createIndex");

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -113,6 +113,7 @@
     bool isActive() const;
 
     Ref<IDBObjectStore> createObjectStore(const IDBObjectStoreInfo&);
+    void renameObjectStore(IDBObjectStore&, const String& newName);
     std::unique_ptr<IDBIndex> createIndex(IDBObjectStore&, const IDBIndexInfo&);
 
     Ref<IDBRequest> requestPutOrAdd(JSC::ExecState&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
@@ -171,6 +172,9 @@
     void createObjectStoreOnServer(IDBClient::TransactionOperation&, const IDBObjectStoreInfo&);
     void didCreateObjectStoreOnServer(const IDBResultData&);
 
+    void renameObjectStoreOnServer(IDBClient::TransactionOperation&, const uint64_t& objectStoreIdentifier, const String& newName);
+    void didRenameObjectStoreOnServer(const IDBResultData&);
+
     void createIndexOnServer(IDBClient::TransactionOperation&, const IDBIndexInfo&);
     void didCreateIndexOnServer(const IDBResultData&);
 

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -125,6 +125,14 @@
     callConnectionOnMainThread(&IDBConnectionToServer::createObjectStore, requestData, info);
 }
 
+void IDBConnectionProxy::renameObjectStore(TransactionOperation& operation, uint64_t objectStoreIdentifier, const String& newName)
+{
+    const IDBRequestData requestData(operation);
+    saveOperation(operation);
+
+    callConnectionOnMainThread(&IDBConnectionToServer::renameObjectStore, requestData, objectStoreIdentifier, newName);
+}
+
 void IDBConnectionProxy::deleteObjectStore(TransactionOperation& operation, const String& objectStoreName)
 {
     const IDBRequestData requestData(operation);

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -77,7 +77,8 @@
     void deleteRecord(TransactionOperation&, const IDBKeyRangeData&);
     void openCursor(TransactionOperation&, const IDBCursorInfo&);
     void iterateCursor(TransactionOperation&, const IDBKeyData&, unsigned long count);
-    
+    void renameObjectStore(TransactionOperation&, uint64_t objectStoreIdentifier, const String& newName);
+
     void fireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
     void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier);
 

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -116,6 +116,20 @@
     m_proxy->completeOperation(resultData);
 }
 
+void IDBConnectionToServer::renameObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& newName)
+{
+    LOG(IndexedDB, "IDBConnectionToServer::renameObjectStore");
+    ASSERT(isMainThread());
+
+    m_delegate->renameObjectStore(requestData, objectStoreIdentifier, newName);
+}
+
+void IDBConnectionToServer::didRenameObjectStore(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "IDBConnectionToServer::didRenameObjectStore");
+    m_proxy->completeOperation(resultData);
+}
+
 void IDBConnectionToServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
 {
     LOG(IndexedDB, "IDBConnectionToServer::clearObjectStore");

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -68,6 +68,9 @@
     void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
     WEBCORE_EXPORT void didDeleteObjectStore(const IDBResultData&);
 
+    void renameObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName);
+    WEBCORE_EXPORT void didRenameObjectStore(const IDBResultData&);
+
     void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
     WEBCORE_EXPORT void didClearObjectStore(const IDBResultData&);
 

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -63,6 +63,7 @@
     virtual void didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier&) = 0;
     virtual void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&) = 0;
     virtual void deleteObjectStore(const IDBRequestData&, const String& objectStoreName) = 0;
+    virtual void renameObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName) = 0;
     virtual void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier) = 0;
     virtual void createIndex(const IDBRequestData&, const IDBIndexInfo&) = 0;
     virtual void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) = 0;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -70,6 +70,7 @@
 
     virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) = 0;
     virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
+    virtual IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) = 0;
     virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
     virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0;
     virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -73,6 +73,11 @@
     m_delegate->didDeleteObjectStore(result);
 }
 
+void IDBConnectionToClient::didRenameObjectStore(const IDBResultData& result)
+{
+    m_delegate->didRenameObjectStore(result);
+}
+
 void IDBConnectionToClient::didClearObjectStore(const IDBResultData& result)
 {
     m_delegate->didClearObjectStore(result);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -55,6 +55,7 @@
     void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&);
     void didCreateObjectStore(const IDBResultData&);
     void didDeleteObjectStore(const IDBResultData&);
+    void didRenameObjectStore(const IDBResultData&);
     void didClearObjectStore(const IDBResultData&);
     void didCreateIndex(const IDBResultData&);
     void didDeleteIndex(const IDBResultData&);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -53,6 +53,7 @@
     virtual void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) = 0;
     virtual void didCreateObjectStore(const IDBResultData&) = 0;
     virtual void didDeleteObjectStore(const IDBResultData&) = 0;
+    virtual void didRenameObjectStore(const IDBResultData&) = 0;
     virtual void didClearObjectStore(const IDBResultData&) = 0;
     virtual void didCreateIndex(const IDBResultData&) = 0;
     virtual void didDeleteIndex(const IDBResultData&) = 0;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -213,6 +213,18 @@
     transaction->deleteObjectStore(requestData, objectStoreName);
 }
 
+void IDBServer::renameObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& newName)
+{
+    LOG(IndexedDB, "IDBServer::renameObjectStore");
+
+    auto transaction = m_transactions.get(requestData.transactionIdentifier());
+    if (!transaction)
+        return;
+
+    ASSERT(transaction->isVersionChange());
+    transaction->renameObjectStore(requestData, objectStoreIdentifier, newName);
+}
+
 void IDBServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
 {
     LOG(IndexedDB, "IDBServer::clearObjectStore");

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -66,6 +66,7 @@
     WEBCORE_EXPORT void commitTransaction(const IDBResourceIdentifier&);
     WEBCORE_EXPORT void didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier&);
     WEBCORE_EXPORT void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
+    WEBCORE_EXPORT void renameObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName);
     WEBCORE_EXPORT void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
     WEBCORE_EXPORT void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
     WEBCORE_EXPORT void createIndex(const IDBRequestData&, const IDBIndexInfo&);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -150,6 +150,16 @@
     m_clearedOrderedKeys.add(&objectStore, WTFMove(orderedKeys));
 }
 
+void MemoryBackingStoreTransaction::objectStoreRenamed(MemoryObjectStore& objectStore, const String& oldName)
+{
+    ASSERT(m_objectStores.contains(&objectStore));
+    ASSERT(m_info.mode() == IndexedDB::TransactionMode::VersionChange);
+
+    // We only care about the first rename in a given transaction, because if the transaction is aborted we want
+    // to go back to the first 'oldName'
+    m_originalObjectStoreNames.add(&objectStore, oldName);
+}
+
 void MemoryBackingStoreTransaction::indexCleared(MemoryIndex& index, std::unique_ptr<IndexValueStore>&& valueStore)
 {
     auto addResult = m_clearedIndexValueStores.add(&index, nullptr);
@@ -193,6 +203,10 @@
 
     TemporaryChange<bool> change(m_isAborting, true);
 
+    for (auto iterator : m_originalObjectStoreNames)
+        iterator.key->rename(iterator.value);
+    m_originalObjectStoreNames.clear();
+
     for (auto objectStore : m_versionChangeAddedObjectStores)
         m_backingStore.removeObjectStoreForVersionChangeAbort(*objectStore);
     m_versionChangeAddedObjectStores.clear();

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -64,6 +64,7 @@
     void recordValueChanged(MemoryObjectStore&, const IDBKeyData&, ThreadSafeDataBuffer*);
     void objectStoreDeleted(Ref<MemoryObjectStore>&&);
     void objectStoreCleared(MemoryObjectStore&, std::unique_ptr<KeyValueMap>&&, std::unique_ptr<std::set<IDBKeyData>>&&);
+    void objectStoreRenamed(MemoryObjectStore&, const String& oldName);
     void indexCleared(MemoryIndex&, std::unique_ptr<IndexValueStore>&&);
 
     void addNewIndex(MemoryIndex&);
@@ -95,6 +96,7 @@
     HashMap<MemoryObjectStore*, std::unique_ptr<KeyValueMap>> m_originalValues;
     HashMap<MemoryObjectStore*, std::unique_ptr<KeyValueMap>> m_clearedKeyValueMaps;
     HashMap<MemoryObjectStore*, std::unique_ptr<std::set<IDBKeyData>>> m_clearedOrderedKeys;
+    HashMap<MemoryObjectStore*, String> m_originalObjectStoreNames;
     HashMap<MemoryIndex*, std::unique_ptr<IndexValueStore>> m_clearedIndexValueStores;
 };
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -171,6 +171,32 @@
     return IDBError();
 }
 
+IDBError MemoryIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
+{
+    LOG(IndexedDB, "MemoryIDBBackingStore::renameObjectStore");
+
+    ASSERT(m_databaseInfo);
+    if (!m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier))
+        return IDBError(IDBDatabaseException::ConstraintError);
+
+    auto transaction = m_transactions.get(transactionIdentifier);
+    ASSERT(transaction);
+    ASSERT(transaction->isVersionChange());
+
+    auto objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
+    ASSERT(objectStore);
+    if (!objectStore)
+        return IDBError(IDBDatabaseException::ConstraintError);
+
+    String oldName = objectStore->info().name();
+    objectStore->rename(newName);
+    transaction->objectStoreRenamed(*objectStore, oldName);
+
+    m_databaseInfo->renameObjectStore(objectStoreIdentifier, newName);
+
+    return IDBError();
+}
+
 IDBError MemoryIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
 {
     LOG(IndexedDB, "MemoryIDBBackingStore::clearObjectStore");

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -54,6 +54,7 @@
     IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
     IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) final;
     IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
+    IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) final;
     IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
     IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
     IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -97,6 +97,8 @@
 
     void maybeRestoreDeletedIndex(Ref<MemoryIndex>&&);
 
+    void rename(const String& newName) { m_info.rename(newName); }
+
 private:
     MemoryObjectStore(const IDBObjectStoreInfo&);
 

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


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -978,6 +978,39 @@
     return { };
 }
 
+IDBError SQLiteIDBBackingStore::renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
+{
+    LOG(IndexedDB, "SQLiteIDBBackingStore::renameObjectStore - object store %" PRIu64, objectStoreIdentifier);
+
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto* transaction = m_transactions.get(transactionIdentifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to rename an object store without an in-progress transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an object store without an in-progress transaction") };
+    }
+    if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
+        LOG_ERROR("Attempt to rename an object store in a non-version-change transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an object store in a non-version-change transaction") };
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("UPDATE ObjectStoreInfo SET name = ? WHERE id = ?;"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindText(1, newName) != SQLITE_OK
+            || sql.bindInt64(2, objectStoreIdentifier) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not update name for object store id %" PRIi64 " in ObjectStoreInfo table (%i) - %s", objectStoreIdentifier, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not rename object store") };
+        }
+    }
+
+    m_databaseInfo->renameObjectStore(objectStoreIdentifier, newName);
+
+    return { };
+}
+
 IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID)
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::clearObjectStore - object store %" PRIu64, objectStoreID);

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


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -58,6 +58,7 @@
     IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) final;
     IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) final;
     IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
+    IDBError renameObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName) final;
     IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) final;
     IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
     IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -660,6 +660,47 @@
     performErrorCallback(callbackIdentifier, error);
 }
 
+void UniqueIDBDatabase::renameObjectStore(UniqueIDBDatabaseTransaction& transaction, uint64_t objectStoreIdentifier, const String& newName, ErrorCallback callback)
+{
+    ASSERT(isMainThread());
+    LOG(IndexedDB, "(main) UniqueIDBDatabase::renameObjectStore");
+
+    uint64_t callbackID = storeCallbackOrFireError(callback);
+    if (!callbackID)
+        return;
+
+    auto* info = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
+    if (!info) {
+        performErrorCallback(callbackID, { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename non-existant object store") });
+        return;
+    }
+
+    postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performRenameObjectStore, callbackID, transaction.info().identifier(), objectStoreIdentifier, newName));
+}
+
+void UniqueIDBDatabase::performRenameObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName)
+{
+    ASSERT(!isMainThread());
+    LOG(IndexedDB, "(db) UniqueIDBDatabase::performRenameObjectStore");
+
+    ASSERT(m_backingStore);
+    m_backingStore->renameObjectStore(transactionIdentifier, objectStoreIdentifier, newName);
+
+    IDBError error;
+    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformRenameObjectStore, callbackIdentifier, error, objectStoreIdentifier, newName));
+}
+
+void UniqueIDBDatabase::didPerformRenameObjectStore(uint64_t callbackIdentifier, const IDBError& error, uint64_t objectStoreIdentifier, const String& newName)
+{
+    ASSERT(isMainThread());
+    LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformRenameObjectStore");
+
+    if (error.isNull())
+        m_databaseInfo->renameObjectStore(objectStoreIdentifier, newName);
+
+    performErrorCallback(callbackIdentifier, error);
+}
+
 void UniqueIDBDatabase::clearObjectStore(UniqueIDBDatabaseTransaction& transaction, uint64_t objectStoreIdentifier, ErrorCallback callback)
 {
     ASSERT(isMainThread());

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -87,6 +87,7 @@
 
     void createObjectStore(UniqueIDBDatabaseTransaction&, const IDBObjectStoreInfo&, ErrorCallback);
     void deleteObjectStore(UniqueIDBDatabaseTransaction&, const String& objectStoreName, ErrorCallback);
+    void renameObjectStore(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, const String& newName, ErrorCallback);
     void clearObjectStore(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, ErrorCallback);
     void createIndex(UniqueIDBDatabaseTransaction&, const IDBIndexInfo&, ErrorCallback);
     void deleteIndex(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, const String& indexName, ErrorCallback);
@@ -144,6 +145,7 @@
     void beginTransactionInBackingStore(const IDBTransactionInfo&);
     void performCreateObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&);
     void performDeleteObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier);
+    void performRenameObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& newName);
     void performClearObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier);
     void performCreateIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&);
     void performDeleteIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier);
@@ -162,6 +164,7 @@
     void didOpenBackingStore(const IDBDatabaseInfo&, const IDBError&);
     void didPerformCreateObjectStore(uint64_t callbackIdentifier, const IDBError&, const IDBObjectStoreInfo&);
     void didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier);
+    void didPerformRenameObjectStore(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier, const String& newName);
     void didPerformClearObjectStore(uint64_t callbackIdentifier, const IDBError&);
     void didPerformCreateIndex(uint64_t callbackIdentifier, const IDBError&, const IDBIndexInfo&);
     void didPerformDeleteIndex(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -184,6 +184,13 @@
     m_connectionToClient.didDeleteObjectStore(resultData);
 }
 
+void UniqueIDBDatabaseConnection::didRenameObjectStore(const IDBResultData& resultData)
+{
+    LOG(IndexedDB, "UniqueIDBDatabaseConnection::didRenameObjectStore");
+
+    m_connectionToClient.didRenameObjectStore(resultData);
+}
+
 void UniqueIDBDatabaseConnection::didClearObjectStore(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "UniqueIDBDatabaseConnection::didClearObjectStore");

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -69,6 +69,7 @@
     void didCommitTransaction(UniqueIDBDatabaseTransaction&, const IDBError&);
     void didCreateObjectStore(const IDBResultData&);
     void didDeleteObjectStore(const IDBResultData&);
+    void didRenameObjectStore(const IDBResultData&);
     void didClearObjectStore(const IDBResultData&);
     void didCreateIndex(const IDBResultData&);
     void didDeleteIndex(const IDBResultData&);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -137,6 +137,23 @@
     });
 }
 
+void UniqueIDBDatabaseTransaction::renameObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& newName)
+{
+    LOG(IndexedDB, "UniqueIDBDatabaseTransaction::renameObjectStore");
+
+    ASSERT(isVersionChange());
+    ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
+
+    RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this);
+    m_databaseConnection->database().renameObjectStore(*this, objectStoreIdentifier, newName, [this, protectedThis, requestData](const IDBError& error) {
+        LOG(IndexedDB, "UniqueIDBDatabaseTransaction::renameObjectStore (callback)");
+        if (error.isNull())
+            m_databaseConnection->didRenameObjectStore(IDBResultData::renameObjectStoreSuccess(requestData.requestIdentifier()));
+        else
+            m_databaseConnection->didRenameObjectStore(IDBResultData::error(requestData.requestIdentifier(), error));
+    });
+}
+
 void UniqueIDBDatabaseTransaction::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
 {
     LOG(IndexedDB, "UniqueIDBDatabaseTransaction::clearObjectStore");

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -69,6 +69,7 @@
 
     void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&);
     void deleteObjectStore(const IDBRequestData&, const String& objectStoreName);
+    void renameObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName);
     void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier);
     void createIndex(const IDBRequestData&, const IDBIndexInfo&);
     void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -122,6 +122,15 @@
     return getInfoForExistingObjectStore(name);
 }
 
+void IDBDatabaseInfo::renameObjectStore(uint64_t objectStoreIdentifier, const String& newName)
+{
+    auto* info = infoForExistingObjectStore(objectStoreIdentifier);
+    if (!info)
+        return;
+
+    info->rename(newName);
+}
+
 Vector<String> IDBDatabaseInfo::objectStoreNames() const
 {
     Vector<String> names;

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -57,6 +57,8 @@
     const IDBObjectStoreInfo* infoForExistingObjectStore(uint64_t objectStoreIdentifier) const;
     const IDBObjectStoreInfo* infoForExistingObjectStore(const String& objectStoreName) const;
 
+    void renameObjectStore(uint64_t objectStoreIdentifier, const String& newName);
+
     Vector<String> objectStoreNames() const;
 
     void deleteObjectStore(const String& objectStoreName);

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -48,6 +48,8 @@
     bool autoIncrement() const { return m_autoIncrement; }
     uint64_t maxIndexID() const { return m_maxIndexID; }
 
+    void rename(const String& newName) { m_name = newName; }
+
     IDBObjectStoreInfo isolatedCopy() const;
 
     IDBIndexInfo createNewIndex(const String& name, const IDBKeyPath&, bool unique, bool multiEntry);

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -139,6 +139,11 @@
     return { IDBResultType::DeleteObjectStoreSuccess, requestIdentifier };
 }
 
+IDBResultData IDBResultData::renameObjectStoreSuccess(const IDBResourceIdentifier& requestIdentifier)
+{
+    return { IDBResultType::RenameObjectStoreSuccess, requestIdentifier };
+}
+
 IDBResultData IDBResultData::clearObjectStoreSuccess(const IDBResourceIdentifier& requestIdentifier)
 {
     return { IDBResultType::ClearObjectStoreSuccess, requestIdentifier };

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -57,6 +57,7 @@
     DeleteIndexSuccess,
     OpenCursorSuccess,
     IterateCursorSuccess,
+    RenameObjectStoreSuccess,
 };
 
 namespace IDBServer {
@@ -72,6 +73,7 @@
     static IDBResultData deleteDatabaseSuccess(const IDBResourceIdentifier&, const IDBDatabaseInfo&);
     static IDBResultData createObjectStoreSuccess(const IDBResourceIdentifier&);
     static IDBResultData deleteObjectStoreSuccess(const IDBResourceIdentifier&);
+    static IDBResultData renameObjectStoreSuccess(const IDBResourceIdentifier&);
     static IDBResultData clearObjectStoreSuccess(const IDBResourceIdentifier&);
     static IDBResultData createIndexSuccess(const IDBResourceIdentifier&);
     static IDBResultData deleteIndexSuccess(const IDBResourceIdentifier&);

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -146,6 +146,13 @@
     });
 }
 
+void InProcessIDBServer::didRenameObjectStore(const IDBResultData& resultData)
+{
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
+        m_connectionToServer->didRenameObjectStore(resultData);
+    });
+}
+
 void InProcessIDBServer::didClearObjectStore(const IDBResultData& resultData)
 {
     RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
@@ -244,6 +251,13 @@
     });
 }
 
+void InProcessIDBServer::renameObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& newName)
+{
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, objectStoreIdentifier, newName] {
+        m_server->renameObjectStore(requestData, objectStoreIdentifier, newName);
+    });
+}
+
 void InProcessIDBServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
 {
     RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, objectStoreIdentifier] {

Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h (207640 => 207641)


--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -64,6 +64,7 @@
     void didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier&) final;
     void createObjectStore(const IDBRequestData&, const IDBObjectStoreInfo&) final;
     void deleteObjectStore(const IDBRequestData&, const String& objectStoreName) final;
+    void renameObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName) final;
     void clearObjectStore(const IDBRequestData&, uint64_t objectStoreIdentifier) final;
     void createIndex(const IDBRequestData&, const IDBIndexInfo&) final;
     void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) final;
@@ -89,6 +90,7 @@
     void didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) final;
     void didCreateObjectStore(const IDBResultData&) final;
     void didDeleteObjectStore(const IDBResultData&) final;
+    void didRenameObjectStore(const IDBResultData&) final;
     void didClearObjectStore(const IDBResultData&) final;
     void didCreateIndex(const IDBResultData&) final;
     void didDeleteIndex(const IDBResultData&) final;

Modified: trunk/Source/WebKit2/ChangeLog (207640 => 207641)


--- trunk/Source/WebKit2/ChangeLog	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/ChangeLog	2016-10-20 23:03:21 UTC (rev 207641)
@@ -1,3 +1,22 @@
+2016-10-20  Brady Eidson  <beid...@apple.com>
+
+        IndexedDB 2.0: Support IDBObjectStore name assignment.
+        <rdar://problem/28806931> and https://bugs.webkit.org/show_bug.cgi?id=163749
+
+        Reviewed by Alex Christensen.
+
+        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
+        (WebKit::WebIDBConnectionToClient::didRenameObjectStore):
+        (WebKit::WebIDBConnectionToClient::renameObjectStore):
+        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
+        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:
+
+        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
+        (WebKit::WebIDBConnectionToServer::renameObjectStore):
+        (WebKit::WebIDBConnectionToServer::didRenameObjectStore):
+        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
+        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in:
+
 2016-10-20  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Avoid strstr() when checking (E)GL extensions

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp (207640 => 207641)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -107,6 +107,11 @@
     send(Messages::WebIDBConnectionToServer::DidDeleteObjectStore(resultData));
 }
 
+void WebIDBConnectionToClient::didRenameObjectStore(const WebCore::IDBResultData& resultData)
+{
+    send(Messages::WebIDBConnectionToServer::DidRenameObjectStore(resultData));
+}
+
 void WebIDBConnectionToClient::didClearObjectStore(const WebCore::IDBResultData& resultData)
 {
     send(Messages::WebIDBConnectionToServer::DidClearObjectStore(resultData));
@@ -235,6 +240,11 @@
     DatabaseProcess::singleton().idbServer().deleteObjectStore(request, name);
 }
 
+void WebIDBConnectionToClient::renameObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier, const String& newName)
+{
+    DatabaseProcess::singleton().idbServer().renameObjectStore(request, objectStoreIdentifier, newName);
+}
+
 void WebIDBConnectionToClient::clearObjectStore(const IDBRequestData& request, uint64_t objectStoreIdentifier)
 {
     DatabaseProcess::singleton().idbServer().clearObjectStore(request, objectStoreIdentifier);

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h (207640 => 207641)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -64,6 +64,7 @@
     void didCommitTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&) final;
     void didCreateObjectStore(const WebCore::IDBResultData&) final;
     void didDeleteObjectStore(const WebCore::IDBResultData&) final;
+    void didRenameObjectStore(const WebCore::IDBResultData&) final;
     void didClearObjectStore(const WebCore::IDBResultData&) final;
     void didCreateIndex(const WebCore::IDBResultData&) final;
     void didDeleteIndex(const WebCore::IDBResultData&) final;
@@ -92,6 +93,7 @@
     void didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier&);
     void createObjectStore(const WebCore::IDBRequestData&, const WebCore::IDBObjectStoreInfo&);
     void deleteObjectStore(const WebCore::IDBRequestData&, const String& objectStoreName);
+    void renameObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName);
     void clearObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier);
     void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&);
     void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);

Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in (207640 => 207641)


--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in	2016-10-20 23:03:21 UTC (rev 207641)
@@ -30,6 +30,7 @@
     DidFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier transactionIdentifier);
     CreateObjectStore(WebCore::IDBRequestData requestData, WebCore::IDBObjectStoreInfo info);
     DeleteObjectStore(WebCore::IDBRequestData requestData, String objectStoreName);
+    RenameObjectStore(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, String newName);
     ClearObjectStore(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier);
     CreateIndex(WebCore::IDBRequestData requestData, WebCore::IDBIndexInfo info);
     DeleteIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, String indexName);

Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp (207640 => 207641)


--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp	2016-10-20 23:03:21 UTC (rev 207641)
@@ -118,6 +118,11 @@
     send(Messages::WebIDBConnectionToClient::DeleteObjectStore(requestData, objectStoreName));
 }
 
+void WebIDBConnectionToServer::renameObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& newName)
+{
+    send(Messages::WebIDBConnectionToClient::RenameObjectStore(requestData, objectStoreIdentifier, newName));
+}
+
 void WebIDBConnectionToServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
 {
     send(Messages::WebIDBConnectionToClient::ClearObjectStore(requestData, objectStoreIdentifier));
@@ -228,6 +233,11 @@
     m_connectionToServer->didDeleteObjectStore(result);
 }
 
+void WebIDBConnectionToServer::didRenameObjectStore(const IDBResultData& result)
+{
+    m_connectionToServer->didRenameObjectStore(result);
+}
+
 void WebIDBConnectionToServer::didClearObjectStore(const IDBResultData& result)
 {
     m_connectionToServer->didClearObjectStore(result);

Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h (207640 => 207641)


--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h	2016-10-20 23:03:21 UTC (rev 207641)
@@ -53,6 +53,7 @@
     void didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier&) final;
     void createObjectStore(const WebCore::IDBRequestData&, const WebCore::IDBObjectStoreInfo&) final;
     void deleteObjectStore(const WebCore::IDBRequestData&, const String& objectStoreName) final;
+    void renameObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& newName) final;
     void clearObjectStore(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier) final;
     void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&) final;
     void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) final;
@@ -81,6 +82,7 @@
     void didCommitTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&);
     void didCreateObjectStore(const WebCore::IDBResultData&);
     void didDeleteObjectStore(const WebCore::IDBResultData&);
+    void didRenameObjectStore(const WebCore::IDBResultData&);
     void didClearObjectStore(const WebCore::IDBResultData&);
     void didCreateIndex(const WebCore::IDBResultData&);
     void didDeleteIndex(const WebCore::IDBResultData&);

Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in (207640 => 207641)


--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in	2016-10-20 21:00:54 UTC (rev 207640)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in	2016-10-20 23:03:21 UTC (rev 207641)
@@ -29,6 +29,7 @@
     DidCommitTransaction(WebCore::IDBResourceIdentifier transactionIdentifier, WebCore::IDBError error)
     DidCreateObjectStore(WebCore::IDBResultData result)
     DidDeleteObjectStore(WebCore::IDBResultData result)
+    DidRenameObjectStore(WebCore::IDBResultData result)
     DidClearObjectStore(WebCore::IDBResultData result)
     DidCreateIndex(WebCore::IDBResultData result)
     DidDeleteIndex(WebCore::IDBResultData result)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to