<!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>[197116] releases/WebKitGTK/webkit-2.12/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/197116">197116</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-25 08:19:53 -0800 (Thu, 25 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/197057">r197057</a> - Modern IDB: Some w3c objectstore tests crash under GuardMalloc.
https://bugs.webkit.org/show_bug.cgi?id=154460

Reviewed by Alex Christensen.

No new tests (Covered by existing tests).

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase):
(WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):  Don't delete the UniqueIDBDatabase yet
  if there are still any connections pending close.
(WebCore::IDBServer::UniqueIDBDatabase::didPerformCommitTransaction):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformAbortTransaction):
(WebCore::IDBServer::UniqueIDBDatabase::inProgressTransactionCompleted): It's possible that with this
  transaction completing, and a connection finished its close process, that the UniqueIDBDatabase is
  now ready to be deleted.

* Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseConnection::abortTransactionWithoutCallback):
* Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:

* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::abortWithoutCallback):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseConnectioncpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseConnectionh">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h</a></li>
<li><a href="#releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseTransactioncpp">releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit212SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (197115 => 197116)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-02-25 16:18:42 UTC (rev 197115)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog        2016-02-25 16:19:53 UTC (rev 197116)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-02-24  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: Some w3c objectstore tests crash under GuardMalloc.
+        https://bugs.webkit.org/show_bug.cgi?id=154460
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Covered by existing tests).
+
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase):
+        (WebCore::IDBServer::UniqueIDBDatabase::performCurrentDeleteOperation):
+        (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):  Don't delete the UniqueIDBDatabase yet 
+          if there are still any connections pending close.
+        (WebCore::IDBServer::UniqueIDBDatabase::didPerformCommitTransaction):
+        (WebCore::IDBServer::UniqueIDBDatabase::didPerformAbortTransaction):
+        (WebCore::IDBServer::UniqueIDBDatabase::inProgressTransactionCompleted): It's possible that with this
+          transaction completing, and a connection finished its close process, that the UniqueIDBDatabase is
+          now ready to be deleted.
+
+        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabaseConnection::abortTransactionWithoutCallback):
+        * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h:
+
+        * Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabaseTransaction::abortWithoutCallback):
+
</ins><span class="cx"> 2016-02-24  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Background of an absolutely positioned inline element inside text-indented parent is positioned statically.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabasecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (197115 => 197116)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-02-25 16:18:42 UTC (rev 197115)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp        2016-02-25 16:19:53 UTC (rev 197116)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx">     ASSERT(m_inProgressTransactions.isEmpty());
</span><span class="cx">     ASSERT(m_pendingTransactions.isEmpty());
</span><span class="cx">     ASSERT(m_openDatabaseConnections.isEmpty());
</span><ins>+    ASSERT(m_closePendingDatabaseConnections.isEmpty());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const IDBDatabaseInfo&amp; UniqueIDBDatabase::info() const
</span><span class="lines">@@ -181,12 +182,8 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Even though we have no open database connections, we might have close-pending database connections
-    // that are waiting on transactions to complete.
-    if (!m_inProgressTransactions.isEmpty()) {
-        ASSERT(!m_closePendingDatabaseConnections.isEmpty());
</del><ins>+    if (!m_inProgressTransactions.isEmpty())
</ins><span class="cx">         return;
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     ASSERT(!hasAnyPendingCallbacks());
</span><span class="cx">     ASSERT(m_pendingTransactions.isEmpty());
</span><span class="lines">@@ -241,10 +238,12 @@
</span><span class="cx">     m_deletePending = false;
</span><span class="cx">     m_deleteBackingStoreInProgress = false;
</span><span class="cx"> 
</span><del>-    if (m_pendingOpenDBRequests.isEmpty())
-        m_server.deleteUniqueIDBDatabase(*this);
-    else
-        invokeOperationAndTransactionTimer();
</del><ins>+    if (m_closePendingDatabaseConnections.isEmpty()) {
+        if (m_pendingOpenDBRequests.isEmpty())
+            m_server.deleteUniqueIDBDatabase(*this);
+        else
+            invokeOperationAndTransactionTimer();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::handleDatabaseOperations()
</span><span class="lines">@@ -978,9 +977,9 @@
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx">     LOG(IndexedDB, &quot;(main) UniqueIDBDatabase::didPerformCommitTransaction&quot;);
</span><span class="cx"> 
</span><ins>+    performErrorCallback(callbackIdentifier, error);
+
</ins><span class="cx">     inProgressTransactionCompleted(transactionIdentifier);
</span><del>-
-    performErrorCallback(callbackIdentifier, error);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::abortTransaction(UniqueIDBDatabaseTransaction&amp; transaction, ErrorCallback callback)
</span><span class="lines">@@ -1028,9 +1027,9 @@
</span><span class="cx">         m_databaseInfo = std::make_unique&lt;IDBDatabaseInfo&gt;(*m_versionChangeTransaction-&gt;originalDatabaseInfo());
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    performErrorCallback(callbackIdentifier, error);
+
</ins><span class="cx">     inProgressTransactionCompleted(transactionIdentifier);
</span><del>-
-    performErrorCallback(callbackIdentifier, error);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UniqueIDBDatabase::transactionDestroyed(UniqueIDBDatabaseTransaction&amp; transaction)
</span><span class="lines">@@ -1244,6 +1243,13 @@
</span><span class="cx">     if (!transaction-&gt;databaseConnection().hasNonFinishedTransactions())
</span><span class="cx">         m_closePendingDatabaseConnections.remove(&amp;transaction-&gt;databaseConnection());
</span><span class="cx"> 
</span><ins>+    // It's possible that this database had its backing store deleted but there were a few outstanding asynchronous operations.
+    // If this transaction completing was the last of those operations, we can finally delete this UniqueIDBDatabase.
+    if (m_closePendingDatabaseConnections.isEmpty() &amp;&amp; m_pendingOpenDBRequests.isEmpty() &amp;&amp; !m_databaseInfo) {
+        m_server.deleteUniqueIDBDatabase(*this);
+        return;
+    }
+
</ins><span class="cx">     // Previously blocked operations might be runnable.
</span><span class="cx">     invokeOperationAndTransactionTimer();
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseConnectioncpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp (197115 => 197116)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp        2016-02-25 16:18:42 UTC (rev 197115)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp        2016-02-25 16:19:53 UTC (rev 197116)
</span><span class="lines">@@ -66,6 +66,14 @@
</span><span class="cx">     return !m_transactionMap.isEmpty();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UniqueIDBDatabaseConnection::abortTransactionWithoutCallback(UniqueIDBDatabaseTransaction&amp; transaction)
+{
+    ASSERT(m_transactionMap.contains(transaction.info().identifier()));
+    auto takenTransaction = m_transactionMap.take(transaction.info().identifier());
+
+    m_database.abortTransaction(*takenTransaction, [](const IDBError&amp;) { });
+}
+
</ins><span class="cx"> void UniqueIDBDatabaseConnection::connectionClosedFromClient()
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;UniqueIDBDatabaseConnection::connectionClosedFromClient - %&quot; PRIu64, m_identifier);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseConnectionh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h (197115 => 197116)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h        2016-02-25 16:18:42 UTC (rev 197115)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseConnection.h        2016-02-25 16:19:53 UTC (rev 197116)
</span><span class="lines">@@ -73,6 +73,8 @@
</span><span class="cx">     void didDeleteIndex(const IDBResultData&amp;);
</span><span class="cx">     void didFireVersionChangeEvent(const IDBResourceIdentifier&amp; requestIdentifier);
</span><span class="cx"> 
</span><ins>+    void abortTransactionWithoutCallback(UniqueIDBDatabaseTransaction&amp;);
+
</ins><span class="cx"> private:
</span><span class="cx">     UniqueIDBDatabaseConnection(UniqueIDBDatabase&amp;, IDBConnectionToClient&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit212SourceWebCoreModulesindexeddbserverUniqueIDBDatabaseTransactioncpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp (197115 => 197116)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp        2016-02-25 16:18:42 UTC (rev 197115)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp        2016-02-25 16:19:53 UTC (rev 197116)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;UniqueIDBDatabaseTransaction::abortWithoutCallback&quot;);
</span><span class="cx"> 
</span><del>-    m_databaseConnection-&gt;database().abortTransaction(*this, [](const IDBError&amp;) { });
</del><ins>+    m_databaseConnection-&gt;abortTransactionWithoutCallback(*this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool UniqueIDBDatabaseTransaction::isVersionChange() const
</span></span></pre>
</div>
</div>

</body>
</html>