Title: [194857] trunk/Source/WebCore
Revision
194857
Author
beid...@apple.com
Date
2016-01-11 09:39:25 -0800 (Mon, 11 Jan 2016)

Log Message

Modern IDB: Make MemoryIndex and MemoryObjectStore RefCounted.
https://bugs.webkit.org/show_bug.cgi?id=152966

Reviewed by Alex Christensen.

No new tests (Refactor, no change in behavior)

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

* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::createObjectStore):
(WebCore::IDBServer::MemoryIDBBackingStore::deleteObjectStore):
(WebCore::IDBServer::MemoryIDBBackingStore::restoreObjectStoreForVersionChangeAbort):
(WebCore::IDBServer::MemoryIDBBackingStore::registerObjectStore):
(WebCore::IDBServer::MemoryIDBBackingStore::takeObjectStoreByName):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:

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

* Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::create):
(WebCore::IDBServer::MemoryObjectStore::createIndex):
(WebCore::IDBServer::MemoryObjectStore::maybeRestoreDeletedIndex):
(WebCore::IDBServer::MemoryObjectStore::takeIndexByName):
(WebCore::IDBServer::MemoryObjectStore::deleteIndex):
(WebCore::IDBServer::MemoryObjectStore::updateIndexesForDeleteRecord):
(WebCore::IDBServer::MemoryObjectStore::updateIndexesForPutRecord):
(WebCore::IDBServer::MemoryObjectStore::registerIndex):
* Modules/indexeddb/server/MemoryObjectStore.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (194856 => 194857)


--- trunk/Source/WebCore/ChangeLog	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/ChangeLog	2016-01-11 17:39:25 UTC (rev 194857)
@@ -1,3 +1,41 @@
+2016-01-11  Brady Eidson  <beid...@apple.com>
+
+        Modern IDB: Make MemoryIndex and MemoryObjectStore RefCounted.
+        https://bugs.webkit.org/show_bug.cgi?id=152966
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Refactor, no change in behavior)
+
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::indexDeleted):
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreDeleted):
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
+        
+        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+        (WebCore::IDBServer::MemoryIDBBackingStore::createObjectStore):
+        (WebCore::IDBServer::MemoryIDBBackingStore::deleteObjectStore):
+        (WebCore::IDBServer::MemoryIDBBackingStore::restoreObjectStoreForVersionChangeAbort):
+        (WebCore::IDBServer::MemoryIDBBackingStore::registerObjectStore):
+        (WebCore::IDBServer::MemoryIDBBackingStore::takeObjectStoreByName):
+        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+        
+        * Modules/indexeddb/server/MemoryIndex.cpp:
+        (WebCore::IDBServer::MemoryIndex::create):
+        * Modules/indexeddb/server/MemoryIndex.h:
+        
+        * Modules/indexeddb/server/MemoryObjectStore.cpp:
+        (WebCore::IDBServer::MemoryObjectStore::create):
+        (WebCore::IDBServer::MemoryObjectStore::createIndex):
+        (WebCore::IDBServer::MemoryObjectStore::maybeRestoreDeletedIndex):
+        (WebCore::IDBServer::MemoryObjectStore::takeIndexByName):
+        (WebCore::IDBServer::MemoryObjectStore::deleteIndex):
+        (WebCore::IDBServer::MemoryObjectStore::updateIndexesForDeleteRecord):
+        (WebCore::IDBServer::MemoryObjectStore::updateIndexesForPutRecord):
+        (WebCore::IDBServer::MemoryObjectStore::registerIndex):
+        * Modules/indexeddb/server/MemoryObjectStore.h:
+
 2016-01-11  Andreas Kling  <akl...@apple.com>
 
         Fix other builds after my MSVC build fix. :-|

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


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp	2016-01-11 17:39:25 UTC (rev 194857)
@@ -86,10 +86,9 @@
     m_indexes.add(&index);
 }
 
-void MemoryBackingStoreTransaction::indexDeleted(std::unique_ptr<MemoryIndex> index)
+void MemoryBackingStoreTransaction::indexDeleted(Ref<MemoryIndex>&& index)
 {
-    ASSERT(index);
-    m_indexes.remove(index.get());
+    m_indexes.remove(&index.get());
 
     auto addResult = m_deletedIndexes.add(index->info().name(), nullptr);
     if (addResult.isNewEntry)
@@ -110,11 +109,10 @@
     m_originalKeyGenerators.add(&objectStore, objectStore.currentKeyGeneratorValue());
 }
 
-void MemoryBackingStoreTransaction::objectStoreDeleted(std::unique_ptr<MemoryObjectStore> objectStore)
+void MemoryBackingStoreTransaction::objectStoreDeleted(Ref<MemoryObjectStore>&& objectStore)
 {
-    ASSERT(objectStore);
-    ASSERT(m_objectStores.contains(objectStore.get()));
-    m_objectStores.remove(objectStore.get());
+    ASSERT(m_objectStores.contains(&objectStore.get()));
+    m_objectStores.remove(&objectStore.get());
 
     objectStore->deleteAllIndexes(*this);
 
@@ -182,17 +180,11 @@
 
     TemporaryChange<bool> change(m_isAborting, true);
 
-    // This loop moves the underlying unique_ptrs from out of the m_deletedObjectStores map,
-    // but the entries in the map still remain.
     for (auto& objectStore : m_deletedObjectStores.values()) {
-        MemoryObjectStore* rawObjectStore = objectStore.get();
-        m_backingStore.restoreObjectStoreForVersionChangeAbort(WTFMove(objectStore));
-
-        ASSERT(!m_objectStores.contains(rawObjectStore));
-        m_objectStores.add(rawObjectStore);
+        m_backingStore.restoreObjectStoreForVersionChangeAbort(*objectStore);
+        ASSERT(!m_objectStores.contains(objectStore.get()));
+        m_objectStores.add(objectStore);
     }
-
-    // This clears the entries from the map.
     m_deletedObjectStores.clear();
 
     if (m_originalDatabaseInfo) {
@@ -206,17 +198,17 @@
         iterator.key->replaceIndexValueStore(WTFMove(iterator.value));
     m_clearedIndexValueStores.clear();
     
-    for (auto objectStore : m_objectStores) {
-        ASSERT(m_originalKeyGenerators.contains(objectStore));
-        objectStore->setKeyGeneratorValue(m_originalKeyGenerators.get(objectStore));
+    for (auto& objectStore : m_objectStores) {
+        ASSERT(m_originalKeyGenerators.contains(objectStore.get()));
+        objectStore->setKeyGeneratorValue(m_originalKeyGenerators.get(objectStore.get()));
 
-        auto clearedKeyValueMap = m_clearedKeyValueMaps.take(objectStore);
+        auto clearedKeyValueMap = m_clearedKeyValueMaps.take(objectStore.get());
         if (clearedKeyValueMap) {
-            ASSERT(m_clearedOrderedKeys.contains(objectStore));
-            objectStore->replaceKeyValueStore(WTFMove(clearedKeyValueMap), m_clearedOrderedKeys.take(objectStore));
+            ASSERT(m_clearedOrderedKeys.contains(objectStore.get()));
+            objectStore->replaceKeyValueStore(WTFMove(clearedKeyValueMap), m_clearedOrderedKeys.take(objectStore.get()));
         }
 
-        auto keyValueMap = m_originalValues.take(objectStore);
+        auto keyValueMap = m_originalValues.take(objectStore.get());
         if (!keyValueMap)
             continue;
 
@@ -226,14 +218,8 @@
         }
     }
 
-    // This loop moves the underlying unique_ptrs from out of the m_deletedIndexes map,
-    // but the entries in the map still remain.
-    for (auto& index : m_deletedIndexes.values()) {
-        MemoryObjectStore& objectStore = index->objectStore();
-        objectStore.maybeRestoreDeletedIndex(WTFMove(index));
-    }
-
-    // This clears the entries from the map.
+    for (auto& index : m_deletedIndexes.values())
+        index->objectStore().maybeRestoreDeletedIndex(*index);
     m_deletedIndexes.clear();
 
     finish();

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


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h	2016-01-11 17:39:25 UTC (rev 194857)
@@ -62,13 +62,13 @@
     void addExistingObjectStore(MemoryObjectStore&);
     
     void recordValueChanged(MemoryObjectStore&, const IDBKeyData&, ThreadSafeDataBuffer*);
-    void objectStoreDeleted(std::unique_ptr<MemoryObjectStore>);
+    void objectStoreDeleted(Ref<MemoryObjectStore>&&);
     void objectStoreCleared(MemoryObjectStore&, std::unique_ptr<KeyValueMap>&&, std::unique_ptr<std::set<IDBKeyData>>&&);
     void indexCleared(MemoryIndex&, std::unique_ptr<IndexValueStore>&&);
 
     void addNewIndex(MemoryIndex&);
     void addExistingIndex(MemoryIndex&);
-    void indexDeleted(std::unique_ptr<MemoryIndex>);
+    void indexDeleted(Ref<MemoryIndex>&&);
 
     void abort();
     void commit();
@@ -86,14 +86,14 @@
     bool m_inProgress { true };
     bool m_isAborting { false };
 
-    HashSet<MemoryObjectStore*> m_objectStores;
-    HashSet<MemoryObjectStore*> m_versionChangeAddedObjectStores;
-    HashSet<MemoryIndex*> m_indexes;
-    HashSet<MemoryIndex*> m_versionChangeAddedIndexes;
+    HashSet<RefPtr<MemoryObjectStore>> m_objectStores;
+    HashSet<RefPtr<MemoryObjectStore>> m_versionChangeAddedObjectStores;
+    HashSet<RefPtr<MemoryIndex>> m_indexes;
+    HashSet<RefPtr<MemoryIndex>> m_versionChangeAddedIndexes;
 
     HashMap<MemoryObjectStore*, uint64_t> m_originalKeyGenerators;
-    HashMap<String, std::unique_ptr<MemoryObjectStore>> m_deletedObjectStores;
-    HashMap<String, std::unique_ptr<MemoryIndex>> m_deletedIndexes;
+    HashMap<String, RefPtr<MemoryObjectStore>> m_deletedObjectStores;
+    HashMap<String, RefPtr<MemoryIndex>> m_deletedIndexes;
     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;

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


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp	2016-01-11 17:39:25 UTC (rev 194857)
@@ -136,7 +136,7 @@
     ASSERT(rawTransaction);
     ASSERT(rawTransaction->isVersionChange());
 
-    rawTransaction->addNewObjectStore(*objectStore);
+    rawTransaction->addNewObjectStore(objectStore.get());
     registerObjectStore(WTFMove(objectStore));
 
     return IDBError();
@@ -160,7 +160,7 @@
         return IDBError(IDBDatabaseException::ConstraintError);
 
     m_databaseInfo->deleteObjectStore(objectStoreName);
-    transaction->objectStoreDeleted(WTFMove(objectStore));
+    transaction->objectStoreDeleted(*objectStore);
 
     return IDBError();
 }
@@ -226,7 +226,7 @@
     unregisterObjectStore(objectStore);
 }
 
-void MemoryIDBBackingStore::restoreObjectStoreForVersionChangeAbort(std::unique_ptr<MemoryObjectStore>&& objectStore)
+void MemoryIDBBackingStore::restoreObjectStoreForVersionChangeAbort(Ref<MemoryObjectStore>&& objectStore)
 {
     registerObjectStore(WTFMove(objectStore));
 }
@@ -428,13 +428,12 @@
     return { };
 }
 
-void MemoryIDBBackingStore::registerObjectStore(std::unique_ptr<MemoryObjectStore>&& objectStore)
+void MemoryIDBBackingStore::registerObjectStore(Ref<MemoryObjectStore>&& objectStore)
 {
-    ASSERT(objectStore);
     ASSERT(!m_objectStoresByIdentifier.contains(objectStore->info().identifier()));
     ASSERT(!m_objectStoresByName.contains(objectStore->info().name()));
 
-    m_objectStoresByName.set(objectStore->info().name(), objectStore.get());
+    m_objectStoresByName.set(objectStore->info().name(), &objectStore.get());
     m_objectStoresByIdentifier.set(objectStore->info().identifier(), WTFMove(objectStore));
 }
 
@@ -447,13 +446,13 @@
     m_objectStoresByIdentifier.remove(objectStore.info().identifier());
 }
 
-std::unique_ptr<MemoryObjectStore> MemoryIDBBackingStore::takeObjectStoreByName(const String& name)
+RefPtr<MemoryObjectStore> MemoryIDBBackingStore::takeObjectStoreByName(const String& name)
 {
-    auto rawObjectStore = m_objectStoresByName.take(name);
-    if (!rawObjectStore)
+    auto objectStoreByName = m_objectStoresByName.take(name);
+    if (!objectStoreByName)
         return nullptr;
 
-    auto objectStore = m_objectStoresByIdentifier.take(rawObjectStore->info().identifier());
+    auto objectStore = m_objectStoresByIdentifier.take(objectStoreByName->info().identifier());
     ASSERT(objectStore);
 
     return objectStore;

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


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h	2016-01-11 17:39:25 UTC (rev 194857)
@@ -71,21 +71,21 @@
     virtual void deleteBackingStore() override final;
 
     void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&);
-    void restoreObjectStoreForVersionChangeAbort(std::unique_ptr<MemoryObjectStore>&&);
+    void restoreObjectStoreForVersionChangeAbort(Ref<MemoryObjectStore>&&);
 
 private:
     MemoryIDBBackingStore(const IDBDatabaseIdentifier&);
 
-    std::unique_ptr<MemoryObjectStore> takeObjectStoreByName(const String& name);
+    RefPtr<MemoryObjectStore> takeObjectStoreByName(const String& name);
 
     IDBDatabaseIdentifier m_identifier;
     std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
 
     HashMap<IDBResourceIdentifier, std::unique_ptr<MemoryBackingStoreTransaction>> m_transactions;
 
-    void registerObjectStore(std::unique_ptr<MemoryObjectStore>&&);
+    void registerObjectStore(Ref<MemoryObjectStore>&&);
     void unregisterObjectStore(MemoryObjectStore&);
-    HashMap<uint64_t, std::unique_ptr<MemoryObjectStore>> m_objectStoresByIdentifier;
+    HashMap<uint64_t, RefPtr<MemoryObjectStore>> m_objectStoresByIdentifier;
     HashMap<String, MemoryObjectStore*> m_objectStoresByName;
 };
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp (194856 => 194857)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp	2016-01-11 17:39:25 UTC (rev 194857)
@@ -40,9 +40,9 @@
 namespace WebCore {
 namespace IDBServer {
 
-std::unique_ptr<MemoryIndex> MemoryIndex::create(const IDBIndexInfo& info, MemoryObjectStore& objectStore)
+Ref<MemoryIndex> MemoryIndex::create(const IDBIndexInfo& info, MemoryObjectStore& objectStore)
 {
-    return std::make_unique<MemoryIndex>(info, objectStore);
+    return adoptRef(*new MemoryIndex(info, objectStore));
 }
 
 MemoryIndex::MemoryIndex(const IDBIndexInfo& info, MemoryObjectStore& objectStore)

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h (194856 => 194857)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h	2016-01-11 17:39:25 UTC (rev 194857)
@@ -35,6 +35,7 @@
 #include "MemoryIndexCursor.h"
 #include <set>
 #include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
@@ -53,10 +54,9 @@
 class MemoryBackingStoreTransaction;
 class MemoryObjectStore;
 
-class MemoryIndex {
-    friend std::unique_ptr<MemoryIndex> std::make_unique<MemoryIndex>(const WebCore::IDBIndexInfo&, WebCore::IDBServer::MemoryObjectStore&);
+class MemoryIndex : public RefCounted<MemoryIndex> {
 public:
-    static std::unique_ptr<MemoryIndex> create(const IDBIndexInfo&, MemoryObjectStore&);
+    static Ref<MemoryIndex> create(const IDBIndexInfo&, MemoryObjectStore&);
 
     ~MemoryIndex();
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (194856 => 194857)


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp	2016-01-11 17:39:25 UTC (rev 194857)
@@ -44,9 +44,9 @@
 namespace WebCore {
 namespace IDBServer {
 
-std::unique_ptr<MemoryObjectStore> MemoryObjectStore::create(const IDBObjectStoreInfo& info)
+Ref<MemoryObjectStore> MemoryObjectStore::create(const IDBObjectStoreInfo& info)
 {
-    return std::make_unique<MemoryObjectStore>(info);
+    return adoptRef(*new MemoryObjectStore(info));
 }
 
 MemoryObjectStore::MemoryObjectStore(const IDBObjectStoreInfo& info)
@@ -92,23 +92,21 @@
     auto index = MemoryIndex::create(info, *this);
 
     // If there was an error populating the new index, then the current records in the object store violate its contraints
-    auto error = populateIndexWithExistingRecords(*index);
+    auto error = populateIndexWithExistingRecords(index.get());
     if (!error.isNull())
         return error;
 
     m_info.addExistingIndex(info);
-    transaction.addNewIndex(*index);
+    transaction.addNewIndex(index.get());
     registerIndex(WTFMove(index));
 
     return { };
 }
 
-void MemoryObjectStore::maybeRestoreDeletedIndex(std::unique_ptr<MemoryIndex> index)
+void MemoryObjectStore::maybeRestoreDeletedIndex(Ref<MemoryIndex>&& index)
 {
     LOG(IndexedDB, "MemoryObjectStore::maybeRestoreDeletedIndex");
 
-    ASSERT(index);
-
     if (m_info.hasIndex(index->info().name()))
         return;
 
@@ -116,7 +114,7 @@
 
     ASSERT(!m_indexesByIdentifier.contains(index->info().identifier()));
     index->clearIndexValueStore();
-    auto error = populateIndexWithExistingRecords(*index);
+    auto error = populateIndexWithExistingRecords(index.get());
 
     // Since this index was installed in the object store before this transaction started,
     // assuming things were in a valid state then, we should definitely be able to successfully
@@ -126,13 +124,13 @@
     registerIndex(WTFMove(index));
 }
 
-std::unique_ptr<MemoryIndex> MemoryObjectStore::takeIndexByName(const String& name)
+RefPtr<MemoryIndex> MemoryObjectStore::takeIndexByName(const String& name)
 {
-    auto rawIndex = m_indexesByName.take(name);
-    if (!rawIndex)
+    auto indexByName = m_indexesByName.take(name);
+    if (!indexByName)
         return nullptr;
 
-    auto index = m_indexesByIdentifier.take(rawIndex->info().identifier());
+    auto index = m_indexesByIdentifier.take(indexByName->info().identifier());
     ASSERT(index);
 
     return index;
@@ -151,7 +149,7 @@
         return IDBError(IDBDatabaseException::ConstraintError);
 
     m_info.deleteIndex(indexName);
-    transaction.indexDeleted(WTFMove(index));
+    transaction.indexDeleted(*index);
 
     return { };
 }
@@ -294,7 +292,7 @@
 
 void MemoryObjectStore::updateIndexesForDeleteRecord(const IDBKeyData& value)
 {
-    for (auto* index : m_indexesByName.values())
+    for (auto& index : m_indexesByName.values())
         index->removeEntriesWithValueKey(value);
 }
 
@@ -309,7 +307,7 @@
     IDBError error;
     Vector<std::pair<MemoryIndex*, IndexKey>> changedIndexRecords;
 
-    for (auto* index : m_indexesByName.values()) {
+    for (auto& index : m_indexesByName.values()) {
         IndexKey indexKey;
         generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index->info(), jsValue, indexKey);
 
@@ -320,7 +318,7 @@
         if (!error.isNull())
             break;
 
-        changedIndexRecords.append(std::make_pair(index, indexKey));
+        changedIndexRecords.append(std::make_pair(index.get(), indexKey));
     }
 
     // If any of the index puts failed, revert all of the ones that went through.
@@ -446,13 +444,12 @@
     return *lowestInRange;
 }
 
-void MemoryObjectStore::registerIndex(std::unique_ptr<MemoryIndex>&& index)
+void MemoryObjectStore::registerIndex(Ref<MemoryIndex>&& index)
 {
-    ASSERT(index);
     ASSERT(!m_indexesByIdentifier.contains(index->info().identifier()));
     ASSERT(!m_indexesByName.contains(index->info().name()));
 
-    m_indexesByName.set(index->info().name(), index.get());
+    m_indexesByName.set(index->info().name(), &index.get());
     m_indexesByIdentifier.set(index->info().identifier(), WTFMove(index));
 }
 

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


--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h	2016-01-11 17:25:03 UTC (rev 194856)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h	2016-01-11 17:39:25 UTC (rev 194857)
@@ -35,6 +35,7 @@
 #include "ThreadSafeDataBuffer.h"
 #include <set>
 #include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
@@ -54,10 +55,9 @@
 
 typedef HashMap<IDBKeyData, ThreadSafeDataBuffer, IDBKeyDataHash, IDBKeyDataHashTraits> KeyValueMap;
 
-class MemoryObjectStore {
-    friend std::unique_ptr<MemoryObjectStore> std::make_unique<MemoryObjectStore>(const WebCore::IDBObjectStoreInfo&);
+class MemoryObjectStore : public RefCounted<MemoryObjectStore> {
 public:
-    static std::unique_ptr<MemoryObjectStore> create(const IDBObjectStoreInfo&);
+    static Ref<MemoryObjectStore> create(const IDBObjectStoreInfo&);
 
     ~MemoryObjectStore();
 
@@ -68,7 +68,7 @@
     IDBError createIndex(MemoryBackingStoreTransaction&, const IDBIndexInfo&);
     IDBError deleteIndex(MemoryBackingStoreTransaction&, const String& indexName);
     void deleteAllIndexes(MemoryBackingStoreTransaction&);
-    void registerIndex(std::unique_ptr<MemoryIndex>&&);
+    void registerIndex(Ref<MemoryIndex>&&);
 
     bool containsRecord(const IDBKeyData&);
     void deleteRecord(const IDBKeyData&);
@@ -94,7 +94,7 @@
 
     MemoryIndex* indexForIdentifier(uint64_t);
 
-    void maybeRestoreDeletedIndex(std::unique_ptr<MemoryIndex>);
+    void maybeRestoreDeletedIndex(Ref<MemoryIndex>&&);
 
 private:
     MemoryObjectStore(const IDBObjectStoreInfo&);
@@ -108,7 +108,7 @@
     void updateCursorsForPutRecord(std::set<IDBKeyData>::iterator);
     void updateCursorsForDeleteRecord(const IDBKeyData&);
 
-    std::unique_ptr<MemoryIndex> takeIndexByName(const String& name);
+    RefPtr<MemoryIndex> takeIndexByName(const String& name);
 
     IDBObjectStoreInfo m_info;
 
@@ -119,8 +119,8 @@
     std::unique_ptr<std::set<IDBKeyData>> m_orderedKeys;
 
     void unregisterIndex(MemoryIndex&);
-    HashMap<uint64_t, std::unique_ptr<MemoryIndex>> m_indexesByIdentifier;
-    HashMap<String, MemoryIndex*> m_indexesByName;
+    HashMap<uint64_t, RefPtr<MemoryIndex>> m_indexesByIdentifier;
+    HashMap<String, RefPtr<MemoryIndex>> m_indexesByName;
     HashMap<IDBResourceIdentifier, std::unique_ptr<MemoryObjectStoreCursor>> m_cursors;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to