<!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>[191776] trunk</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/191776">191776</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-10-29 21:55:12 -0700 (Thu, 29 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modern IDB: autoIncrement support.
https://bugs.webkit.org/show_bug.cgi?id=150695

Reviewed by Alex Christensen.

Source/WebCore:

Test: storage/indexeddb/modern/autoincrement-abort.html

* Modules/indexeddb/server/IDBBackingStore.h:
* Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
(WebCore::IDBServer::MemoryBackingStoreTransaction::addNewObjectStore):
(WebCore::IDBServer::MemoryBackingStoreTransaction::addExistingObjectStore):
(WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
* Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::putRecord):
(WebCore::IDBServer::MemoryIDBBackingStore::generateKeyNumber):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:
* Modules/indexeddb/server/MemoryObjectStore.h:
(WebCore::IDBServer::MemoryObjectStore::currentKeyGeneratorValue):
(WebCore::IDBServer::MemoryObjectStore::setKeyGeneratorValue):
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):

LayoutTests:

* storage/indexeddb/modern/autoincrement-abort-expected.txt: Added.
* storage/indexeddb/modern/autoincrement-abort.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBBackingStoreh">trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h</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="#trunkSourceWebCoreModulesindexeddbserverMemoryObjectStoreh">trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernautoincrementabortexpectedtxt">trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstorageindexeddbmodernautoincrementaborthtml">trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/LayoutTests/ChangeLog        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-10-29  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: autoIncrement support.
+        https://bugs.webkit.org/show_bug.cgi?id=150695
+
+        Reviewed by Alex Christensen.
+
+        * storage/indexeddb/modern/autoincrement-abort-expected.txt: Added.
+        * storage/indexeddb/modern/autoincrement-abort.html: Added.
+
</ins><span class="cx"> 2015-10-29  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Crash making a tail call from a getter to a host function
</span></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernautoincrementabortexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort-expected.txt (0 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort-expected.txt                                (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort-expected.txt        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+ALERT: Initial upgrade needed: Old version - 0 New version - 1
+ALERT: Initial upgrade versionchange transaction complete
+ALERT: Opening readwrite transaction to bump the key generator, but it will be aborted
+ALERT: Key used for put was 1
+ALERT: Key used for put was 2
+ALERT: Key used for put was 3
+ALERT: Key used for put was 4
+ALERT: Key used for put was 5
+ALERT: Key used for put was 6
+ALERT: readwrite transaction abort
+ALERT: Opening readwrite transaction to make sure the key generator had successfully reverted
+ALERT: Key used for put was 1
+ALERT: Key used for put was 2
+ALERT: Key used for put was 3
+ALERT: Key used for put was 4
+ALERT: Key used for put was 5
+ALERT: Key used for put was 6
+ALERT: readwrite transaction complete
+ALERT: Opening readwrite transaction to make sure the key generator picks up where it should've left off
+ALERT: Key used for put was 7
+ALERT: Key used for put was 8
+ALERT: Key used for put was 9
+ALERT: Key used for put was 10
+ALERT: Key used for put was 11
+ALERT: Key used for put was 12
+ALERT: readwrite transaction complete
+ALERT: Done
+This test creates a new database with an objectstore that autoincrements.
+It then puts some things in that object store, checking the keys that were used.
+But it then aborts that transaction.
+Then it opens a new one and puts something in it, double checking that the key generator was reverted when the above transaction was aborted.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageindexeddbmodernautoincrementaborthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort.html (0 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort.html                                (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/autoincrement-abort.html        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -0,0 +1,159 @@
</span><ins>+This test creates a new database with an objectstore that autoincrements.&lt;br&gt;
+It then puts some things in that object store, checking the keys that were used.&lt;br&gt;
+But it then aborts that transaction.&lt;br&gt;
+Then it opens a new one and puts something in it, double checking that the key generator was reverted when the above transaction was aborted.&lt;br&gt;
+&lt;script&gt;
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+
+function done()
+{
+    alert(&quot;Done&quot;);
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+var createRequest = window.indexedDB.open(&quot;AutoincrementAbortDatabase&quot;, 1);
+var database;
+
+createRequest.onupgradeneeded = function(event) {
+    alert(&quot;Initial upgrade needed: Old version - &quot; + event.oldVersion + &quot; New version - &quot; + event.newVersion);
+
+    var versionTransaction = createRequest.transaction;
+    database = event.target.result;
+    var objectStore = database.createObjectStore('TestObjectStore', { autoIncrement: true });
+    
+    versionTransaction.onabort = function(event) {
+        alert(&quot;Initial upgrade versionchange transaction unexpected abort&quot;);
+        done();
+    }
+
+    versionTransaction.oncomplete = function(event) {
+        alert(&quot;Initial upgrade versionchange transaction complete&quot;);
+        continueTest1();
+    }
+
+    versionTransaction.onerror = function(event) {
+        alert(&quot;Initial upgrade versionchange transaction unexpected error&quot; + event);
+        done();
+    }
+}
+
+function putChecker(event) {
+    alert(&quot;Key used for put was &quot; + event.target.result);
+}
+
+function continueTest1()
+{
+    alert(&quot;Opening readwrite transaction to bump the key generator, but it will be aborted&quot;);
+    var transaction = database.transaction('TestObjectStore', &quot;readwrite&quot;);
+    var objectStore = transaction.objectStore('TestObjectStore');
+    
+    var request = objectStore.put(&quot;bar1&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar2&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar3&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar4&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar5&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar6&quot;);
+    request.onsuccess = function(event) {
+        putChecker(event);
+        transaction.abort();
+    }
+    
+    transaction.onabort = function(event) {
+        alert(&quot;readwrite transaction abort&quot;);
+        continueTest2();
+    }
+
+    transaction.oncomplete = function(event) {
+        alert(&quot;readwrite transaction unexpected complete&quot;);
+        done();
+    }
+
+    transaction.onerror = function(event) {
+        alert(&quot;readwrite transaction unexpected error&quot;);
+        done();
+    }
+}
+
+function continueTest2()
+{
+    alert(&quot;Opening readwrite transaction to make sure the key generator had successfully reverted&quot;);
+    
+    var transaction = database.transaction('TestObjectStore', &quot;readwrite&quot;);
+    var objectStore = transaction.objectStore('TestObjectStore');
+
+    var request = objectStore.put(&quot;bar1&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar2&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar3&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar4&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar5&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar6&quot;);
+    request.onsuccess = putChecker;
+
+    transaction.onabort = function(event) {
+        alert(&quot;readwrite transaction unexpected abort&quot;);
+        done();
+    }
+
+    transaction.oncomplete = function(event) {
+        alert(&quot;readwrite transaction complete&quot;);
+        continueTest3();
+    }
+
+    transaction.onerror = function(event) {
+        alert(&quot;readwrite transaction unexpected error&quot;);
+        done();
+    }
+}
+
+function continueTest3()
+{
+    alert(&quot;Opening readwrite transaction to make sure the key generator picks up where it should've left off&quot;);
+    
+    var transaction = database.transaction('TestObjectStore', &quot;readwrite&quot;);
+    var objectStore = transaction.objectStore('TestObjectStore');
+
+    var request = objectStore.put(&quot;bar1&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar2&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar3&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar4&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar5&quot;);
+    request.onsuccess = putChecker;
+    var request = objectStore.put(&quot;bar6&quot;);
+    request.onsuccess = putChecker;
+
+    transaction.onabort = function(event) {
+        alert(&quot;readwrite transaction unexpected abort&quot;);
+        done();
+    }
+
+    transaction.oncomplete = function(event) {
+        alert(&quot;readwrite transaction complete&quot;);
+        done();
+    }
+
+    transaction.onerror = function(event) {
+        alert(&quot;readwrite transaction unexpected error&quot;);
+        done();
+    }
+}
+
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/ChangeLog        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-10-29  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: autoIncrement support.
+        https://bugs.webkit.org/show_bug.cgi?id=150695
+
+        Reviewed by Alex Christensen.
+
+        Test: storage/indexeddb/modern/autoincrement-abort.html
+
+        * Modules/indexeddb/server/IDBBackingStore.h:
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::addNewObjectStore):
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::addExistingObjectStore):
+        (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
+        * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
+        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+        (WebCore::IDBServer::MemoryIDBBackingStore::putRecord):
+        (WebCore::IDBServer::MemoryIDBBackingStore::generateKeyNumber):
+        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+        * Modules/indexeddb/server/MemoryObjectStore.h:
+        (WebCore::IDBServer::MemoryObjectStore::currentKeyGeneratorValue):
+        (WebCore::IDBServer::MemoryObjectStore::setKeyGeneratorValue):
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
+
</ins><span class="cx"> 2015-10-29  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Make WebCore a framework in Mac CMake build
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx">     virtual IDBError deleteRecord(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&amp;) = 0;
</span><span class="cx">     virtual IDBError putRecord(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&amp;, const ThreadSafeDataBuffer&amp; value) = 0;
</span><span class="cx">     virtual IDBError getRecord(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&amp;, ThreadSafeDataBuffer&amp; outValue) = 0;
</span><ins>+    virtual IDBError generateKeyNumber(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t&amp; keyNumber) = 0;
+
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace IDBServer
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryBackingStoreTransactioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -60,12 +60,9 @@
</span><span class="cx">     LOG(IndexedDB, &quot;MemoryBackingStoreTransaction::addNewObjectStore()&quot;);
</span><span class="cx"> 
</span><span class="cx">     ASSERT(isVersionChange());
</span><del>-
-    ASSERT(!m_objectStores.contains(&amp;objectStore));
-    m_objectStores.add(&amp;objectStore);
</del><span class="cx">     m_versionChangeAddedObjectStores.add(&amp;objectStore);
</span><span class="cx"> 
</span><del>-    objectStore.writeTransactionStarted(*this);
</del><ins>+    addExistingObjectStore(objectStore);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MemoryBackingStoreTransaction::addExistingObjectStore(MemoryObjectStore&amp; objectStore)
</span><span class="lines">@@ -78,6 +75,8 @@
</span><span class="cx">     m_objectStores.add(&amp;objectStore);
</span><span class="cx"> 
</span><span class="cx">     objectStore.writeTransactionStarted(*this);
</span><ins>+
+    m_originalKeyGenerators.add(&amp;objectStore, objectStore.currentKeyGeneratorValue());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MemoryBackingStoreTransaction::objectStoreDeleted(std::unique_ptr&lt;MemoryObjectStore&gt; objectStore)
</span><span class="lines">@@ -136,6 +135,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (auto objectStore : m_objectStores) {
</span><ins>+        ASSERT(m_originalKeyGenerators.contains(objectStore));
+        objectStore-&gt;setKeyGeneratorValue(m_originalKeyGenerators.get(objectStore));
+
</ins><span class="cx">         auto keyValueMap = m_originalValues.get(objectStore);
</span><span class="cx">         if (!keyValueMap)
</span><span class="cx">             continue;
</span><span class="lines">@@ -148,7 +150,6 @@
</span><span class="cx">         m_originalValues.remove(objectStore);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-
</del><span class="cx">     finish();
</span><span class="cx"> 
</span><span class="cx">     for (auto objectStore : m_versionChangeAddedObjectStores)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryBackingStoreTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx">     HashSet&lt;MemoryObjectStore*&gt; m_objectStores;
</span><span class="cx">     HashSet&lt;MemoryObjectStore*&gt; m_versionChangeAddedObjectStores;
</span><span class="cx"> 
</span><ins>+    HashMap&lt;MemoryObjectStore*, uint64_t&gt; m_originalKeyGenerators;
</ins><span class="cx">     HashMap&lt;String, std::unique_ptr&lt;MemoryObjectStore&gt;&gt; m_deletedObjectStores;
</span><span class="cx">     HashMap&lt;MemoryObjectStore*, std::unique_ptr&lt;KeyValueMap&gt;&gt; m_originalValues;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -211,7 +211,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto transaction = m_transactions.get(transactionIdentifier);
</span><span class="cx">     if (!transaction)
</span><del>-        return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral(&quot;No backing store transaction found to get record&quot;));
</del><ins>+        return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral(&quot;No backing store transaction found to put record&quot;));
</ins><span class="cx"> 
</span><span class="cx">     MemoryObjectStore* objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
</span><span class="cx">     if (!objectStore)
</span><span class="lines">@@ -238,6 +238,22 @@
</span><span class="cx">     return IDBError();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+IDBError MemoryIDBBackingStore::generateKeyNumber(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t&amp; keyNumber)
+{
+    LOG(IndexedDB, &quot;MemoryIDBBackingStore::generateKeyNumber&quot;);
+    ASSERT(objectStoreIdentifier);
+    ASSERT_UNUSED(transactionIdentifier, m_transactions.contains(transactionIdentifier));
+    ASSERT_UNUSED(transactionIdentifier, m_transactions.get(transactionIdentifier)-&gt;isWriting());
+
+    MemoryObjectStore* objectStore = m_objectStoresByIdentifier.get(objectStoreIdentifier);
+    RELEASE_ASSERT(objectStore);
+
+    keyNumber = objectStore-&gt;currentKeyGeneratorValue();
+    objectStore-&gt;setKeyGeneratorValue(keyNumber + 1);
+
+    return IDBError();
+}
+
</ins><span class="cx"> void MemoryIDBBackingStore::registerObjectStore(std::unique_ptr&lt;MemoryObjectStore&gt;&amp;&amp; objectStore)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(objectStore);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryIDBBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx">     virtual IDBError deleteRecord(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&amp;) override final;
</span><span class="cx">     virtual IDBError putRecord(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&amp;, const ThreadSafeDataBuffer&amp; value) override final;
</span><span class="cx">     virtual IDBError getRecord(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&amp;, ThreadSafeDataBuffer&amp; outValue) override final;
</span><ins>+    virtual IDBError generateKeyNumber(const IDBResourceIdentifier&amp; transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t&amp; keyNumber) override final;
</ins><span class="cx"> 
</span><span class="cx">     void removeObjectStoreForVersionChangeAbort(MemoryObjectStore&amp;);
</span><span class="cx">     void restoreObjectStoreForVersionChangeAbort(std::unique_ptr&lt;MemoryObjectStore&gt;&amp;&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverMemoryObjectStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -60,6 +60,9 @@
</span><span class="cx"> 
</span><span class="cx">     void setKeyValue(const IDBKeyData&amp;, const ThreadSafeDataBuffer&amp; value);
</span><span class="cx"> 
</span><ins>+    uint64_t currentKeyGeneratorValue() const { return m_keyGeneratorValue; }
+    void setKeyGeneratorValue(uint64_t value) { m_keyGeneratorValue = value; }
+
</ins><span class="cx">     ThreadSafeDataBuffer valueForKey(const IDBKeyData&amp;) const;
</span><span class="cx"> 
</span><span class="cx">     const IDBObjectStoreInfo&amp; info() const { return m_info; }
</span><span class="lines">@@ -70,6 +73,7 @@
</span><span class="cx">     IDBObjectStoreInfo m_info;
</span><span class="cx"> 
</span><span class="cx">     MemoryBackingStoreTransaction* m_writeTransaction { nullptr };
</span><ins>+    uint64_t m_keyGeneratorValue { 1 };
</ins><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;KeyValueMap&gt; m_keyValueStore;
</span><span class="cx">     std::unique_ptr&lt;std::set&lt;IDBKeyData&gt;&gt; m_orderedKeys;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (191775 => 191776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-10-30 04:30:26 UTC (rev 191775)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-10-30 04:55:12 UTC (rev 191776)
</span><span class="lines">@@ -313,6 +313,7 @@
</span><span class="cx">     ASSERT(m_backingStore);
</span><span class="cx">     ASSERT(objectStoreIdentifier);
</span><span class="cx"> 
</span><ins>+    bool keyWasGenerated = false;
</ins><span class="cx">     IDBKeyData usedKey;
</span><span class="cx">     IDBError error;
</span><span class="cx"> 
</span><span class="lines">@@ -324,14 +325,18 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (objectStoreInfo-&gt;autoIncrement() &amp;&amp; !keyData.isValid()) {
</span><del>-        // FIXME: This is where generated key support goes
-        error = IDBError(IDBExceptionCode::Unknown, ASCIILiteral(&quot;Key generators not supported yet&quot;));
-        m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
-        return;
-    }
</del><ins>+        uint64_t keyNumber;
+        error = m_backingStore-&gt;generateKeyNumber(transactionIdentifier, objectStoreIdentifier, keyNumber);
+        if (!error.isNull()) {
+            m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
+            return;
+        }
+        
+        usedKey.setNumberValue(keyNumber);
+        keyWasGenerated = true;
+    } else
+        usedKey = keyData;
</ins><span class="cx"> 
</span><del>-    usedKey = keyData;
-
</del><span class="cx">     if (overwriteMode == IndexedDB::ObjectStoreOverwriteMode::NoOverwrite) {
</span><span class="cx">         bool keyExists;
</span><span class="cx">         error = m_backingStore-&gt;keyExistsInObjectStore(transactionIdentifier, objectStoreIdentifier, usedKey, keyExists);
</span></span></pre>
</div>
</div>

</body>
</html>