<!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>[194256] 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/194256">194256</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-12-17 19:06:11 -0800 (Thu, 17 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/194241">r194241</a> and <a href="http://trac.webkit.org/projects/webkit/changeset/194252">r194252</a>.
https://bugs.webkit.org/show_bug.cgi?id=152415

Caused crashes on GuardMalloc (Requested by ap on #webkit).

Reverted changesets:

&quot;Modern IDB: Refactor open/delete requests to exist in the
same queue.&quot;
https://bugs.webkit.org/show_bug.cgi?id=152397
http://trac.webkit.org/changeset/194241

&quot;Modern IDB: Refactor when opening the backing store takes
place.&quot;
https://bugs.webkit.org/show_bug.cgi?id=152405
http://trac.webkit.org/changeset/194252</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBServerOperationcpp">trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverIDBServerOperationh">trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh">trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/LayoutTests/ChangeLog        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-12-17  Commit Queue  &lt;commit-queue@webkit.org&gt;
+
+        Unreviewed, rolling out r194241 and r194252.
+        https://bugs.webkit.org/show_bug.cgi?id=152415
+
+        Caused crashes on GuardMalloc (Requested by ap on #webkit).
+
+        Reverted changesets:
+
+        &quot;Modern IDB: Refactor open/delete requests to exist in the
+        same queue.&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=152397
+        http://trac.webkit.org/changeset/194241
+
+        &quot;Modern IDB: Refactor when opening the backing store takes
+        place.&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=152405
+        http://trac.webkit.org/changeset/194252
+
</ins><span class="cx"> 2015-12-17  Sukolsak Sakshuwong  &lt;sukolsak@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [INTL] Implement Collator Compare Functions
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -99,6 +99,7 @@
</span><span class="cx"> storage/indexeddb/intversion-two-opens-no-versions.html [ Failure ]
</span><span class="cx"> storage/indexeddb/odd-strings.html [ Failure ]
</span><span class="cx"> storage/indexeddb/open-db-private-browsing.html [ Failure ]
</span><ins>+storage/indexeddb/open-ordering.html [ Failure ]
</ins><span class="cx"> storage/indexeddb/properties-disabled-at-runtime.html [ Failure ]
</span><span class="cx"> storage/indexeddb/setversion-blocked-by-versionchange-close.html [ Failure ]
</span><span class="cx"> storage/indexeddb/transaction-basics.html [ Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/ChangeLog        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-12-17  Commit Queue  &lt;commit-queue@webkit.org&gt;
+
+        Unreviewed, rolling out r194241 and r194252.
+        https://bugs.webkit.org/show_bug.cgi?id=152415
+
+        Caused crashes on GuardMalloc (Requested by ap on #webkit).
+
+        Reverted changesets:
+
+        &quot;Modern IDB: Refactor open/delete requests to exist in the
+        same queue.&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=152397
+        http://trac.webkit.org/changeset/194241
+
+        &quot;Modern IDB: Refactor when opening the backing store takes
+        place.&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=152405
+        http://trac.webkit.org/changeset/194252
+
</ins><span class="cx"> 2015-12-17  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: Refactor when opening the backing store takes place.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBServerOperationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.cpp        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="cx"> 
</span><del>-#include &quot;IDBResultData.h&quot;
</del><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -55,22 +54,6 @@
</span><span class="cx">     return m_requestData.isDeleteRequest();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IDBServerOperation::notifyDeleteRequestBlocked(uint64_t currentVersion)
-{
-    ASSERT(isDeleteRequest());
-    ASSERT(!m_notifiedDeleteRequestBlocked);
-
-    m_connection.notifyOpenDBRequestBlocked(m_requestData.requestIdentifier(), currentVersion, 0);
-    m_notifiedDeleteRequestBlocked = true;
-}
-
-void IDBServerOperation::notifyDidDeleteDatabase(const IDBDatabaseInfo&amp; info)
-{
-    ASSERT(isDeleteRequest());
-
-    m_connection.didDeleteDatabase(IDBResultData::deleteDatabaseSuccess(m_requestData.requestIdentifier(), info));
-}
-
</del><span class="cx"> } // namespace IDBServer
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverIDBServerOperationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServerOperation.h        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -34,9 +34,6 @@
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><del>-
-class IDBDatabaseInfo;
-
</del><span class="cx"> namespace IDBServer {
</span><span class="cx"> 
</span><span class="cx"> class IDBServerOperation : public RefCounted&lt;IDBServerOperation&gt; {
</span><span class="lines">@@ -49,17 +46,11 @@
</span><span class="cx">     bool isOpenRequest() const;
</span><span class="cx">     bool isDeleteRequest() const;
</span><span class="cx"> 
</span><del>-    void notifyDeleteRequestBlocked(uint64_t currentVersion);
-    void notifyDidDeleteDatabase(const IDBDatabaseInfo&amp;);
-    bool hasNotifiedDeleteRequestBlocked() const { return m_notifiedDeleteRequestBlocked; }
-
</del><span class="cx"> private:
</span><span class="cx">     IDBServerOperation(IDBConnectionToClient&amp;, const IDBRequestData&amp;);
</span><span class="cx"> 
</span><span class="cx">     IDBConnectionToClient&amp; m_connection;
</span><span class="cx">     IDBRequestData m_requestData;
</span><del>-
-    bool m_notifiedDeleteRequestBlocked { false };
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace IDBServer
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -51,15 +51,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-UniqueIDBDatabase::~UniqueIDBDatabase()
-{
-    LOG(IndexedDB, &quot;UniqueIDBDatabase::~UniqueIDBDatabase()&quot;);
-    ASSERT(!hasAnyPendingCallbacks());
-    ASSERT(m_inProgressTransactions.isEmpty());
-    ASSERT(m_pendingTransactions.isEmpty());
-    ASSERT(m_openDatabaseConnections.isEmpty());
-}
-
</del><span class="cx"> const IDBDatabaseInfo&amp; UniqueIDBDatabase::info() const
</span><span class="cx"> {
</span><span class="cx">     RELEASE_ASSERT(m_databaseInfo);
</span><span class="lines">@@ -69,13 +60,19 @@
</span><span class="cx"> void UniqueIDBDatabase::openDatabaseConnection(IDBConnectionToClient&amp; connection, const IDBRequestData&amp; requestData)
</span><span class="cx"> {
</span><span class="cx">     auto operation = IDBServerOperation::create(connection, requestData);
</span><del>-    m_pendingDatabaseOperations.append(WTF::move(operation));
</del><ins>+    m_pendingOpenDatabaseOperations.append(WTF::move(operation));
</ins><span class="cx"> 
</span><del>-    // An open operation is already in progress, so we can't possibly handle this one yet.
</del><ins>+    // An open operation is already in progress, so this one has to wait.
</ins><span class="cx">     if (m_isOpeningBackingStore)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    handleDatabaseOperations();
</del><ins>+    if (m_databaseInfo) {
+        handleDatabaseOperations();
+        return;
+    }
+
+    m_isOpeningBackingStore = true;
+    m_server.postDatabaseTask(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::openBackingStore, m_identifier));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool UniqueIDBDatabase::hasAnyPendingCallbacks() const
</span><span class="lines">@@ -86,14 +83,39 @@
</span><span class="cx">         || !m_countCallbacks.isEmpty();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool UniqueIDBDatabase::isVersionChangeInProgress()
</del><ins>+bool UniqueIDBDatabase::maybeDeleteDatabase(IDBServerOperation* newestDeleteOperation)
</ins><span class="cx"> {
</span><del>-#ifndef NDEBUG
-    if (m_versionChangeTransaction)
-        ASSERT(m_versionChangeDatabaseConnection);
-#endif
</del><ins>+    ASSERT(isMainThread());
+    LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::maybeDeleteDatabase&quot;);
</ins><span class="cx"> 
</span><del>-    return m_versionChangeDatabaseConnection;
</del><ins>+    if (hasAnyOpenConnections() || !m_closePendingDatabaseConnections.isEmpty()) {
+        // Exactly once, notify all open connections of the pending deletion.
+        if (!m_hasNotifiedConnectionsOfDelete) {
+            notifyConnectionsOfVersionChange(0);
+            m_hasNotifiedConnectionsOfDelete = true;
+        }
+
+        if (newestDeleteOperation)
+            newestDeleteOperation-&gt;connection().notifyOpenDBRequestBlocked(newestDeleteOperation-&gt;requestData().requestIdentifier(), m_databaseInfo-&gt;version(), 0);
+
+        return false;
+    }
+
+    ASSERT(!hasAnyPendingCallbacks());
+    ASSERT(m_inProgressTransactions.isEmpty());
+    ASSERT(m_pendingTransactions.isEmpty());
+    ASSERT(m_openDatabaseConnections.isEmpty());
+    ASSERT(m_pendingOpenDatabaseOperations.isEmpty());
+
+    for (auto&amp; operation : m_pendingDeleteDatabaseOperations) {
+        ASSERT(m_databaseInfo);
+        ASSERT(operation-&gt;isDeleteRequest());
+        operation-&gt;connection().didDeleteDatabase(IDBResultData::deleteDatabaseSuccess(operation-&gt;requestData().requestIdentifier(), *m_databaseInfo));
+    }
+
+    m_server.deleteUniqueIDBDatabase(*this);
+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::performCurrentOpenOperation()
</span><span class="lines">@@ -103,20 +125,6 @@
</span><span class="cx">     ASSERT(m_currentOperation);
</span><span class="cx">     ASSERT(m_currentOperation-&gt;isOpenRequest());
</span><span class="cx"> 
</span><del>-    if (!m_databaseInfo) {
-        m_isOpeningBackingStore = true;
-        m_server.postDatabaseTask(createCrossThreadTask(*this, &amp;UniqueIDBDatabase::openBackingStore, m_identifier));
-        return;
-    }
-
-    // If we previously started a version change operation but were blocked by having open connections,
-    // we might now be unblocked.
-    if (m_versionChangeDatabaseConnection) {
-        if (!m_versionChangeTransaction &amp;&amp; !hasAnyOpenConnections())
-            startVersionChangeTransaction();
-        return;
-    }
-
</del><span class="cx">     // 3.3.1 Opening a database
</span><span class="cx">     // If requested version is undefined, then let requested version be 1 if db was created in the previous step,
</span><span class="cx">     // or the current version of db otherwise.
</span><span class="lines">@@ -168,83 +176,36 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::performCurrentDeleteOperation&quot;);
</span><span class="cx"> 
</span><del>-    ASSERT(m_databaseInfo);
-    ASSERT(m_currentOperation);
-    ASSERT(m_currentOperation-&gt;isDeleteRequest());
-
-    if (hasAnyOpenConnections()) {
-        // Exactly once, notify all open connections of the pending deletion.
-        if (!m_hasNotifiedConnectionsOfDelete) {
-            notifyConnectionsOfVersionChange(0);
-            m_hasNotifiedConnectionsOfDelete = true;
-        }
-
-        if (!m_currentOperation-&gt;hasNotifiedDeleteRequestBlocked())
-            m_currentOperation-&gt;notifyDeleteRequestBlocked(m_databaseInfo-&gt;version());
-
-        return;
-    }
-
-    ASSERT(!hasAnyPendingCallbacks());
-    ASSERT(m_inProgressTransactions.isEmpty());
-    ASSERT(m_pendingTransactions.isEmpty());
-    ASSERT(m_openDatabaseConnections.isEmpty());
-
-    m_currentOperation-&gt;notifyDidDeleteDatabase(*m_databaseInfo);
-    m_currentOperation = nullptr;
-    m_hasNotifiedConnectionsOfDelete = false;
-    m_deletePending = false;
-
-    if (m_pendingDatabaseOperations.isEmpty())
-        m_server.deleteUniqueIDBDatabase(*this);
-    else
-        invokeOperationAndTransactionTimer();
</del><ins>+    // Not used yet.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::handleDatabaseOperations()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><del>-    LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::handleDatabaseOperations - There are %zu pending&quot;, m_pendingDatabaseOperations.size());
</del><ins>+    LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::handleDatabaseOperations&quot;);
</ins><span class="cx"> 
</span><del>-    if (m_versionChangeDatabaseConnection || m_currentOperation) {
-        // We can't start the next database operation quite yet, but we might need to notify all open connections
-        // about a pending delete.
-        if (!m_pendingDatabaseOperations.isEmpty() &amp;&amp; m_pendingDatabaseOperations.first()-&gt;isDeleteRequest() &amp;&amp; !m_hasNotifiedConnectionsOfDelete) {
-            m_hasNotifiedConnectionsOfDelete = true;
-            notifyConnectionsOfVersionChange(0);
-        }
</del><ins>+    // If a version change transaction is currently in progress, no new connections can be opened right now.
+    // We will try again later.
+    if (m_versionChangeDatabaseConnection)
+        return;
</ins><span class="cx"> 
</span><del>-        // Some operations (such as the first open operation after a delete) require multiple passes to completely handle
-        if (m_currentOperation)
-            handleCurrentOperation();
-
</del><ins>+    if (m_pendingOpenDatabaseOperations.isEmpty())
</ins><span class="cx">         return;
</span><del>-    }
</del><span class="cx"> 
</span><del>-    if (m_pendingDatabaseOperations.isEmpty())
</del><ins>+    if (m_currentOperation)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_currentOperation = m_pendingDatabaseOperations.takeFirst();
-    LOG(IndexedDB, &quot;UniqueIDBDatabase::handleDatabaseOperations - Popped an operation, now there are %zu pending&quot;, m_pendingDatabaseOperations.size());
</del><ins>+    m_currentOperation = m_pendingOpenDatabaseOperations.takeFirst();
</ins><span class="cx"> 
</span><del>-    handleCurrentOperation();
-}
</del><ins>+    // FIXME: Once handleDatabaseOperations also handles delete operations, remove this ASSERT.
+    ASSERT(m_currentOperation-&gt;isOpenRequest());
</ins><span class="cx"> 
</span><del>-void UniqueIDBDatabase::handleCurrentOperation()
-{
-    ASSERT(m_currentOperation);
-
-    RefPtr&lt;UniqueIDBDatabase&gt; protector(this);
-
</del><span class="cx">     if (m_currentOperation-&gt;isOpenRequest())
</span><span class="cx">         performCurrentOpenOperation();
</span><span class="cx">     else if (m_currentOperation-&gt;isDeleteRequest())
</span><span class="cx">         performCurrentDeleteOperation();
</span><span class="cx">     else
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><del>-
-    if (!m_currentOperation)
-        invokeOperationAndTransactionTimer();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool UniqueIDBDatabase::hasAnyOpenConnections() const
</span><span class="lines">@@ -295,8 +256,18 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::handleDelete&quot;);
</span><span class="cx"> 
</span><del>-    m_pendingDatabaseOperations.append(IDBServerOperation::create(connection, requestData));
-    handleDatabaseOperations();
</del><ins>+    auto operation = IDBServerOperation::create(connection, requestData);
+    auto* rawOperation = &amp;operation.get();
+    m_pendingDeleteDatabaseOperations.append(WTF::move(operation));
+
+    // If a different request has already come in to delete this database, there's nothing left to do.
+    // A delete is already in progress, and this request will be handled along with all the rest.
+    if (m_deletePending)
+        return;
+
+    m_deletePending = true;
+
+    maybeDeleteDatabase(rawOperation);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::startVersionChangeTransaction()
</span><span class="lines">@@ -966,7 +937,6 @@
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::invokeOperationAndTransactionTimer()
</span><span class="cx"> {
</span><del>-    LOG(IndexedDB, &quot;UniqueIDBDatabase::invokeOperationAndTransactionTimer()&quot;);
</del><span class="cx">     if (!m_operationAndTransactionTimer.isActive())
</span><span class="cx">         m_operationAndTransactionTimer.startOneShot(0);
</span><span class="cx"> }
</span><span class="lines">@@ -975,14 +945,19 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::operationAndTransactionTimerFired&quot;);
</span><span class="cx"> 
</span><del>-    // The current operation might require multiple attempts to handle, so try to
-    // make further progress on it now.
-    if (m_currentOperation)
-        handleCurrentOperation();
</del><ins>+    handleDatabaseOperations();
</ins><span class="cx"> 
</span><del>-    if (!m_currentOperation)
-        handleDatabaseOperations();
</del><ins>+    if (m_deletePending &amp;&amp; maybeDeleteDatabase(nullptr))
+        return;
</ins><span class="cx"> 
</span><ins>+    // If the database was not deleted in the previous step, try to run a transaction now.
+    if (m_pendingTransactions.isEmpty()) {
+        if (!hasAnyOpenConnections() &amp;&amp; m_currentOperation) {
+            startVersionChangeTransaction();
+            return;
+        }
+    }
+
</ins><span class="cx">     bool hadDeferredTransactions = false;
</span><span class="cx">     auto transaction = takeNextRunnableTransaction(hadDeferredTransactions);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbserverUniqueIDBDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h (194255 => 194256)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2015-12-18 02:46:47 UTC (rev 194255)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h        2015-12-18 03:06:11 UTC (rev 194256)
</span><span class="lines">@@ -71,8 +71,6 @@
</span><span class="cx">         return adoptRef(*new UniqueIDBDatabase(server, identifier));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ~UniqueIDBDatabase();
-
</del><span class="cx">     void openDatabaseConnection(IDBConnectionToClient&amp;, const IDBRequestData&amp;);
</span><span class="cx"> 
</span><span class="cx">     const IDBDatabaseInfo&amp; info() const;
</span><span class="lines">@@ -107,16 +105,15 @@
</span><span class="cx">     UniqueIDBDatabase(IDBServer&amp;, const IDBDatabaseIdentifier&amp;);
</span><span class="cx">     
</span><span class="cx">     void handleDatabaseOperations();
</span><del>-    void handleCurrentOperation();
</del><span class="cx">     void performCurrentOpenOperation();
</span><span class="cx">     void performCurrentDeleteOperation();
</span><span class="cx">     void addOpenDatabaseConnection(Ref&lt;UniqueIDBDatabaseConnection&gt;&amp;&amp;);
</span><ins>+    bool maybeDeleteDatabase(IDBServerOperation*);
</ins><span class="cx">     bool hasAnyOpenConnections() const;
</span><span class="cx"> 
</span><span class="cx">     void startVersionChangeTransaction();
</span><span class="cx">     void notifyConnectionsOfVersionChangeForUpgrade();
</span><span class="cx">     void notifyConnectionsOfVersionChange(uint64_t requestedVersion);
</span><del>-    bool isVersionChangeInProgress();
</del><span class="cx"> 
</span><span class="cx">     void activateTransactionInBackingStore(UniqueIDBDatabaseTransaction&amp;);
</span><span class="cx">     void inProgressTransactionCompleted(const IDBResourceIdentifier&amp;);
</span><span class="lines">@@ -176,7 +173,8 @@
</span><span class="cx">     IDBServer&amp; m_server;
</span><span class="cx">     IDBDatabaseIdentifier m_identifier;
</span><span class="cx">     
</span><del>-    Deque&lt;Ref&lt;IDBServerOperation&gt;&gt; m_pendingDatabaseOperations;
</del><ins>+    Deque&lt;Ref&lt;IDBServerOperation&gt;&gt; m_pendingOpenDatabaseOperations;
+    Deque&lt;Ref&lt;IDBServerOperation&gt;&gt; m_pendingDeleteDatabaseOperations;
</ins><span class="cx">     RefPtr&lt;IDBServerOperation&gt; m_currentOperation;
</span><span class="cx"> 
</span><span class="cx">     HashSet&lt;RefPtr&lt;UniqueIDBDatabaseConnection&gt;&gt; m_openDatabaseConnections;
</span></span></pre>
</div>
</div>

</body>
</html>