Changeset 207761 in webkit


Ignore:
Timestamp:
Oct 24, 2016 9:24:09 AM (8 years ago)
Author:
beidson@apple.com
Message:

IndexedDB 2.0: Support IDBIndex name assignment.
<rdar://problem/28806932> and https://bugs.webkit.org/show_bug.cgi?id=163805

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

  • web-platform-tests/IndexedDB/idbindex-rename-errors-expected.txt:
  • web-platform-tests/IndexedDB/idbindex-rename-expected.txt:

Source/WebCore:

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

storage/indexeddb/modern/index-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::renameIndex):

  • Modules/indexeddb/IDBDatabase.h:
  • Modules/indexeddb/IDBIndex.cpp:

(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::setName):
(WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):

  • Modules/indexeddb/IDBIndex.h:
  • Modules/indexeddb/IDBIndex.idl:
  • Modules/indexeddb/IDBObjectStore.cpp:

(WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
(WebCore::IDBObjectStore::renameReferencedIndex):
(WebCore::IDBObjectStore::rollbackInfoForVersionChangeAbort): Deleted.

  • Modules/indexeddb/IDBObjectStore.h:
  • Modules/indexeddb/IDBTransaction.cpp:

(WebCore::IDBTransaction::internalAbort):
(WebCore::IDBTransaction::renameIndex):
(WebCore::IDBTransaction::renameIndexOnServer):
(WebCore::IDBTransaction::didRenameIndexOnServer):

  • Modules/indexeddb/IDBTransaction.h:
  • Modules/indexeddb/client/IDBConnectionProxy.cpp:

(WebCore::IDBClient::IDBConnectionProxy::renameIndex):

  • Modules/indexeddb/client/IDBConnectionProxy.h:
  • Modules/indexeddb/client/IDBConnectionToServer.cpp:

(WebCore::IDBClient::IDBConnectionToServer::renameIndex):
(WebCore::IDBClient::IDBConnectionToServer::didRenameIndex):

  • Modules/indexeddb/client/IDBConnectionToServer.h:
  • Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
  • Modules/indexeddb/client/TransactionOperation.h:

(WebCore::IDBClient::createTransactionOperation):

  • Modules/indexeddb/server/IDBBackingStore.h:
  • Modules/indexeddb/server/IDBConnectionToClient.cpp:

(WebCore::IDBServer::IDBConnectionToClient::didRenameIndex):

  • Modules/indexeddb/server/IDBConnectionToClient.h:
  • Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
  • Modules/indexeddb/server/IDBServer.cpp:

(WebCore::IDBServer::IDBServer::renameIndex):

  • Modules/indexeddb/server/IDBServer.h:
  • Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:

(WebCore::IDBServer::MemoryBackingStoreTransaction::indexRenamed):
(WebCore::IDBServer::MemoryBackingStoreTransaction::abort):

  • Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
  • Modules/indexeddb/server/MemoryIDBBackingStore.cpp:

(WebCore::IDBServer::MemoryIDBBackingStore::renameIndex):

  • Modules/indexeddb/server/MemoryIDBBackingStore.h:
  • Modules/indexeddb/server/MemoryIndex.h:

(WebCore::IDBServer::MemoryIndex::rename):

  • Modules/indexeddb/server/MemoryObjectStore.cpp:

(WebCore::IDBServer::MemoryObjectStore::renameIndex):

  • Modules/indexeddb/server/MemoryObjectStore.h:
  • Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):

  • Modules/indexeddb/server/SQLiteIDBBackingStore.h:
  • Modules/indexeddb/server/UniqueIDBDatabase.cpp:

(WebCore::IDBServer::UniqueIDBDatabase::renameIndex):
(WebCore::IDBServer::UniqueIDBDatabase::performRenameIndex):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformRenameIndex):

  • Modules/indexeddb/server/UniqueIDBDatabase.h:
  • Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:

(WebCore::IDBServer::UniqueIDBDatabaseConnection::didRenameIndex):

  • Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:
  • Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:

(WebCore::IDBServer::UniqueIDBDatabaseTransaction::renameIndex):

  • Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
  • Modules/indexeddb/shared/IDBIndexInfo.h:

(WebCore::IDBIndexInfo::rename):

  • Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:

(WebCore::IDBObjectStoreInfo::infoForExistingIndex):

  • Modules/indexeddb/shared/IDBObjectStoreInfo.h:
  • Modules/indexeddb/shared/IDBResultData.cpp:

(WebCore::IDBResultData::renameIndexSuccess):

  • Modules/indexeddb/shared/IDBResultData.h:
  • Modules/indexeddb/shared/InProcessIDBServer.cpp:

(WebCore::InProcessIDBServer::didRenameIndex):
(WebCore::InProcessIDBServer::renameIndex):

  • Modules/indexeddb/shared/InProcessIDBServer.h:

Source/WebKit2:

  • DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:

(WebKit::WebIDBConnectionToClient::didRenameIndex):
(WebKit::WebIDBConnectionToClient::renameIndex):

  • DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
  • DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:
  • WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:

(WebKit::WebIDBConnectionToServer::renameIndex):
(WebKit::WebIDBConnectionToServer::didRenameIndex):

  • WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
  • WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in:

LayoutTests:

  • storage/indexeddb/modern/index-rename-1-expected.txt: Added.
  • storage/indexeddb/modern/index-rename-1-private-expected.txt: Added.
  • storage/indexeddb/modern/index-rename-1-private.html: Added.
  • storage/indexeddb/modern/index-rename-1.html: Added.
  • storage/indexeddb/modern/resources/index-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 index names are readonly as they are no longer readonly.
Location:
trunk
Files:
5 added
58 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207757 r207761  
     12016-10-24  Brady Eidson  <beidson@apple.com>
     2
     3        IndexedDB 2.0: Support IDBIndex name assignment.
     4        <rdar://problem/28806932> and https://bugs.webkit.org/show_bug.cgi?id=163805
     5
     6        Reviewed by Alex Christensen.
     7
     8        * storage/indexeddb/modern/index-rename-1-expected.txt: Added.
     9        * storage/indexeddb/modern/index-rename-1-private-expected.txt: Added.
     10        * storage/indexeddb/modern/index-rename-1-private.html: Added.
     11        * storage/indexeddb/modern/index-rename-1.html: Added.
     12        * storage/indexeddb/modern/resources/index-rename-1.js: Added.
     13
     14        * storage/indexeddb/readonly-expected.txt:
     15        * storage/indexeddb/readonly-private-expected.txt:
     16        * storage/indexeddb/resources/readonly.js: Removed the test that verifies that index names are
     17          readonly as they are no longer readonly.
     18
    1192016-10-24  Dave Hyatt  <hyatt@apple.com>
    220
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r207710 r207761  
     12016-10-24  Brady Eidson  <beidson@apple.com>
     2
     3        IndexedDB 2.0: Support IDBIndex name assignment.
     4        <rdar://problem/28806932> and https://bugs.webkit.org/show_bug.cgi?id=163805
     5
     6        Reviewed by Alex Christensen.
     7
     8        * web-platform-tests/IndexedDB/idbindex-rename-errors-expected.txt:
     9        * web-platform-tests/IndexedDB/idbindex-rename-expected.txt:
     10
    1112016-10-22  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbindex-rename-errors-expected.txt

    r206999 r207761  
    11
    2 FAIL IndexedDB deleted index rename throws assert_throws: function "() => index.name = 'renamed_by_author'" did not throw
    3 FAIL IndexedDB index rename throws in a readonly transaction assert_throws: function "() => index.name = 'renamed_by_author'" did not throw
    4 FAIL IndexedDB index rename throws in a readwrite transaction assert_throws: function "() => index.name = 'renamed_by_author'" did not throw
    5 FAIL IndexedDB index rename throws in an inactive transaction assert_throws: function "() => authorIndex.name = 'renamed_by_author'" did not throw
    6 FAIL IndexedDB index rename to the name of another index throws assert_throws: function "() => index.name = 'by_title'" did not throw
    7 FAIL IndexedDB index rename handles exceptions when stringifying names assert_throws: IDBObjectStore rename should re-raise toString() exception function "() => {
    8               index.name = {
    9                 toSt..." did not throw
     2PASS IndexedDB deleted index rename throws
     3PASS IndexedDB index rename throws in a readonly transaction
     4PASS IndexedDB index rename throws in a readwrite transaction
     5FAIL IndexedDB index rename throws in an inactive transaction assert_throws: function "() => authorIndex.name = 'renamed_by_author'" threw object "InvalidStateError (DOM Exception 11): Failed set property..." that is not a DOMException TransactionInactiveError: property "code" is equal to 11, expected 0
     6FAIL IndexedDB index rename to the name of another index throws assert_throws: function "() => index.name = 'by_title'" threw object "InvalidStateError (DOM Exception 11): Failed set property..." that is not a DOMException ConstraintError: property "code" is equal to 11, expected 0
     7PASS IndexedDB index rename handles exceptions when stringifying names
    108
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbindex-rename-expected.txt

    r206999 r207761  
    11
    2 FAIL IndexedDB index rename in new transaction assert_equals: IDBIndex name should change immediately after a rename expected "renamed_by_author" but got "by_author"
    3 FAIL IndexedDB index rename in the transaction where it is created assert_equals: IDBIndex name should change immediately after a rename expected "renamed_by_author" but got "by_author"
     2PASS IndexedDB index rename in new transaction
     3PASS IndexedDB index rename in the transaction where it is created
    44PASS IndexedDB index rename to the same name succeeds
    5 FAIL IndexedDB index rename to the name of a deleted index succeeds assert_array_equals: IDBObjectStore.indexNames should immediately reflect the rename property 0, expected "by_title" but got "by_author"
    6 FAIL IndexedDB index swapping via renames succeeds Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.
    7 FAIL IndexedDB index rename stringifies non-string names assert_equals: IDBIndex name should change immediately after a rename to a number expected "42" but got "by_author"
    8 FAIL IndexedDB index can be renamed to "" assert_equals: IDBIndex name should change immediately after the rename expected "" but got "by_author"
    9 FAIL IndexedDB index can be renamed to "\u0000" assert_equals: IDBIndex name should change immediately after the rename expected "\0" but got "by_author"
    10 FAIL IndexedDB index can be renamed to "\uDC00\uD800" assert_equals: IDBIndex name should change immediately after the rename expected "í°€í €" but got "by_author"
     5PASS IndexedDB index rename to the name of a deleted index succeeds
     6PASS IndexedDB index swapping via renames succeeds
     7PASS IndexedDB index rename stringifies non-string names
     8PASS IndexedDB index can be renamed to ""
     9PASS IndexedDB index can be renamed to "\u0000"
     10PASS IndexedDB index can be renamed to "\uDC00\uD800"
    1111
  • trunk/LayoutTests/storage/indexeddb/readonly-expected.txt

    r207641 r207761  
    3636PASS cursor.primaryKey is still first
    3737index = objectStore.createIndex('first', 'first');
    38 trying to set readonly property index.name
    39 index.name = 'bar'
    40 PASS index.name is still first
    4138trying to set readonly property index.objectStore
    4239index.objectStore = this
  • trunk/LayoutTests/storage/indexeddb/readonly-private-expected.txt

    r207641 r207761  
    3636PASS cursor.primaryKey is still first
    3737index = objectStore.createIndex('first', 'first');
    38 trying to set readonly property index.name
    39 index.name = 'bar'
    40 PASS index.name is still first
    4138trying to set readonly property index.objectStore
    4239index.objectStore = this
  • trunk/LayoutTests/storage/indexeddb/resources/readonly.js

    r207641 r207761  
    6464
    6565    index = evalAndLog("index = objectStore.createIndex('first', 'first');");
    66     setReadonlyProperty("index.name", "'bar'");
    6766    setReadonlyProperty("index.objectStore", "this");
    6867    setReadonlyProperty("index.keyPath", "'bar'");
  • trunk/Source/WebCore/ChangeLog

    r207759 r207761  
     12016-10-24  Brady Eidson  <beidson@apple.com>
     2
     3        IndexedDB 2.0: Support IDBIndex name assignment.
     4        <rdar://problem/28806932> and https://bugs.webkit.org/show_bug.cgi?id=163805
     5
     6        Reviewed by Alex Christensen.
     7
     8        Tests: storage/indexeddb/modern/index-rename-1-private.html
     9               storage/indexeddb/modern/index-rename-1.html
     10
     11        Touches a *lot* of code sites, but none of them are particularly interesting.
     12        They are all just getting the new name spread out to all of the various objects that need it.
     13
     14        * Modules/indexeddb/IDBDatabase.cpp:
     15        (WebCore::IDBDatabase::renameIndex):
     16        * Modules/indexeddb/IDBDatabase.h:
     17
     18        * Modules/indexeddb/IDBIndex.cpp:
     19        (WebCore::IDBIndex::IDBIndex):
     20        (WebCore::IDBIndex::setName):
     21        (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
     22        * Modules/indexeddb/IDBIndex.h:
     23        * Modules/indexeddb/IDBIndex.idl:
     24
     25        * Modules/indexeddb/IDBObjectStore.cpp:
     26        (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
     27        (WebCore::IDBObjectStore::renameReferencedIndex):
     28        (WebCore::IDBObjectStore::rollbackInfoForVersionChangeAbort): Deleted.
     29        * Modules/indexeddb/IDBObjectStore.h:
     30
     31        * Modules/indexeddb/IDBTransaction.cpp:
     32        (WebCore::IDBTransaction::internalAbort):
     33        (WebCore::IDBTransaction::renameIndex):
     34        (WebCore::IDBTransaction::renameIndexOnServer):
     35        (WebCore::IDBTransaction::didRenameIndexOnServer):
     36        * Modules/indexeddb/IDBTransaction.h:
     37
     38        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
     39        (WebCore::IDBClient::IDBConnectionProxy::renameIndex):
     40        * Modules/indexeddb/client/IDBConnectionProxy.h:
     41
     42        * Modules/indexeddb/client/IDBConnectionToServer.cpp:
     43        (WebCore::IDBClient::IDBConnectionToServer::renameIndex):
     44        (WebCore::IDBClient::IDBConnectionToServer::didRenameIndex):
     45        * Modules/indexeddb/client/IDBConnectionToServer.h:
     46        * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
     47
     48        * Modules/indexeddb/client/TransactionOperation.h:
     49        (WebCore::IDBClient::createTransactionOperation):
     50
     51        * Modules/indexeddb/server/IDBBackingStore.h:
     52
     53        * Modules/indexeddb/server/IDBConnectionToClient.cpp:
     54        (WebCore::IDBServer::IDBConnectionToClient::didRenameIndex):
     55        * Modules/indexeddb/server/IDBConnectionToClient.h:
     56        * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
     57
     58        * Modules/indexeddb/server/IDBServer.cpp:
     59        (WebCore::IDBServer::IDBServer::renameIndex):
     60        * Modules/indexeddb/server/IDBServer.h:
     61
     62        * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
     63        (WebCore::IDBServer::MemoryBackingStoreTransaction::indexRenamed):
     64        (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
     65        * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
     66
     67        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
     68        (WebCore::IDBServer::MemoryIDBBackingStore::renameIndex):
     69        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
     70
     71        * Modules/indexeddb/server/MemoryIndex.h:
     72        (WebCore::IDBServer::MemoryIndex::rename):
     73
     74        * Modules/indexeddb/server/MemoryObjectStore.cpp:
     75        (WebCore::IDBServer::MemoryObjectStore::renameIndex):
     76        * Modules/indexeddb/server/MemoryObjectStore.h:
     77
     78        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
     79        (WebCore::IDBServer::SQLiteIDBBackingStore::renameIndex):
     80        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
     81
     82        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
     83        (WebCore::IDBServer::UniqueIDBDatabase::renameIndex):
     84        (WebCore::IDBServer::UniqueIDBDatabase::performRenameIndex):
     85        (WebCore::IDBServer::UniqueIDBDatabase::didPerformRenameIndex):
     86        * Modules/indexeddb/server/UniqueIDBDatabase.h:
     87
     88        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
     89        (WebCore::IDBServer::UniqueIDBDatabaseConnection::didRenameIndex):
     90        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:
     91
     92        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
     93        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::renameIndex):
     94        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
     95
     96        * Modules/indexeddb/shared/IDBIndexInfo.h:
     97        (WebCore::IDBIndexInfo::rename):
     98
     99        * Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:
     100        (WebCore::IDBObjectStoreInfo::infoForExistingIndex):
     101        * Modules/indexeddb/shared/IDBObjectStoreInfo.h:
     102
     103        * Modules/indexeddb/shared/IDBResultData.cpp:
     104        (WebCore::IDBResultData::renameIndexSuccess):
     105        * Modules/indexeddb/shared/IDBResultData.h:
     106
     107        * Modules/indexeddb/shared/InProcessIDBServer.cpp:
     108        (WebCore::InProcessIDBServer::didRenameIndex):
     109        (WebCore::InProcessIDBServer::renameIndex):
     110        * Modules/indexeddb/shared/InProcessIDBServer.h:
     111
    11122016-10-24  Dave Hyatt  <hyatt@apple.com>
    2113
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp

    r207641 r207761  
    3535#include "IDBConnectionToServer.h"
    3636#include "IDBDatabaseException.h"
     37#include "IDBIndex.h"
    3738#include "IDBObjectStore.h"
    3839#include "IDBOpenDBRequest.h"
     
    116117
    117118    m_versionChangeTransaction->renameObjectStore(objectStore, newName);
     119}
     120
     121void IDBDatabase::renameIndex(IDBIndex& index, const String& newName)
     122{
     123    ASSERT(currentThread() == originThreadID());
     124    ASSERT(m_versionChangeTransaction);
     125    ASSERT(m_info.hasObjectStore(index.objectStore().info().name()));
     126    ASSERT(m_info.infoForExistingObjectStore(index.objectStore().info().name())->hasIndex(index.info().name()));
     127
     128    m_info.infoForExistingObjectStore(index.objectStore().info().name())->infoForExistingIndex(index.info().identifier())->rename(newName);
     129
     130    m_versionChangeTransaction->renameIndex(index, newName);
    118131}
    119132
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h

    r207641 r207761  
    6464
    6565    void renameObjectStore(IDBObjectStore&, const String& newName);
     66    void renameIndex(IDBIndex&, const String& newName);
    6667
    6768    // EventTarget
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp

    r206976 r207761  
    4646    : ActiveDOMObject(&context)
    4747    , m_info(info)
     48    , m_originalInfo(info)
    4849    , m_objectStore(objectStore)
    4950{
     
    7980}
    8081
     82ExceptionOr<void> IDBIndex::setName(const String& name)
     83{
     84    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
     85
     86    if (m_deleted)
     87        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBIndex': The index has been deleted.") };
     88
     89    if (m_objectStore.isDeleted())
     90        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBIndex': The index's object store has been deleted.") };
     91
     92    if (!m_objectStore.transaction().isVersionChange())
     93        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBIndex': The index's transaction is not a version change transaction.") };
     94
     95    if (!m_objectStore.transaction().isActive())
     96        return Exception { INVALID_STATE_ERR, ASCIILiteral("Failed set property 'name' on 'IDBIndex': The index's transaction is not active.") };
     97
     98    if (m_info.name() == name)
     99        return { };
     100
     101    if (m_objectStore.info().hasIndex(name))
     102        return Exception { INVALID_STATE_ERR, makeString("Failed set property 'name' on 'IDBIndex': The owning object store already has an index named '", name, "'.") };
     103
     104    m_objectStore.transaction().database().renameIndex(*this, name);
     105    m_info.rename(name);
     106
     107    return { };
     108}
     109
    81110IDBObjectStore& IDBIndex::objectStore()
    82111{
     
    101130    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
    102131    return m_info.multiEntry();
     132}
     133
     134void IDBIndex::rollbackInfoForVersionChangeAbort()
     135{
     136    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
     137    m_info = m_originalInfo;
    103138}
    104139
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h

    r206976 r207761  
    4949
    5050    const String& name() const;
     51    ExceptionOr<void> setName(const String&);
    5152    IDBObjectStore& objectStore();
    5253    const IDBKeyPath& keyPath() const;
    5354    bool unique() const;
    5455    bool multiEntry() const;
     56
     57    void rollbackInfoForVersionChangeAbort();
    5558
    5659    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, IDBKeyRange*, const String& direction);
     
    8891
    8992    IDBIndexInfo m_info;
     93    IDBIndexInfo m_originalInfo;
    9094
    9195    bool m_deleted { false };
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl

    r206976 r207761  
    3131    SkipVTableValidation,
    3232] interface IDBIndex {
    33     readonly attribute DOMString name;
     33    [SetterMayThrowException] attribute DOMString name;
    3434    readonly attribute IDBObjectStore objectStore;
    3535    [ImplementationReturnType=IDBKeyPath] readonly attribute any keyPath;
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r207641 r207761  
    527527}
    528528
    529 void IDBObjectStore::rollbackInfoForVersionChangeAbort()
     529void IDBObjectStore::rollbackForVersionChangeAbort()
    530530{
    531531    ASSERT(currentThread() == m_transaction->database().originThreadID());
    532532    m_info = m_originalInfo;
     533
     534    Locker<Lock> locker(m_referencedIndexLock);
     535    for (auto& index : m_referencedIndexes.values())
     536        index->rollbackInfoForVersionChangeAbort();
    533537}
    534538
     
    540544}
    541545
     546void IDBObjectStore::renameReferencedIndex(IDBIndex& index, const String& newName)
     547{
     548    LOG(IndexedDB, "IDBObjectStore::renameReferencedIndex");
     549
     550    auto* indexInfo = m_info.infoForExistingIndex(index.info().identifier());
     551    ASSERT(indexInfo);
     552    indexInfo->rename(newName);
     553
     554    ASSERT(m_referencedIndexes.contains(index.info().name()));
     555    ASSERT(!m_referencedIndexes.contains(newName));
     556    ASSERT(m_referencedIndexes.get(index.info().name()) == &index);
     557
     558    m_referencedIndexes.set(newName, m_referencedIndexes.take(index.info().name()));
     559}
     560
    542561} // namespace WebCore
    543562
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h

    r207641 r207761  
    9494    const IDBObjectStoreInfo& info() const { return m_info; }
    9595
    96     void rollbackInfoForVersionChangeAbort();
     96    void rollbackForVersionChangeAbort();
    9797
    9898    void visitReferencedIndexes(JSC::SlotVisitor&) const;
     99    void renameReferencedIndex(IDBIndex&, const String& newName);
    99100
    100101private:
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp

    r207641 r207761  
    280280    if (isVersionChange()) {
    281281        for (auto& objectStore : m_referencedObjectStores.values())
    282             objectStore->rollbackInfoForVersionChangeAbort();
     282            objectStore->rollbackForVersionChangeAbort();
    283283    }
    284284
     
    676676    // Otherwise, failure to create an index forced abortion of the transaction.
    677677    abortDueToFailedRequest(DOMError::create(IDBDatabaseException::getErrorName(resultData.error().code()), resultData.error().message()));
     678}
     679
     680void IDBTransaction::renameIndex(IDBIndex& index, const String& newName)
     681{
     682    LOG(IndexedDB, "IDBTransaction::renameIndex");
     683    ASSERT(isVersionChange());
     684    ASSERT(scriptExecutionContext());
     685    ASSERT(currentThread() == m_database->originThreadID());
     686
     687    ASSERT(m_referencedObjectStores.contains(index.objectStore().info().name()));
     688    ASSERT(m_referencedObjectStores.get(index.objectStore().info().name()) == &index.objectStore());
     689
     690    index.objectStore().renameReferencedIndex(index, newName);
     691
     692    uint64_t objectStoreIdentifier = index.objectStore().info().identifier();
     693    uint64_t indexIdentifier = index.info().identifier();
     694    auto operation = IDBClient::createTransactionOperation(*this, &IDBTransaction::didRenameIndexOnServer, &IDBTransaction::renameIndexOnServer, objectStoreIdentifier, indexIdentifier, newName);
     695    scheduleOperation(WTFMove(operation));
     696}
     697
     698void IDBTransaction::renameIndexOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const uint64_t& indexIdentifier, const String& newName)
     699{
     700    LOG(IndexedDB, "IDBTransaction::renameIndexOnServer");
     701    ASSERT(currentThread() == m_database->originThreadID());
     702    ASSERT(isVersionChange());
     703
     704    m_database->connectionProxy().renameIndex(operation, objectStoreIdentifier, indexIdentifier, newName);
     705}
     706
     707void IDBTransaction::didRenameIndexOnServer(const IDBResultData& resultData)
     708{
     709    LOG(IndexedDB, "IDBTransaction::didRenameIndexOnServer");
     710    ASSERT(currentThread() == m_database->originThreadID());
     711    ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::RenameIndexSuccess || resultData.type() == IDBResultType::Error);
    678712}
    679713
  • trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h

    r207641 r207761  
    116116    void renameObjectStore(IDBObjectStore&, const String& newName);
    117117    std::unique_ptr<IDBIndex> createIndex(IDBObjectStore&, const IDBIndexInfo&);
     118    void renameIndex(IDBIndex&, const String& newName);
    118119
    119120    Ref<IDBRequest> requestPutOrAdd(JSC::ExecState&, IDBObjectStore&, IDBKey*, SerializedScriptValue&, IndexedDB::ObjectStoreOverwriteMode);
     
    179180    void didCreateIndexOnServer(const IDBResultData&);
    180181
     182    void renameIndexOnServer(IDBClient::TransactionOperation&, const uint64_t& objectStoreIdentifier, const uint64_t& indexIdentifier, const String& newName);
     183    void didRenameIndexOnServer(const IDBResultData&);
     184
    181185    void clearObjectStoreOnServer(IDBClient::TransactionOperation&, const uint64_t& objectStoreIdentifier);
    182186    void didClearObjectStoreOnServer(IDBRequest&, const IDBResultData&);
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp

    r207641 r207761  
    134134}
    135135
     136void IDBConnectionProxy::renameIndex(TransactionOperation& operation, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     137{
     138    const IDBRequestData requestData(operation);
     139    saveOperation(operation);
     140
     141    callConnectionOnMainThread(&IDBConnectionToServer::renameIndex, requestData, objectStoreIdentifier, indexIdentifier, newName);
     142}
     143
    136144void IDBConnectionProxy::deleteObjectStore(TransactionOperation& operation, const String& objectStoreName)
    137145{
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h

    r207641 r207761  
    7979    void iterateCursor(TransactionOperation&, const IDBKeyData&, unsigned long count);
    8080    void renameObjectStore(TransactionOperation&, uint64_t objectStoreIdentifier, const String& newName);
     81    void renameIndex(TransactionOperation&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
    8182
    8283    void fireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp

    r207641 r207761  
    173173}
    174174
     175void IDBConnectionToServer::renameIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     176{
     177    LOG(IndexedDB, "IDBConnectionToServer::renameIndex");
     178    ASSERT(isMainThread());
     179
     180    m_delegate->renameIndex(requestData, objectStoreIdentifier, indexIdentifier, newName);
     181}
     182
     183void IDBConnectionToServer::didRenameIndex(const IDBResultData& resultData)
     184{
     185    LOG(IndexedDB, "IDBConnectionToServer::didRenameIndex");
     186    m_proxy->completeOperation(resultData);
     187}
     188
    175189void IDBConnectionToServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& key, const IDBValue& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
    176190{
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h

    r207641 r207761  
    8181    WEBCORE_EXPORT void didDeleteIndex(const IDBResultData&);
    8282
     83    void renameIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
     84    WEBCORE_EXPORT void didRenameIndex(const IDBResultData&);
     85
    8386    void putOrAdd(const IDBRequestData&, const IDBKeyData&, const IDBValue&, const IndexedDB::ObjectStoreOverwriteMode);
    8487    WEBCORE_EXPORT void didPutOrAdd(const IDBResultData&);
  • trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h

    r207641 r207761  
    6868    virtual void createIndex(const IDBRequestData&, const IDBIndexInfo&) = 0;
    6969    virtual void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) = 0;
     70    virtual void renameIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) = 0;
    7071    virtual void putOrAdd(const IDBRequestData&, const IDBKeyData&, const IDBValue&, const IndexedDB::ObjectStoreOverwriteMode) = 0;
    7172    virtual void getRecord(const IDBRequestData&, const IDBGetRecordData&) = 0;
  • trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h

    r202821 r207761  
    195195}
    196196
     197template<typename MP1, typename P1, typename MP2, typename P2, typename MP3, typename P3>
     198RefPtr<TransactionOperation> createTransactionOperation(
     199    IDBTransaction& transaction,
     200    void (IDBTransaction::*complete)(const IDBResultData&),
     201    void (IDBTransaction::*perform)(TransactionOperation&, MP1, MP2, MP3),
     202    const P1& parameter1,
     203    const P2& parameter2,
     204    const P3& parameter3)
     205{
     206    auto operation = new TransactionOperationImpl<MP1, MP2, MP3>(transaction, complete, perform, parameter1, parameter2, parameter3);
     207    return adoptRef(operation);
     208}
     209
    197210template<typename MP1, typename P1>
    198211RefPtr<TransactionOperation> createTransactionOperation(
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h

    r207641 r207761  
    7575    virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0;
    7676    virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) = 0;
     77    virtual IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) = 0;
    7778    virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
    7879    virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp

    r207641 r207761  
    9494}
    9595
     96void IDBConnectionToClient::didRenameIndex(const IDBResultData& result)
     97{
     98    m_delegate->didRenameIndex(result);
     99}
     100
    96101void IDBConnectionToClient::didPutOrAdd(const IDBResultData& result)
    97102{
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h

    r207641 r207761  
    6060    void didCreateIndex(const IDBResultData&);
    6161    void didDeleteIndex(const IDBResultData&);
     62    void didRenameIndex(const IDBResultData&);
    6263    void didPutOrAdd(const IDBResultData&);
    6364    void didGetRecord(const IDBResultData&);
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h

    r207641 r207761  
    5858    virtual void didCreateIndex(const IDBResultData&) = 0;
    5959    virtual void didDeleteIndex(const IDBResultData&) = 0;
     60    virtual void didRenameIndex(const IDBResultData&) = 0;
    6061    virtual void didPutOrAdd(const IDBResultData&) = 0;
    6162    virtual void didGetRecord(const IDBResultData&) = 0;
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r207641 r207761  
    261261}
    262262
     263void IDBServer::renameIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     264{
     265    LOG(IndexedDB, "IDBServer::renameIndex");
     266
     267    auto transaction = m_transactions.get(requestData.transactionIdentifier());
     268    if (!transaction)
     269        return;
     270
     271    ASSERT(transaction->isVersionChange());
     272    transaction->renameIndex(requestData, objectStoreIdentifier, indexIdentifier, newName);
     273}
     274
    263275void IDBServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
    264276{
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h

    r207641 r207761  
    7272    WEBCORE_EXPORT void createIndex(const IDBRequestData&, const IDBIndexInfo&);
    7373    WEBCORE_EXPORT void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
     74    WEBCORE_EXPORT void renameIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
    7475    WEBCORE_EXPORT void putOrAdd(const IDBRequestData&, const IDBKeyData&, const IDBValue&, IndexedDB::ObjectStoreOverwriteMode);
    7576    WEBCORE_EXPORT void getRecord(const IDBRequestData&, const IDBGetRecordData&);
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp

    r207641 r207761  
    161161}
    162162
     163void MemoryBackingStoreTransaction::indexRenamed(MemoryIndex& index, const String& oldName)
     164{
     165    ASSERT(m_objectStores.contains(&index.objectStore()));
     166    ASSERT(m_info.mode() == IndexedDB::TransactionMode::VersionChange);
     167
     168    // We only care about the first rename in a given transaction, because if the transaction is aborted we want
     169    // to go back to the first 'oldName'
     170    m_originalIndexNames.add(&index, oldName);
     171}
     172
    163173void MemoryBackingStoreTransaction::indexCleared(MemoryIndex& index, std::unique_ptr<IndexValueStore>&& valueStore)
    164174{
     
    203213
    204214    TemporaryChange<bool> change(m_isAborting, true);
     215
     216    for (auto iterator : m_originalIndexNames)
     217        iterator.key->rename(iterator.value);
     218    m_originalIndexNames.clear();
    205219
    206220    for (auto iterator : m_originalObjectStoreNames)
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h

    r207641 r207761  
    6666    void objectStoreCleared(MemoryObjectStore&, std::unique_ptr<KeyValueMap>&&, std::unique_ptr<std::set<IDBKeyData>>&&);
    6767    void objectStoreRenamed(MemoryObjectStore&, const String& oldName);
     68    void indexRenamed(MemoryIndex&, const String& oldName);
    6869    void indexCleared(MemoryIndex&, std::unique_ptr<IndexValueStore>&&);
    6970
     
    9899    HashMap<MemoryObjectStore*, std::unique_ptr<std::set<IDBKeyData>>> m_clearedOrderedKeys;
    99100    HashMap<MemoryObjectStore*, String> m_originalObjectStoreNames;
     101    HashMap<MemoryIndex*, String> m_originalIndexNames;
    100102    HashMap<MemoryIndex*, std::unique_ptr<IndexValueStore>> m_clearedIndexValueStores;
    101103};
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp

    r207641 r207761  
    249249}
    250250
     251IDBError MemoryIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     252{
     253    LOG(IndexedDB, "MemoryIDBBackingStore::renameIndex");
     254
     255    ASSERT(m_databaseInfo);
     256    auto* objectStoreInfo = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
     257    if (!objectStoreInfo)
     258        return IDBError(IDBDatabaseException::ConstraintError);
     259
     260    auto* indexInfo = objectStoreInfo->infoForExistingIndex(indexIdentifier);
     261    if (!indexInfo)
     262        return IDBError(IDBDatabaseException::ConstraintError);
     263
     264    auto transaction = m_transactions.get(transactionIdentifier);
     265    ASSERT(transaction);
     266    ASSERT(transaction->isVersionChange());
     267
     268    auto objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
     269    ASSERT(objectStore);
     270    if (!objectStore)
     271        return IDBError(IDBDatabaseException::ConstraintError);
     272
     273    auto* index = objectStore->indexForIdentifier(indexIdentifier);
     274    ASSERT(index);
     275    if (!index)
     276        return IDBError(IDBDatabaseException::ConstraintError);
     277
     278    String oldName = index->info().name();
     279    objectStore->renameIndex(*index, newName);
     280    transaction->indexRenamed(*index, oldName);
     281
     282    indexInfo->rename(newName);
     283
     284    return IDBError();
     285}
     286
    251287void MemoryIDBBackingStore::removeObjectStoreForVersionChangeAbort(MemoryObjectStore& objectStore)
    252288{
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h

    r207641 r207761  
    5959    IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
    6060    IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
     61    IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
    6162    IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
    6263    IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h

    r199668 r207761  
    6363    const IDBIndexInfo& info() const { return m_info; }
    6464
     65    void rename(const String& newName) { m_info.rename(newName); }
     66
    6567    IDBGetResult getResultForKeyRange(IndexedDB::IndexRecordType, const IDBKeyRangeData&) const;
    6668    uint64_t countForKeyRange(const IDBKeyRangeData&);
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp

    r201665 r207761  
    476476}
    477477
     478void MemoryObjectStore::renameIndex(MemoryIndex& index, const String& newName)
     479{
     480    ASSERT(m_indexesByName.get(index.info().name()) == &index);
     481    ASSERT(!m_indexesByName.contains(newName));
     482    ASSERT(m_info.infoForExistingIndex(index.info().name()));
     483
     484    m_info.infoForExistingIndex(index.info().name())->rename(newName);
     485    m_indexesByName.set(newName, m_indexesByName.take(index.info().name()));
     486    index.rename(newName);
     487}
     488
    478489} // namespace IDBServer
    479490} // namespace WebCore
  • trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h

    r207641 r207761  
    9999
    100100    void rename(const String& newName) { m_info.rename(newName); }
     101    void renameIndex(MemoryIndex&, const String& newName);
    101102
    102103private:
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp

    r207641 r207761  
    12761276}
    12771277
     1278IDBError SQLiteIDBBackingStore::renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     1279{
     1280    LOG(IndexedDB, "SQLiteIDBBackingStore::renameIndex - object store %" PRIu64 ", index %" PRIu64, objectStoreIdentifier, indexIdentifier);
     1281
     1282    ASSERT(m_sqliteDB);
     1283    ASSERT(m_sqliteDB->isOpen());
     1284
     1285    auto* objectStoreInfo = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
     1286    if (!objectStoreInfo)
     1287        return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not rename index") };
     1288
     1289    auto* indexInfo = objectStoreInfo->infoForExistingIndex(indexIdentifier);
     1290    if (!indexInfo)
     1291        return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not rename index") };
     1292
     1293    auto* transaction = m_transactions.get(transactionIdentifier);
     1294    if (!transaction || !transaction->inProgress()) {
     1295        LOG_ERROR("Attempt to rename an index without an in-progress transaction");
     1296        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an index without an in-progress transaction") };
     1297    }
     1298
     1299    if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
     1300        LOG_ERROR("Attempt to rename an index in a non-version-change transaction");
     1301        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename an index in a non-version-change transaction") };
     1302    }
     1303
     1304    {
     1305        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("UPDATE IndexInfo SET name = ? WHERE objectStoreID = ? AND id = ?;"));
     1306        if (sql.prepare() != SQLITE_OK
     1307            || sql.bindText(1, newName) != SQLITE_OK
     1308            || sql.bindInt64(2, objectStoreIdentifier) != SQLITE_OK
     1309            || sql.bindInt64(3, indexIdentifier) != SQLITE_OK
     1310            || sql.step() != SQLITE_DONE) {
     1311            LOG_ERROR("Could not update name for index id (%" PRIi64 ", %" PRIi64 ") in IndexInfo table (%i) - %s", objectStoreIdentifier, indexIdentifier, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
     1312            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not rename index") };
     1313        }
     1314    }
     1315
     1316    indexInfo->rename(newName);
     1317
     1318    return { };
     1319}
     1320
    12781321IDBError SQLiteIDBBackingStore::keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreID, const IDBKeyData& keyData, bool& keyExists)
    12791322{
  • trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h

    r207641 r207761  
    6363    IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) final;
    6464    IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier) final;
     65    IDBError renameIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
    6566    IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) final;
    6667    IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) final;
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp

    r207641 r207761  
    820820}
    821821
     822void UniqueIDBDatabase::renameIndex(UniqueIDBDatabaseTransaction& transaction, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, ErrorCallback callback)
     823{
     824    ASSERT(isMainThread());
     825    LOG(IndexedDB, "(main) UniqueIDBDatabase::renameIndex");
     826
     827    uint64_t callbackID = storeCallbackOrFireError(callback);
     828    if (!callbackID)
     829        return;
     830
     831    auto* objectStoreInfo = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
     832    if (!objectStoreInfo) {
     833        performErrorCallback(callbackID, { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename index in non-existant object store") });
     834        return;
     835    }
     836
     837    auto* indexInfo = objectStoreInfo->infoForExistingIndex(indexIdentifier);
     838    if (!indexInfo) {
     839        performErrorCallback(callbackID, { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to rename non-existant index") });
     840        return;
     841    }
     842
     843    postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performRenameIndex, callbackID, transaction.info().identifier(), objectStoreIdentifier, indexIdentifier, newName));
     844}
     845
     846void UniqueIDBDatabase::performRenameIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     847{
     848    ASSERT(!isMainThread());
     849    LOG(IndexedDB, "(db) UniqueIDBDatabase::performRenameIndex");
     850
     851    ASSERT(m_backingStore);
     852    m_backingStore->renameIndex(transactionIdentifier, objectStoreIdentifier, indexIdentifier, newName);
     853
     854    IDBError error;
     855    postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformRenameIndex, callbackIdentifier, error, objectStoreIdentifier, indexIdentifier, newName));
     856}
     857
     858void UniqueIDBDatabase::didPerformRenameIndex(uint64_t callbackIdentifier, const IDBError& error, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     859{
     860    ASSERT(isMainThread());
     861    LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformRenameIndex");
     862
     863    if (error.isNull()) {
     864        auto* objectStoreInfo = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);
     865        ASSERT(objectStoreInfo);
     866        if (objectStoreInfo) {
     867            auto* indexInfo = objectStoreInfo->infoForExistingIndex(indexIdentifier);
     868            ASSERT(indexInfo);
     869            indexInfo->rename(newName);
     870        }
     871    }
     872
     873    performErrorCallback(callbackIdentifier, error);
     874}
     875
    822876void UniqueIDBDatabase::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode, KeyDataCallback callback)
    823877{
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h

    r207641 r207761  
    9292    void createIndex(UniqueIDBDatabaseTransaction&, const IDBIndexInfo&, ErrorCallback);
    9393    void deleteIndex(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, const String& indexName, ErrorCallback);
     94    void renameIndex(UniqueIDBDatabaseTransaction&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName, ErrorCallback);
    9495    void putOrAdd(const IDBRequestData&, const IDBKeyData&, const IDBValue&, IndexedDB::ObjectStoreOverwriteMode, KeyDataCallback);
    9596    void getRecord(const IDBRequestData&, const IDBGetRecordData&, GetResultCallback);
     
    150151    void performCreateIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&);
    151152    void performDeleteIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier);
     153    void performRenameIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
    152154    void performPutOrAdd(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const IDBValue&, IndexedDB::ObjectStoreOverwriteMode);
    153155    void performGetRecord(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&);
     
    169171    void didPerformCreateIndex(uint64_t callbackIdentifier, const IDBError&, const IDBIndexInfo&);
    170172    void didPerformDeleteIndex(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier);
     173    void didPerformRenameIndex(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
    171174    void didPerformPutOrAdd(uint64_t callbackIdentifier, const IDBError&, const IDBKeyData&);
    172175    void didPerformGetRecord(uint64_t callbackIdentifier, const IDBError&, const IDBGetResult&);
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp

    r207641 r207761  
    213213}
    214214
     215void UniqueIDBDatabaseConnection::didRenameIndex(const IDBResultData& resultData)
     216{
     217    LOG(IndexedDB, "UniqueIDBDatabaseConnection::didRenameIndex");
     218
     219    m_connectionToClient.didRenameIndex(resultData);
     220}
     221
    215222} // namespace IDBServer
    216223} // namespace WebCore
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h

    r207641 r207761  
    7474    void didCreateIndex(const IDBResultData&);
    7575    void didDeleteIndex(const IDBResultData&);
     76    void didRenameIndex(const IDBResultData&);
    7677    void didFireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier);
    7778    void didFinishHandlingVersionChange(const IDBResourceIdentifier& transactionIdentifier);
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp

    r207641 r207761  
    205205}
    206206
     207void UniqueIDBDatabaseTransaction::renameIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     208{
     209    LOG(IndexedDB, "UniqueIDBDatabaseTransaction::renameIndex");
     210
     211    ASSERT(isVersionChange());
     212    ASSERT(m_transactionInfo.identifier() == requestData.transactionIdentifier());
     213
     214    RefPtr<UniqueIDBDatabaseTransaction> protectedThis(this);
     215    m_databaseConnection->database().renameIndex(*this, objectStoreIdentifier, indexIdentifier, newName, [this, protectedThis, requestData](const IDBError& error) {
     216        LOG(IndexedDB, "UniqueIDBDatabaseTransaction::renameIndex (callback)");
     217        if (error.isNull())
     218            m_databaseConnection->didRenameIndex(IDBResultData::renameIndexSuccess(requestData.requestIdentifier()));
     219        else
     220            m_databaseConnection->didRenameIndex(IDBResultData::error(requestData.requestIdentifier(), error));
     221    });
     222}
     223
     224
    207225void UniqueIDBDatabaseTransaction::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, IndexedDB::ObjectStoreOverwriteMode overwriteMode)
    208226{
  • trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h

    r207641 r207761  
    7474    void createIndex(const IDBRequestData&, const IDBIndexInfo&);
    7575    void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
     76    void renameIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
    7677    void putOrAdd(const IDBRequestData&, const IDBKeyData&, const IDBValue&, IndexedDB::ObjectStoreOverwriteMode);
    7778    void getRecord(const IDBRequestData&, const IDBGetRecordData&);
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBIndexInfo.h

    r202806 r207761  
    4747    bool unique() const { return m_unique; }
    4848    bool multiEntry() const { return m_multiEntry; }
     49
     50    void rename(const String& newName) { m_name = newName; }
    4951
    5052    template<class Encoder> void encode(Encoder&) const;
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.cpp

    r204394 r207761  
    8686}
    8787
     88IDBIndexInfo* IDBObjectStoreInfo::infoForExistingIndex(uint64_t identifier)
     89{
     90    auto iterator = m_indexMap.find(identifier);
     91    if (iterator == m_indexMap.end())
     92        return nullptr;
     93
     94    return &iterator->value;
     95}
     96
    8897IDBObjectStoreInfo IDBObjectStoreInfo::isolatedCopy() const
    8998{
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h

    r207641 r207761  
    5858    bool hasIndex(uint64_t indexIdentifier) const;
    5959    IDBIndexInfo* infoForExistingIndex(const String& name);
     60    IDBIndexInfo* infoForExistingIndex(uint64_t identifier);
    6061
    6162    Vector<String> indexNames() const;
     
    8081
    8182    HashMap<uint64_t, IDBIndexInfo> m_indexMap;
    82 
    8383};
    8484
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp

    r207641 r207761  
    160160}
    161161
     162IDBResultData IDBResultData::renameIndexSuccess(const IDBResourceIdentifier& requestIdentifier)
     163{
     164    return { IDBResultType::RenameIndexSuccess, requestIdentifier };
     165}
     166
    162167IDBResultData IDBResultData::putOrAddSuccess(const IDBResourceIdentifier& requestIdentifier, const IDBKeyData& resultKey)
    163168{
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBResultData.h

    r207641 r207761  
    5959    IterateCursorSuccess,
    6060    RenameObjectStoreSuccess,
     61    RenameIndexSuccess,
    6162};
    6263
     
    7879    static IDBResultData createIndexSuccess(const IDBResourceIdentifier&);
    7980    static IDBResultData deleteIndexSuccess(const IDBResourceIdentifier&);
     81    static IDBResultData renameIndexSuccess(const IDBResourceIdentifier&);
    8082    static IDBResultData putOrAddSuccess(const IDBResourceIdentifier&, const IDBKeyData&);
    8183    static IDBResultData getRecordSuccess(const IDBResourceIdentifier&, const IDBGetResult&);
  • trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp

    r207641 r207761  
    175175}
    176176
     177void InProcessIDBServer::didRenameIndex(const IDBResultData& resultData)
     178{
     179    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
     180        m_connectionToServer->didRenameIndex(resultData);
     181    });
     182}
     183
    177184void InProcessIDBServer::didPutOrAdd(const IDBResultData& resultData)
    178185{
     
    280287}
    281288
     289void InProcessIDBServer::renameIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     290{
     291    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, objectStoreIdentifier, indexIdentifier, newName] {
     292        m_server->renameIndex(requestData, objectStoreIdentifier, indexIdentifier, newName);
     293    });
     294}
     295
    282296void InProcessIDBServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
    283297{
  • trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h

    r207641 r207761  
    6969    void createIndex(const IDBRequestData&, const IDBIndexInfo&) final;
    7070    void deleteIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) final;
     71    void renameIndex(const IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
    7172    void putOrAdd(const IDBRequestData&, const IDBKeyData&, const IDBValue&, const IndexedDB::ObjectStoreOverwriteMode) final;
    7273    void getRecord(const IDBRequestData&, const IDBGetRecordData&) final;
     
    9596    void didCreateIndex(const IDBResultData&) final;
    9697    void didDeleteIndex(const IDBResultData&) final;
     98    void didRenameIndex(const IDBResultData&) final;
    9799    void didPutOrAdd(const IDBResultData&) final;
    98100    void didGetRecord(const IDBResultData&) final;
  • trunk/Source/WebKit2/ChangeLog

    r207735 r207761  
     12016-10-24  Brady Eidson  <beidson@apple.com>
     2
     3        IndexedDB 2.0: Support IDBIndex name assignment.
     4        <rdar://problem/28806932> and https://bugs.webkit.org/show_bug.cgi?id=163805
     5
     6        Reviewed by Alex Christensen.
     7
     8        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
     9        (WebKit::WebIDBConnectionToClient::didRenameIndex):
     10        (WebKit::WebIDBConnectionToClient::renameIndex):
     11        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
     12        * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:
     13
     14        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
     15        (WebKit::WebIDBConnectionToServer::renameIndex):
     16        (WebKit::WebIDBConnectionToServer::didRenameIndex):
     17        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
     18        * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in:
     19
    1202016-10-23  Michael Catanzaro  <mcatanzaro@igalia.com>
    221
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp

    r207641 r207761  
    128128}
    129129
     130void WebIDBConnectionToClient::didRenameIndex(const WebCore::IDBResultData& resultData)
     131{
     132    send(Messages::WebIDBConnectionToServer::DidRenameIndex(resultData));
     133}
     134
    130135void WebIDBConnectionToClient::didPutOrAdd(const WebCore::IDBResultData& resultData)
    131136{
     
    261266}
    262267
     268void WebIDBConnectionToClient::renameIndex(const IDBRequestData& request, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     269{
     270    DatabaseProcess::singleton().idbServer().renameIndex(request, objectStoreIdentifier, indexIdentifier, newName);
     271}
     272
    263273void WebIDBConnectionToClient::putOrAdd(const IDBRequestData& request, const IDBKeyData& key, const IDBValue& value, unsigned overwriteMode)
    264274{
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h

    r207641 r207761  
    6969    void didCreateIndex(const WebCore::IDBResultData&) final;
    7070    void didDeleteIndex(const WebCore::IDBResultData&) final;
     71    void didRenameIndex(const WebCore::IDBResultData&) final;
    7172    void didPutOrAdd(const WebCore::IDBResultData&) final;
    7273    void didGetRecord(const WebCore::IDBResultData&) final;
     
    9899    void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&);
    99100    void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName);
     101    void renameIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName);
    100102    void putOrAdd(const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, const WebCore::IDBValue&, unsigned overwriteMode);
    101103    void getRecord(const WebCore::IDBRequestData&, const WebCore::IDBGetRecordData&);
  • trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in

    r207641 r207761  
    3535    CreateIndex(WebCore::IDBRequestData requestData, WebCore::IDBIndexInfo info);
    3636    DeleteIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, String indexName);
     37    RenameIndex(WebCore::IDBRequestData requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, String newName);
    3738    PutOrAdd(WebCore::IDBRequestData requestData, WebCore::IDBKeyData key, WebCore::IDBValue value, unsigned overwriteMode);
    3839    GetRecord(WebCore::IDBRequestData requestData, struct WebCore::IDBGetRecordData getRecordData);
  • trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp

    r207641 r207761  
    139139}
    140140
     141void WebIDBConnectionToServer::renameIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName)
     142{
     143    send(Messages::WebIDBConnectionToClient::RenameIndex(requestData, objectStoreIdentifier, indexIdentifier, newName));
     144}
     145
    141146void WebIDBConnectionToServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, const IndexedDB::ObjectStoreOverwriteMode mode)
    142147{
     
    252257{
    253258    m_connectionToServer->didDeleteIndex(result);
     259}
     260
     261void WebIDBConnectionToServer::didRenameIndex(const IDBResultData& result)
     262{
     263    m_connectionToServer->didRenameIndex(result);
    254264}
    255265
  • trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h

    r207641 r207761  
    5858    void createIndex(const WebCore::IDBRequestData&, const WebCore::IDBIndexInfo&) final;
    5959    void deleteIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, const String& indexName) final;
     60    void renameIndex(const WebCore::IDBRequestData&, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const String& newName) final;
    6061    void putOrAdd(const WebCore::IDBRequestData&, const WebCore::IDBKeyData&, const WebCore::IDBValue&, const WebCore::IndexedDB::ObjectStoreOverwriteMode) final;
    6162    void getRecord(const WebCore::IDBRequestData&, const WebCore::IDBGetRecordData&) final;
     
    8788    void didCreateIndex(const WebCore::IDBResultData&);
    8889    void didDeleteIndex(const WebCore::IDBResultData&);
     90    void didRenameIndex(const WebCore::IDBResultData&);
    8991    void didPutOrAdd(const WebCore::IDBResultData&);
    9092    void didGetRecord(const WebIDBResult&);
  • trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in

    r207641 r207761  
    3434    DidCreateIndex(WebCore::IDBResultData result)
    3535    DidDeleteIndex(WebCore::IDBResultData result)
     36    DidRenameIndex(WebCore::IDBResultData result)
    3637    DidPutOrAdd(WebCore::IDBResultData result)
    3738    DidGetRecord(WebKit::WebIDBResult result)
Note: See TracChangeset for help on using the changeset viewer.