<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194857] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194857">194857</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-01-11 09:39:25 -0800 (Mon, 11 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryBackingStoreTransactioncpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryBackingStoreTransactionh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIndexcpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryIndexh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryObjectStorecpp">trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverMemoryObjectStoreh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-01-11  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        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:
+
</ins><span class="cx"> 2016-01-11  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix other builds after my MSVC build fix. :-|
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryBackingStoreTransactioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -86,10 +86,9 @@
</span><span class="cx">     m_indexes.add(&amp;index);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryBackingStoreTransaction::indexDeleted(std::unique_ptr&lt;MemoryIndex&gt; index)
</del><ins>+void MemoryBackingStoreTransaction::indexDeleted(Ref&lt;MemoryIndex&gt;&amp;&amp; index)
</ins><span class="cx"> {
</span><del>-    ASSERT(index);
-    m_indexes.remove(index.get());
</del><ins>+    m_indexes.remove(&amp;index.get());
</ins><span class="cx"> 
</span><span class="cx">     auto addResult = m_deletedIndexes.add(index-&gt;info().name(), nullptr);
</span><span class="cx">     if (addResult.isNewEntry)
</span><span class="lines">@@ -110,11 +109,10 @@
</span><span class="cx">     m_originalKeyGenerators.add(&amp;objectStore, objectStore.currentKeyGeneratorValue());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryBackingStoreTransaction::objectStoreDeleted(std::unique_ptr&lt;MemoryObjectStore&gt; objectStore)
</del><ins>+void MemoryBackingStoreTransaction::objectStoreDeleted(Ref&lt;MemoryObjectStore&gt;&amp;&amp; objectStore)
</ins><span class="cx"> {
</span><del>-    ASSERT(objectStore);
-    ASSERT(m_objectStores.contains(objectStore.get()));
-    m_objectStores.remove(objectStore.get());
</del><ins>+    ASSERT(m_objectStores.contains(&amp;objectStore.get()));
+    m_objectStores.remove(&amp;objectStore.get());
</ins><span class="cx"> 
</span><span class="cx">     objectStore-&gt;deleteAllIndexes(*this);
</span><span class="cx"> 
</span><span class="lines">@@ -182,17 +180,11 @@
</span><span class="cx"> 
</span><span class="cx">     TemporaryChange&lt;bool&gt; change(m_isAborting, true);
</span><span class="cx"> 
</span><del>-    // This loop moves the underlying unique_ptrs from out of the m_deletedObjectStores map,
-    // but the entries in the map still remain.
</del><span class="cx">     for (auto&amp; objectStore : m_deletedObjectStores.values()) {
</span><del>-        MemoryObjectStore* rawObjectStore = objectStore.get();
-        m_backingStore.restoreObjectStoreForVersionChangeAbort(WTFMove(objectStore));
-
-        ASSERT(!m_objectStores.contains(rawObjectStore));
-        m_objectStores.add(rawObjectStore);
</del><ins>+        m_backingStore.restoreObjectStoreForVersionChangeAbort(*objectStore);
+        ASSERT(!m_objectStores.contains(objectStore.get()));
+        m_objectStores.add(objectStore);
</ins><span class="cx">     }
</span><del>-
-    // This clears the entries from the map.
</del><span class="cx">     m_deletedObjectStores.clear();
</span><span class="cx"> 
</span><span class="cx">     if (m_originalDatabaseInfo) {
</span><span class="lines">@@ -206,17 +198,17 @@
</span><span class="cx">         iterator.key-&gt;replaceIndexValueStore(WTFMove(iterator.value));
</span><span class="cx">     m_clearedIndexValueStores.clear();
</span><span class="cx">     
</span><del>-    for (auto objectStore : m_objectStores) {
-        ASSERT(m_originalKeyGenerators.contains(objectStore));
-        objectStore-&gt;setKeyGeneratorValue(m_originalKeyGenerators.get(objectStore));
</del><ins>+    for (auto&amp; objectStore : m_objectStores) {
+        ASSERT(m_originalKeyGenerators.contains(objectStore.get()));
+        objectStore-&gt;setKeyGeneratorValue(m_originalKeyGenerators.get(objectStore.get()));
</ins><span class="cx"> 
</span><del>-        auto clearedKeyValueMap = m_clearedKeyValueMaps.take(objectStore);
</del><ins>+        auto clearedKeyValueMap = m_clearedKeyValueMaps.take(objectStore.get());
</ins><span class="cx">         if (clearedKeyValueMap) {
</span><del>-            ASSERT(m_clearedOrderedKeys.contains(objectStore));
-            objectStore-&gt;replaceKeyValueStore(WTFMove(clearedKeyValueMap), m_clearedOrderedKeys.take(objectStore));
</del><ins>+            ASSERT(m_clearedOrderedKeys.contains(objectStore.get()));
+            objectStore-&gt;replaceKeyValueStore(WTFMove(clearedKeyValueMap), m_clearedOrderedKeys.take(objectStore.get()));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        auto keyValueMap = m_originalValues.take(objectStore);
</del><ins>+        auto keyValueMap = m_originalValues.take(objectStore.get());
</ins><span class="cx">         if (!keyValueMap)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="lines">@@ -226,14 +218,8 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // This loop moves the underlying unique_ptrs from out of the m_deletedIndexes map,
-    // but the entries in the map still remain.
-    for (auto&amp; index : m_deletedIndexes.values()) {
-        MemoryObjectStore&amp; objectStore = index-&gt;objectStore();
-        objectStore.maybeRestoreDeletedIndex(WTFMove(index));
-    }
-
-    // This clears the entries from the map.
</del><ins>+    for (auto&amp; index : m_deletedIndexes.values())
+        index-&gt;objectStore().maybeRestoreDeletedIndex(*index);
</ins><span class="cx">     m_deletedIndexes.clear();
</span><span class="cx"> 
</span><span class="cx">     finish();
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryBackingStoreTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -62,13 +62,13 @@
</span><span class="cx">     void addExistingObjectStore(MemoryObjectStore&amp;);
</span><span class="cx">     
</span><span class="cx">     void recordValueChanged(MemoryObjectStore&amp;, const IDBKeyData&amp;, ThreadSafeDataBuffer*);
</span><del>-    void objectStoreDeleted(std::unique_ptr&lt;MemoryObjectStore&gt;);
</del><ins>+    void objectStoreDeleted(Ref&lt;MemoryObjectStore&gt;&amp;&amp;);
</ins><span class="cx">     void objectStoreCleared(MemoryObjectStore&amp;, std::unique_ptr&lt;KeyValueMap&gt;&amp;&amp;, std::unique_ptr&lt;std::set&lt;IDBKeyData&gt;&gt;&amp;&amp;);
</span><span class="cx">     void indexCleared(MemoryIndex&amp;, std::unique_ptr&lt;IndexValueStore&gt;&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     void addNewIndex(MemoryIndex&amp;);
</span><span class="cx">     void addExistingIndex(MemoryIndex&amp;);
</span><del>-    void indexDeleted(std::unique_ptr&lt;MemoryIndex&gt;);
</del><ins>+    void indexDeleted(Ref&lt;MemoryIndex&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void abort();
</span><span class="cx">     void commit();
</span><span class="lines">@@ -86,14 +86,14 @@
</span><span class="cx">     bool m_inProgress { true };
</span><span class="cx">     bool m_isAborting { false };
</span><span class="cx"> 
</span><del>-    HashSet&lt;MemoryObjectStore*&gt; m_objectStores;
-    HashSet&lt;MemoryObjectStore*&gt; m_versionChangeAddedObjectStores;
-    HashSet&lt;MemoryIndex*&gt; m_indexes;
-    HashSet&lt;MemoryIndex*&gt; m_versionChangeAddedIndexes;
</del><ins>+    HashSet&lt;RefPtr&lt;MemoryObjectStore&gt;&gt; m_objectStores;
+    HashSet&lt;RefPtr&lt;MemoryObjectStore&gt;&gt; m_versionChangeAddedObjectStores;
+    HashSet&lt;RefPtr&lt;MemoryIndex&gt;&gt; m_indexes;
+    HashSet&lt;RefPtr&lt;MemoryIndex&gt;&gt; m_versionChangeAddedIndexes;
</ins><span class="cx"> 
</span><span class="cx">     HashMap&lt;MemoryObjectStore*, uint64_t&gt; m_originalKeyGenerators;
</span><del>-    HashMap&lt;String, std::unique_ptr&lt;MemoryObjectStore&gt;&gt; m_deletedObjectStores;
-    HashMap&lt;String, std::unique_ptr&lt;MemoryIndex&gt;&gt; m_deletedIndexes;
</del><ins>+    HashMap&lt;String, RefPtr&lt;MemoryObjectStore&gt;&gt; m_deletedObjectStores;
+    HashMap&lt;String, RefPtr&lt;MemoryIndex&gt;&gt; m_deletedIndexes;
</ins><span class="cx">     HashMap&lt;MemoryObjectStore*, std::unique_ptr&lt;KeyValueMap&gt;&gt; m_originalValues;
</span><span class="cx">     HashMap&lt;MemoryObjectStore*, std::unique_ptr&lt;KeyValueMap&gt;&gt; m_clearedKeyValueMaps;
</span><span class="cx">     HashMap&lt;MemoryObjectStore*, std::unique_ptr&lt;std::set&lt;IDBKeyData&gt;&gt;&gt; m_clearedOrderedKeys;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx">     ASSERT(rawTransaction);
</span><span class="cx">     ASSERT(rawTransaction-&gt;isVersionChange());
</span><span class="cx"> 
</span><del>-    rawTransaction-&gt;addNewObjectStore(*objectStore);
</del><ins>+    rawTransaction-&gt;addNewObjectStore(objectStore.get());
</ins><span class="cx">     registerObjectStore(WTFMove(objectStore));
</span><span class="cx"> 
</span><span class="cx">     return IDBError();
</span><span class="lines">@@ -160,7 +160,7 @@
</span><span class="cx">         return IDBError(IDBDatabaseException::ConstraintError);
</span><span class="cx"> 
</span><span class="cx">     m_databaseInfo-&gt;deleteObjectStore(objectStoreName);
</span><del>-    transaction-&gt;objectStoreDeleted(WTFMove(objectStore));
</del><ins>+    transaction-&gt;objectStoreDeleted(*objectStore);
</ins><span class="cx"> 
</span><span class="cx">     return IDBError();
</span><span class="cx"> }
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx">     unregisterObjectStore(objectStore);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryIDBBackingStore::restoreObjectStoreForVersionChangeAbort(std::unique_ptr&lt;MemoryObjectStore&gt;&amp;&amp; objectStore)
</del><ins>+void MemoryIDBBackingStore::restoreObjectStoreForVersionChangeAbort(Ref&lt;MemoryObjectStore&gt;&amp;&amp; objectStore)
</ins><span class="cx"> {
</span><span class="cx">     registerObjectStore(WTFMove(objectStore));
</span><span class="cx"> }
</span><span class="lines">@@ -428,13 +428,12 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryIDBBackingStore::registerObjectStore(std::unique_ptr&lt;MemoryObjectStore&gt;&amp;&amp; objectStore)
</del><ins>+void MemoryIDBBackingStore::registerObjectStore(Ref&lt;MemoryObjectStore&gt;&amp;&amp; objectStore)
</ins><span class="cx"> {
</span><del>-    ASSERT(objectStore);
</del><span class="cx">     ASSERT(!m_objectStoresByIdentifier.contains(objectStore-&gt;info().identifier()));
</span><span class="cx">     ASSERT(!m_objectStoresByName.contains(objectStore-&gt;info().name()));
</span><span class="cx"> 
</span><del>-    m_objectStoresByName.set(objectStore-&gt;info().name(), objectStore.get());
</del><ins>+    m_objectStoresByName.set(objectStore-&gt;info().name(), &amp;objectStore.get());
</ins><span class="cx">     m_objectStoresByIdentifier.set(objectStore-&gt;info().identifier(), WTFMove(objectStore));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -447,13 +446,13 @@
</span><span class="cx">     m_objectStoresByIdentifier.remove(objectStore.info().identifier());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;MemoryObjectStore&gt; MemoryIDBBackingStore::takeObjectStoreByName(const String&amp; name)
</del><ins>+RefPtr&lt;MemoryObjectStore&gt; MemoryIDBBackingStore::takeObjectStoreByName(const String&amp; name)
</ins><span class="cx"> {
</span><del>-    auto rawObjectStore = m_objectStoresByName.take(name);
-    if (!rawObjectStore)
</del><ins>+    auto objectStoreByName = m_objectStoresByName.take(name);
+    if (!objectStoreByName)
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    auto objectStore = m_objectStoresByIdentifier.take(rawObjectStore-&gt;info().identifier());
</del><ins>+    auto objectStore = m_objectStoresByIdentifier.take(objectStoreByName-&gt;info().identifier());
</ins><span class="cx">     ASSERT(objectStore);
</span><span class="cx"> 
</span><span class="cx">     return objectStore;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -71,21 +71,21 @@
</span><span class="cx">     virtual void deleteBackingStore() override final;
</span><span class="cx"> 
</span><span class="cx">     void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&amp;);
</span><del>-    void restoreObjectStoreForVersionChangeAbort(std::unique_ptr&lt;MemoryObjectStore&gt;&amp;&amp;);
</del><ins>+    void restoreObjectStoreForVersionChangeAbort(Ref&lt;MemoryObjectStore&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     MemoryIDBBackingStore(const IDBDatabaseIdentifier&amp;);
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;MemoryObjectStore&gt; takeObjectStoreByName(const String&amp; name);
</del><ins>+    RefPtr&lt;MemoryObjectStore&gt; takeObjectStoreByName(const String&amp; name);
</ins><span class="cx"> 
</span><span class="cx">     IDBDatabaseIdentifier m_identifier;
</span><span class="cx">     std::unique_ptr&lt;IDBDatabaseInfo&gt; m_databaseInfo;
</span><span class="cx"> 
</span><span class="cx">     HashMap&lt;IDBResourceIdentifier, std::unique_ptr&lt;MemoryBackingStoreTransaction&gt;&gt; m_transactions;
</span><span class="cx"> 
</span><del>-    void registerObjectStore(std::unique_ptr&lt;MemoryObjectStore&gt;&amp;&amp;);
</del><ins>+    void registerObjectStore(Ref&lt;MemoryObjectStore&gt;&amp;&amp;);
</ins><span class="cx">     void unregisterObjectStore(MemoryObjectStore&amp;);
</span><del>-    HashMap&lt;uint64_t, std::unique_ptr&lt;MemoryObjectStore&gt;&gt; m_objectStoresByIdentifier;
</del><ins>+    HashMap&lt;uint64_t, RefPtr&lt;MemoryObjectStore&gt;&gt; m_objectStoresByIdentifier;
</ins><span class="cx">     HashMap&lt;String, MemoryObjectStore*&gt; m_objectStoresByName;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIndexcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.cpp (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -40,9 +40,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace IDBServer {
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;MemoryIndex&gt; MemoryIndex::create(const IDBIndexInfo&amp; info, MemoryObjectStore&amp; objectStore)
</del><ins>+Ref&lt;MemoryIndex&gt; MemoryIndex::create(const IDBIndexInfo&amp; info, MemoryObjectStore&amp; objectStore)
</ins><span class="cx"> {
</span><del>-    return std::make_unique&lt;MemoryIndex&gt;(info, objectStore);
</del><ins>+    return adoptRef(*new MemoryIndex(info, objectStore));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MemoryIndex::MemoryIndex(const IDBIndexInfo&amp; info, MemoryObjectStore&amp; objectStore)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIndexh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;MemoryIndexCursor.h&quot;
</span><span class="cx"> #include &lt;set&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/RefCounted.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -53,10 +54,9 @@
</span><span class="cx"> class MemoryBackingStoreTransaction;
</span><span class="cx"> class MemoryObjectStore;
</span><span class="cx"> 
</span><del>-class MemoryIndex {
-    friend std::unique_ptr&lt;MemoryIndex&gt; std::make_unique&lt;MemoryIndex&gt;(const WebCore::IDBIndexInfo&amp;, WebCore::IDBServer::MemoryObjectStore&amp;);
</del><ins>+class MemoryIndex : public RefCounted&lt;MemoryIndex&gt; {
</ins><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;MemoryIndex&gt; create(const IDBIndexInfo&amp;, MemoryObjectStore&amp;);
</del><ins>+    static Ref&lt;MemoryIndex&gt; create(const IDBIndexInfo&amp;, MemoryObjectStore&amp;);
</ins><span class="cx"> 
</span><span class="cx">     ~MemoryIndex();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryObjectStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -44,9 +44,9 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace IDBServer {
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;MemoryObjectStore&gt; MemoryObjectStore::create(const IDBObjectStoreInfo&amp; info)
</del><ins>+Ref&lt;MemoryObjectStore&gt; MemoryObjectStore::create(const IDBObjectStoreInfo&amp; info)
</ins><span class="cx"> {
</span><del>-    return std::make_unique&lt;MemoryObjectStore&gt;(info);
</del><ins>+    return adoptRef(*new MemoryObjectStore(info));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MemoryObjectStore::MemoryObjectStore(const IDBObjectStoreInfo&amp; info)
</span><span class="lines">@@ -92,23 +92,21 @@
</span><span class="cx">     auto index = MemoryIndex::create(info, *this);
</span><span class="cx"> 
</span><span class="cx">     // If there was an error populating the new index, then the current records in the object store violate its contraints
</span><del>-    auto error = populateIndexWithExistingRecords(*index);
</del><ins>+    auto error = populateIndexWithExistingRecords(index.get());
</ins><span class="cx">     if (!error.isNull())
</span><span class="cx">         return error;
</span><span class="cx"> 
</span><span class="cx">     m_info.addExistingIndex(info);
</span><del>-    transaction.addNewIndex(*index);
</del><ins>+    transaction.addNewIndex(index.get());
</ins><span class="cx">     registerIndex(WTFMove(index));
</span><span class="cx"> 
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryObjectStore::maybeRestoreDeletedIndex(std::unique_ptr&lt;MemoryIndex&gt; index)
</del><ins>+void MemoryObjectStore::maybeRestoreDeletedIndex(Ref&lt;MemoryIndex&gt;&amp;&amp; index)
</ins><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;MemoryObjectStore::maybeRestoreDeletedIndex&quot;);
</span><span class="cx"> 
</span><del>-    ASSERT(index);
-
</del><span class="cx">     if (m_info.hasIndex(index-&gt;info().name()))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -116,7 +114,7 @@
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!m_indexesByIdentifier.contains(index-&gt;info().identifier()));
</span><span class="cx">     index-&gt;clearIndexValueStore();
</span><del>-    auto error = populateIndexWithExistingRecords(*index);
</del><ins>+    auto error = populateIndexWithExistingRecords(index.get());
</ins><span class="cx"> 
</span><span class="cx">     // Since this index was installed in the object store before this transaction started,
</span><span class="cx">     // assuming things were in a valid state then, we should definitely be able to successfully
</span><span class="lines">@@ -126,13 +124,13 @@
</span><span class="cx">     registerIndex(WTFMove(index));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;MemoryIndex&gt; MemoryObjectStore::takeIndexByName(const String&amp; name)
</del><ins>+RefPtr&lt;MemoryIndex&gt; MemoryObjectStore::takeIndexByName(const String&amp; name)
</ins><span class="cx"> {
</span><del>-    auto rawIndex = m_indexesByName.take(name);
-    if (!rawIndex)
</del><ins>+    auto indexByName = m_indexesByName.take(name);
+    if (!indexByName)
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    auto index = m_indexesByIdentifier.take(rawIndex-&gt;info().identifier());
</del><ins>+    auto index = m_indexesByIdentifier.take(indexByName-&gt;info().identifier());
</ins><span class="cx">     ASSERT(index);
</span><span class="cx"> 
</span><span class="cx">     return index;
</span><span class="lines">@@ -151,7 +149,7 @@
</span><span class="cx">         return IDBError(IDBDatabaseException::ConstraintError);
</span><span class="cx"> 
</span><span class="cx">     m_info.deleteIndex(indexName);
</span><del>-    transaction.indexDeleted(WTFMove(index));
</del><ins>+    transaction.indexDeleted(*index);
</ins><span class="cx"> 
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="lines">@@ -294,7 +292,7 @@
</span><span class="cx"> 
</span><span class="cx"> void MemoryObjectStore::updateIndexesForDeleteRecord(const IDBKeyData&amp; value)
</span><span class="cx"> {
</span><del>-    for (auto* index : m_indexesByName.values())
</del><ins>+    for (auto&amp; index : m_indexesByName.values())
</ins><span class="cx">         index-&gt;removeEntriesWithValueKey(value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -309,7 +307,7 @@
</span><span class="cx">     IDBError error;
</span><span class="cx">     Vector&lt;std::pair&lt;MemoryIndex*, IndexKey&gt;&gt; changedIndexRecords;
</span><span class="cx"> 
</span><del>-    for (auto* index : m_indexesByName.values()) {
</del><ins>+    for (auto&amp; index : m_indexesByName.values()) {
</ins><span class="cx">         IndexKey indexKey;
</span><span class="cx">         generateIndexKeyForValue(UniqueIDBDatabase::databaseThreadExecState(), index-&gt;info(), jsValue, indexKey);
</span><span class="cx"> 
</span><span class="lines">@@ -320,7 +318,7 @@
</span><span class="cx">         if (!error.isNull())
</span><span class="cx">             break;
</span><span class="cx"> 
</span><del>-        changedIndexRecords.append(std::make_pair(index, indexKey));
</del><ins>+        changedIndexRecords.append(std::make_pair(index.get(), indexKey));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If any of the index puts failed, revert all of the ones that went through.
</span><span class="lines">@@ -446,13 +444,12 @@
</span><span class="cx">     return *lowestInRange;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MemoryObjectStore::registerIndex(std::unique_ptr&lt;MemoryIndex&gt;&amp;&amp; index)
</del><ins>+void MemoryObjectStore::registerIndex(Ref&lt;MemoryIndex&gt;&amp;&amp; index)
</ins><span class="cx"> {
</span><del>-    ASSERT(index);
</del><span class="cx">     ASSERT(!m_indexesByIdentifier.contains(index-&gt;info().identifier()));
</span><span class="cx">     ASSERT(!m_indexesByName.contains(index-&gt;info().name()));
</span><span class="cx"> 
</span><del>-    m_indexesByName.set(index-&gt;info().name(), index.get());
</del><ins>+    m_indexesByName.set(index-&gt;info().name(), &amp;index.get());
</ins><span class="cx">     m_indexesByIdentifier.set(index-&gt;info().identifier(), WTFMove(index));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryObjectStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (194856 => 194857)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;ThreadSafeDataBuffer.h&quot;
</span><span class="cx"> #include &lt;set&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><ins>+#include &lt;wtf/RefCounted.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -54,10 +55,9 @@
</span><span class="cx"> 
</span><span class="cx"> typedef HashMap&lt;IDBKeyData, ThreadSafeDataBuffer, IDBKeyDataHash, IDBKeyDataHashTraits&gt; KeyValueMap;
</span><span class="cx"> 
</span><del>-class MemoryObjectStore {
-    friend std::unique_ptr&lt;MemoryObjectStore&gt; std::make_unique&lt;MemoryObjectStore&gt;(const WebCore::IDBObjectStoreInfo&amp;);
</del><ins>+class MemoryObjectStore : public RefCounted&lt;MemoryObjectStore&gt; {
</ins><span class="cx"> public:
</span><del>-    static std::unique_ptr&lt;MemoryObjectStore&gt; create(const IDBObjectStoreInfo&amp;);
</del><ins>+    static Ref&lt;MemoryObjectStore&gt; create(const IDBObjectStoreInfo&amp;);
</ins><span class="cx"> 
</span><span class="cx">     ~MemoryObjectStore();
</span><span class="cx"> 
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">     IDBError createIndex(MemoryBackingStoreTransaction&amp;, const IDBIndexInfo&amp;);
</span><span class="cx">     IDBError deleteIndex(MemoryBackingStoreTransaction&amp;, const String&amp; indexName);
</span><span class="cx">     void deleteAllIndexes(MemoryBackingStoreTransaction&amp;);
</span><del>-    void registerIndex(std::unique_ptr&lt;MemoryIndex&gt;&amp;&amp;);
</del><ins>+    void registerIndex(Ref&lt;MemoryIndex&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     bool containsRecord(const IDBKeyData&amp;);
</span><span class="cx">     void deleteRecord(const IDBKeyData&amp;);
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx"> 
</span><span class="cx">     MemoryIndex* indexForIdentifier(uint64_t);
</span><span class="cx"> 
</span><del>-    void maybeRestoreDeletedIndex(std::unique_ptr&lt;MemoryIndex&gt;);
</del><ins>+    void maybeRestoreDeletedIndex(Ref&lt;MemoryIndex&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     MemoryObjectStore(const IDBObjectStoreInfo&amp;);
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">     void updateCursorsForPutRecord(std::set&lt;IDBKeyData&gt;::iterator);
</span><span class="cx">     void updateCursorsForDeleteRecord(const IDBKeyData&amp;);
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;MemoryIndex&gt; takeIndexByName(const String&amp; name);
</del><ins>+    RefPtr&lt;MemoryIndex&gt; takeIndexByName(const String&amp; name);
</ins><span class="cx"> 
</span><span class="cx">     IDBObjectStoreInfo m_info;
</span><span class="cx"> 
</span><span class="lines">@@ -119,8 +119,8 @@
</span><span class="cx">     std::unique_ptr&lt;std::set&lt;IDBKeyData&gt;&gt; m_orderedKeys;
</span><span class="cx"> 
</span><span class="cx">     void unregisterIndex(MemoryIndex&amp;);
</span><del>-    HashMap&lt;uint64_t, std::unique_ptr&lt;MemoryIndex&gt;&gt; m_indexesByIdentifier;
-    HashMap&lt;String, MemoryIndex*&gt; m_indexesByName;
</del><ins>+    HashMap&lt;uint64_t, RefPtr&lt;MemoryIndex&gt;&gt; m_indexesByIdentifier;
+    HashMap&lt;String, RefPtr&lt;MemoryIndex&gt;&gt; m_indexesByName;
</ins><span class="cx">     HashMap&lt;IDBResourceIdentifier, std::unique_ptr&lt;MemoryObjectStoreCursor&gt;&gt; m_cursors;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>