<!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>[204349] 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/204349">204349</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2016-08-10 13:30:14 -0700 (Wed, 10 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move all SQLTransactionBackend member variables to SQLTransaction
https://bugs.webkit.org/show_bug.cgi?id=160745

Reviewed by Tim Horton.

* Modules/webdatabase/ChangeVersionWrapper.cpp:
(WebCore::ChangeVersionWrapper::performPreflight):
(WebCore::ChangeVersionWrapper::performPostflight):
(WebCore::ChangeVersionWrapper::handleCommitFailedAfterPostflight):
* Modules/webdatabase/ChangeVersionWrapper.h:
(WebCore::ChangeVersionWrapper::sqlError): Deleted.
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::SQLTransaction):
(WebCore::SQLTransaction::deliverTransactionErrorCallback):
(WebCore::SQLTransaction::deliverStatementCallback):
(WebCore::SQLTransaction::deliverQuotaIncreaseCallback):
(WebCore::SQLTransaction::hasCallback): Deleted.
(WebCore::SQLTransaction::hasSuccessCallback): Deleted.
(WebCore::SQLTransaction::hasErrorCallback): Deleted.
* Modules/webdatabase/SQLTransaction.h:
(WebCore::SQLTransaction::isReadOnly):
* Modules/webdatabase/SQLTransactionBackend.cpp:
(WebCore::SQLTransactionBackend::SQLTransactionBackend):
(WebCore::SQLTransactionBackend::~SQLTransactionBackend):
(WebCore::SQLTransactionBackend::doCleanup):
(WebCore::SQLTransactionBackend::enqueueStatement):
(WebCore::SQLTransactionBackend::computeNextStateAndCleanupIfNeeded):
(WebCore::SQLTransactionBackend::executeSQL):
(WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown):
(WebCore::SQLTransactionBackend::acquireLock):
(WebCore::SQLTransactionBackend::lockAcquired):
(WebCore::SQLTransactionBackend::openTransactionAndPreflight):
(WebCore::SQLTransactionBackend::runStatements):
(WebCore::SQLTransactionBackend::getNextStatement):
(WebCore::SQLTransactionBackend::runCurrentStatement):
(WebCore::SQLTransactionBackend::handleCurrentStatementError):
(WebCore::SQLTransactionBackend::handleTransactionError):
(WebCore::SQLTransactionBackend::postflightAndCommit):
(WebCore::SQLTransactionBackend::cleanupAndTerminate):
(WebCore::SQLTransactionBackend::cleanupAfterTransactionErrorCallback):
(WebCore::SQLTransactionBackend::requestTransitToState):
(WebCore::SQLTransactionBackend::acquireOriginLock):
(WebCore::SQLTransactionBackend::releaseOriginLockIfNeeded):
(WebCore::SQLTransactionBackend::currentStatement): Deleted.
(WebCore::SQLTransactionBackend::transactionError): Deleted.
(WebCore::SQLTransactionBackend::setShouldRetryCurrentStatement): Deleted.
(WebCore::SQLTransactionBackend::enqueueStatementBackend): Deleted.
* Modules/webdatabase/SQLTransactionBackend.h:
(WebCore::SQLTransactionBackend::database): Deleted.
(WebCore::SQLTransactionBackend::isReadOnly): Deleted.
* Modules/webdatabase/SQLTransactionCoordinator.cpp:
(WebCore::SQLTransactionCoordinator::processPendingTransactions):
(WebCore::SQLTransactionCoordinator::releaseLock):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseChangeVersionWrappercpp">trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseChangeVersionWrapperh">trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLTransactioncpp">trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLTransactionh">trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLTransactionBackendcpp">trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLTransactionBackendh">trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebdatabaseSQLTransactionCoordinatorcpp">trunk/Source/WebCore/Modules/webdatabase/SQLTransactionCoordinator.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/ChangeLog        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2016-08-10  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Move all SQLTransactionBackend member variables to SQLTransaction
+        https://bugs.webkit.org/show_bug.cgi?id=160745
+
+        Reviewed by Tim Horton.
+
+        * Modules/webdatabase/ChangeVersionWrapper.cpp:
+        (WebCore::ChangeVersionWrapper::performPreflight):
+        (WebCore::ChangeVersionWrapper::performPostflight):
+        (WebCore::ChangeVersionWrapper::handleCommitFailedAfterPostflight):
+        * Modules/webdatabase/ChangeVersionWrapper.h:
+        (WebCore::ChangeVersionWrapper::sqlError): Deleted.
+        * Modules/webdatabase/SQLTransaction.cpp:
+        (WebCore::SQLTransaction::SQLTransaction):
+        (WebCore::SQLTransaction::deliverTransactionErrorCallback):
+        (WebCore::SQLTransaction::deliverStatementCallback):
+        (WebCore::SQLTransaction::deliverQuotaIncreaseCallback):
+        (WebCore::SQLTransaction::hasCallback): Deleted.
+        (WebCore::SQLTransaction::hasSuccessCallback): Deleted.
+        (WebCore::SQLTransaction::hasErrorCallback): Deleted.
+        * Modules/webdatabase/SQLTransaction.h:
+        (WebCore::SQLTransaction::isReadOnly):
+        * Modules/webdatabase/SQLTransactionBackend.cpp:
+        (WebCore::SQLTransactionBackend::SQLTransactionBackend):
+        (WebCore::SQLTransactionBackend::~SQLTransactionBackend):
+        (WebCore::SQLTransactionBackend::doCleanup):
+        (WebCore::SQLTransactionBackend::enqueueStatement):
+        (WebCore::SQLTransactionBackend::computeNextStateAndCleanupIfNeeded):
+        (WebCore::SQLTransactionBackend::executeSQL):
+        (WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown):
+        (WebCore::SQLTransactionBackend::acquireLock):
+        (WebCore::SQLTransactionBackend::lockAcquired):
+        (WebCore::SQLTransactionBackend::openTransactionAndPreflight):
+        (WebCore::SQLTransactionBackend::runStatements):
+        (WebCore::SQLTransactionBackend::getNextStatement):
+        (WebCore::SQLTransactionBackend::runCurrentStatement):
+        (WebCore::SQLTransactionBackend::handleCurrentStatementError):
+        (WebCore::SQLTransactionBackend::handleTransactionError):
+        (WebCore::SQLTransactionBackend::postflightAndCommit):
+        (WebCore::SQLTransactionBackend::cleanupAndTerminate):
+        (WebCore::SQLTransactionBackend::cleanupAfterTransactionErrorCallback):
+        (WebCore::SQLTransactionBackend::requestTransitToState):
+        (WebCore::SQLTransactionBackend::acquireOriginLock):
+        (WebCore::SQLTransactionBackend::releaseOriginLockIfNeeded):
+        (WebCore::SQLTransactionBackend::currentStatement): Deleted.
+        (WebCore::SQLTransactionBackend::transactionError): Deleted.
+        (WebCore::SQLTransactionBackend::setShouldRetryCurrentStatement): Deleted.
+        (WebCore::SQLTransactionBackend::enqueueStatementBackend): Deleted.
+        * Modules/webdatabase/SQLTransactionBackend.h:
+        (WebCore::SQLTransactionBackend::database): Deleted.
+        (WebCore::SQLTransactionBackend::isReadOnly): Deleted.
+        * Modules/webdatabase/SQLTransactionCoordinator.cpp:
+        (WebCore::SQLTransactionCoordinator::processPendingTransactions):
+        (WebCore::SQLTransactionCoordinator::releaseLock):
+
</ins><span class="cx"> 2016-08-10  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Sort the project file.
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseChangeVersionWrappercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.cpp (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.cpp        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.cpp        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -41,17 +41,14 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ChangeVersionWrapper::performPreflight(SQLTransactionBackend* transaction)
</del><ins>+bool ChangeVersionWrapper::performPreflight(SQLTransaction&amp; transaction)
</ins><span class="cx"> {
</span><del>-    ASSERT(transaction &amp;&amp; transaction-&gt;database());
</del><ins>+    Database&amp; database = transaction.database();
</ins><span class="cx"> 
</span><del>-    Database* database = transaction-&gt;database();
-
</del><span class="cx">     String actualVersion;
</span><del>-    if (!database-&gt;getVersionFromDatabase(actualVersion)) {
-        int sqliteError = database-&gt;sqliteDatabase().lastError();
-        m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unable to read the current version&quot;,
-                                      sqliteError, database-&gt;sqliteDatabase().lastErrorMsg());
</del><ins>+    if (!database.getVersionFromDatabase(actualVersion)) {
+        int sqliteError = database.sqliteDatabase().lastError();
+        m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unable to read the current version&quot;, sqliteError, database.sqliteDatabase().lastErrorMsg());
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -63,26 +60,23 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool ChangeVersionWrapper::performPostflight(SQLTransactionBackend* transaction)
</del><ins>+bool ChangeVersionWrapper::performPostflight(SQLTransaction&amp; transaction)
</ins><span class="cx"> {
</span><del>-    ASSERT(transaction &amp;&amp; transaction-&gt;database());
</del><ins>+    Database&amp; database = transaction.database();
</ins><span class="cx"> 
</span><del>-    Database* database = transaction-&gt;database();
-
-    if (!database-&gt;setVersionInDatabase(m_newVersion)) {
-        int sqliteError = database-&gt;sqliteDatabase().lastError();
-        m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unable to set new version in database&quot;,
-                                      sqliteError, database-&gt;sqliteDatabase().lastErrorMsg());
</del><ins>+    if (!database.setVersionInDatabase(m_newVersion)) {
+        int sqliteError = database.sqliteDatabase().lastError();
+        m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unable to set new version in database&quot;, sqliteError, database.sqliteDatabase().lastErrorMsg());
</ins><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    database-&gt;setExpectedVersion(m_newVersion);
</del><ins>+    database.setExpectedVersion(m_newVersion);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ChangeVersionWrapper::handleCommitFailedAfterPostflight(SQLTransactionBackend* transaction)
</del><ins>+void ChangeVersionWrapper::handleCommitFailedAfterPostflight(SQLTransaction&amp; transaction)
</ins><span class="cx"> {
</span><del>-    transaction-&gt;database()-&gt;setCachedVersion(m_oldVersion);
</del><ins>+    transaction.database().setCachedVersion(m_oldVersion);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseChangeVersionWrapperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.h (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.h        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/ChangeVersionWrapper.h        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -39,10 +39,10 @@
</span><span class="cx"> public:
</span><span class="cx">     static Ref&lt;ChangeVersionWrapper&gt; create(const String&amp; oldVersion, const String&amp; newVersion) { return adoptRef(*new ChangeVersionWrapper(oldVersion, newVersion)); }
</span><span class="cx"> 
</span><del>-    virtual bool performPreflight(SQLTransactionBackend*);
-    virtual bool performPostflight(SQLTransactionBackend*);
-    virtual SQLError* sqlError() const { return m_sqlError.get(); }
-    virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*);
</del><ins>+    bool performPreflight(SQLTransaction&amp;) override;
+    bool performPostflight(SQLTransaction&amp;) override;
+    SQLError* sqlError() const override { return m_sqlError.get(); };
+    void handleCommitFailedAfterPostflight(SQLTransaction&amp;) override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     ChangeVersionWrapper(const String&amp; oldVersion, const String&amp; newVersion);
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLTransactioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;DatabaseContext.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><ins>+#include &quot;OriginLock.h&quot;
</ins><span class="cx"> #include &quot;SQLError.h&quot;
</span><span class="cx"> #include &quot;SQLStatement.h&quot;
</span><span class="cx"> #include &quot;SQLStatementCallback.h&quot;
</span><span class="lines">@@ -42,6 +43,7 @@
</span><span class="cx"> #include &quot;SQLTransactionCallback.h&quot;
</span><span class="cx"> #include &quot;SQLTransactionClient.h&quot; // FIXME: Should be used in the backend only.
</span><span class="cx"> #include &quot;SQLTransactionErrorCallback.h&quot;
</span><ins>+#include &quot;SQLiteTransaction.h&quot;
</ins><span class="cx"> #include &quot;VoidCallback.h&quot;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="lines">@@ -58,9 +60,14 @@
</span><span class="cx">     , m_callbackWrapper(WTFMove(callback), m_database-&gt;scriptExecutionContext())
</span><span class="cx">     , m_successCallbackWrapper(WTFMove(successCallback), m_database-&gt;scriptExecutionContext())
</span><span class="cx">     , m_errorCallbackWrapper(WTFMove(errorCallback), m_database-&gt;scriptExecutionContext())
</span><ins>+    , m_wrapper(WTFMove(wrapper))
</ins><span class="cx">     , m_executeSqlAllowed(false)
</span><ins>+    , m_shouldRetryCurrentStatement(false)
+    , m_modifiedDatabase(false)
+    , m_lockAcquired(false)
</ins><span class="cx">     , m_readOnly(readOnly)
</span><del>-    , m_backend(m_database.ptr(), *this, WTFMove(wrapper), readOnly)
</del><ins>+    , m_hasVersionMismatch(false)
+    , m_backend(*this)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -68,21 +75,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool SQLTransaction::hasCallback() const
-{
-    return m_callbackWrapper.hasCallback();
-}
-
-bool SQLTransaction::hasSuccessCallback() const
-{
-    return m_successCallbackWrapper.hasCallback();
-}
-
-bool SQLTransaction::hasErrorCallback() const
-{
-    return m_errorCallbackWrapper.hasCallback();
-}
-
</del><span class="cx"> SQLTransaction::StateFunction SQLTransaction::stateFunctionFor(SQLTransactionState state)
</span><span class="cx"> {
</span><span class="cx">     static const StateFunction stateFunctions[] = {
</span><span class="lines">@@ -140,23 +132,14 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransaction::deliverTransactionErrorCallback()
</span><span class="cx"> {
</span><ins>+    ASSERT(m_transactionError);
+
</ins><span class="cx">     // Spec 4.3.2.10: If exists, invoke error callback with the last
</span><span class="cx">     // error to have occurred in this transaction.
</span><span class="cx">     RefPtr&lt;SQLTransactionErrorCallback&gt; errorCallback = m_errorCallbackWrapper.unwrap();
</span><del>-    if (errorCallback) {
-        // If we get here with an empty m_transactionError, then the backend
-        // must be waiting in the idle state waiting for this state to finish.
-        // Hence, it's thread safe to fetch the backend transactionError without
-        // a lock.
-        if (!m_transactionError)
-            m_transactionError = m_backend.transactionError();
-
-        ASSERT(m_transactionError);
</del><ins>+    if (errorCallback)
</ins><span class="cx">         errorCallback-&gt;handleEvent(m_transactionError.get());
</span><span class="cx"> 
</span><del>-        m_transactionError = nullptr;
-    }
-
</del><span class="cx">     clearCallbackWrappers();
</span><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.10: Rollback the transaction.
</span><span class="lines">@@ -165,15 +148,12 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransaction::deliverStatementCallback()
</span><span class="cx"> {
</span><ins>+    ASSERT(m_currentStatement);
+
</ins><span class="cx">     // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback
</span><span class="cx">     // Otherwise, continue to loop through the statement queue
</span><span class="cx">     m_executeSqlAllowed = true;
</span><del>-
-    SQLStatement* currentStatement = m_backend.currentStatement();
-    ASSERT(currentStatement);
-
-    bool result = currentStatement-&gt;performCallback(this);
-
</del><ins>+    bool result = m_currentStatement-&gt;performCallback(this);
</ins><span class="cx">     m_executeSqlAllowed = false;
</span><span class="cx"> 
</span><span class="cx">     if (result) {
</span><span class="lines">@@ -193,10 +173,10 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransaction::deliverQuotaIncreaseCallback()
</span><span class="cx"> {
</span><del>-    ASSERT(m_backend.currentStatement());
</del><ins>+    ASSERT(m_currentStatement);
+    ASSERT(!m_shouldRetryCurrentStatement);
</ins><span class="cx"> 
</span><del>-    bool shouldRetryCurrentStatement = m_database-&gt;transactionClient()-&gt;didExceedQuota(&amp;database());
-    m_backend.setShouldRetryCurrentStatement(shouldRetryCurrentStatement);
</del><ins>+    m_shouldRetryCurrentStatement = m_database-&gt;transactionClient()-&gt;didExceedQuota(&amp;database());
</ins><span class="cx"> 
</span><span class="cx">     m_backend.requestTransitToState(SQLTransactionState::RunStatements);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLTransactionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -51,10 +51,10 @@
</span><span class="cx"> class SQLTransactionWrapper : public ThreadSafeRefCounted&lt;SQLTransactionWrapper&gt; {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~SQLTransactionWrapper() { }
</span><del>-    virtual bool performPreflight(SQLTransactionBackend*) = 0;
-    virtual bool performPostflight(SQLTransactionBackend*) = 0;
</del><ins>+    virtual bool performPreflight(SQLTransaction&amp;) = 0;
+    virtual bool performPostflight(SQLTransaction&amp;) = 0;
</ins><span class="cx">     virtual SQLError* sqlError() const = 0;
</span><del>-    virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0;
</del><ins>+    virtual void handleCommitFailedAfterPostflight(SQLTransaction&amp;) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class SQLTransaction : public ThreadSafeRefCounted&lt;SQLTransaction&gt;, public SQLTransactionStateMachine&lt;SQLTransaction&gt; {
</span><span class="lines">@@ -67,15 +67,15 @@
</span><span class="cx">     void performPendingCallback();
</span><span class="cx"> 
</span><span class="cx">     Database&amp; database() { return m_database; }
</span><ins>+    bool isReadOnly() const { return m_readOnly; }
</ins><span class="cx">     SQLTransactionBackend&amp; backend() { return m_backend; }
</span><span class="cx"> 
</span><span class="cx">     // APIs called from the backend published via SQLTransaction:
</span><span class="cx">     void requestTransitToState(SQLTransactionState);
</span><del>-    bool hasCallback() const;
-    bool hasSuccessCallback() const;
-    bool hasErrorCallback() const;
</del><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class SQLTransactionBackend;
+
</ins><span class="cx">     SQLTransaction(Ref&lt;Database&gt;&amp;&amp;, RefPtr&lt;SQLTransactionCallback&gt;&amp;&amp;, RefPtr&lt;VoidCallback&gt;&amp;&amp; successCallback, RefPtr&lt;SQLTransactionErrorCallback&gt;&amp;&amp;, RefPtr&lt;SQLTransactionWrapper&gt;&amp;&amp;, bool readOnly);
</span><span class="cx"> 
</span><span class="cx">     void clearCallbackWrappers();
</span><span class="lines">@@ -98,11 +98,25 @@
</span><span class="cx">     SQLCallbackWrapper&lt;VoidCallback&gt; m_successCallbackWrapper;
</span><span class="cx">     SQLCallbackWrapper&lt;SQLTransactionErrorCallback&gt; m_errorCallbackWrapper;
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;SQLTransactionWrapper&gt; m_wrapper;
+
</ins><span class="cx">     bool m_executeSqlAllowed;
</span><span class="cx">     RefPtr&lt;SQLError&gt; m_transactionError;
</span><span class="cx"> 
</span><ins>+    bool m_shouldRetryCurrentStatement;
+    bool m_modifiedDatabase;
+    bool m_lockAcquired;
</ins><span class="cx">     bool m_readOnly;
</span><ins>+    bool m_hasVersionMismatch;
</ins><span class="cx"> 
</span><ins>+    Lock m_statementMutex;
+    Deque&lt;std::unique_ptr&lt;SQLStatement&gt;&gt; m_statementQueue;
+
+    std::unique_ptr&lt;SQLStatement&gt; m_currentStatement;
+
+    std::unique_ptr&lt;SQLiteTransaction&gt; m_sqliteTransaction;
+    RefPtr&lt;OriginLock&gt; m_originLock;
+
</ins><span class="cx">     SQLTransactionBackend m_backend;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLTransactionBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -343,49 +343,38 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-SQLTransactionBackend::SQLTransactionBackend(Database* db, SQLTransaction&amp; frontend, RefPtr&lt;SQLTransactionWrapper&gt;&amp;&amp; wrapper, bool readOnly)
</del><ins>+SQLTransactionBackend::SQLTransactionBackend(SQLTransaction&amp; frontend)
</ins><span class="cx">     : m_frontend(frontend)
</span><del>-    , m_database(db)
-    , m_wrapper(WTFMove(wrapper))
-    , m_hasCallback(m_frontend.hasCallback())
-    , m_hasSuccessCallback(m_frontend.hasSuccessCallback())
-    , m_hasErrorCallback(m_frontend.hasErrorCallback())
-    , m_shouldRetryCurrentStatement(false)
-    , m_modifiedDatabase(false)
-    , m_lockAcquired(false)
-    , m_readOnly(readOnly)
-    , m_hasVersionMismatch(false)
</del><span class="cx"> {
</span><del>-    ASSERT(m_database);
</del><span class="cx">     m_requestedState = SQLTransactionState::AcquireLock;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> SQLTransactionBackend::~SQLTransactionBackend()
</span><span class="cx"> {
</span><del>-    ASSERT(!m_sqliteTransaction);
</del><ins>+    ASSERT(!m_frontend.m_sqliteTransaction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::doCleanup()
</span><span class="cx"> {
</span><del>-    ASSERT(currentThread() == database()-&gt;databaseContext()-&gt;databaseThread()-&gt;getThreadID());
</del><ins>+    ASSERT(currentThread() == m_frontend.database().databaseContext()-&gt;databaseThread()-&gt;getThreadID());
</ins><span class="cx"> 
</span><span class="cx">     releaseOriginLockIfNeeded();
</span><span class="cx"> 
</span><del>-    LockHolder locker(m_statementMutex);
-    m_statementQueue.clear();
</del><ins>+    LockHolder locker(m_frontend.m_statementMutex);
+    m_frontend.m_statementQueue.clear();
</ins><span class="cx"> 
</span><del>-    if (m_sqliteTransaction) {
</del><ins>+    if (m_frontend.m_sqliteTransaction) {
</ins><span class="cx">         // In the event we got here because of an interruption or error (i.e. if
</span><span class="cx">         // the transaction is in progress), we should roll it back here. Clearing
</span><span class="cx">         // m_sqliteTransaction invokes SQLiteTransaction's destructor which does
</span><span class="cx">         // just that. We might as well do this unconditionally and free up its
</span><span class="cx">         // resources because we're already terminating.
</span><del>-        m_sqliteTransaction = nullptr;
</del><ins>+        m_frontend.m_sqliteTransaction = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Release the lock on this database
</span><del>-    if (m_lockAcquired)
-        m_database-&gt;transactionCoordinator()-&gt;releaseLock(m_frontend);
</del><ins>+    if (m_frontend.m_lockAcquired)
+        m_frontend.m_database-&gt;transactionCoordinator()-&gt;releaseLock(m_frontend);
</ins><span class="cx"> 
</span><span class="cx">     // Do some aggresive clean up here except for m_database.
</span><span class="cx">     //
</span><span class="lines">@@ -410,25 +399,9 @@
</span><span class="cx">     // SQLTransactionBackend is guaranteed to not destruct until the frontend
</span><span class="cx">     // is also destructing.
</span><span class="cx"> 
</span><del>-    m_wrapper = nullptr;
</del><ins>+    m_frontend.m_wrapper = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-SQLStatement* SQLTransactionBackend::currentStatement()
-{
-    return m_currentStatementBackend.get();
-}
-
-SQLError* SQLTransactionBackend::transactionError()
-{
-    return m_transactionError.get();
-}
-
-void SQLTransactionBackend::setShouldRetryCurrentStatement(bool shouldRetry)
-{
-    ASSERT(!m_shouldRetryCurrentStatement);
-    m_shouldRetryCurrentStatement = shouldRetry;
-}
-
</del><span class="cx"> SQLTransactionBackend::StateFunction SQLTransactionBackend::stateFunctionFor(SQLTransactionState state)
</span><span class="cx"> {
</span><span class="cx">     static const StateFunction stateFunctions[] = {
</span><span class="lines">@@ -453,10 +426,10 @@
</span><span class="cx">     return stateFunctions[static_cast&lt;int&gt;(state)];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SQLTransactionBackend::enqueueStatementBackend(std::unique_ptr&lt;SQLStatement&gt; statementBackend)
</del><ins>+void SQLTransactionBackend::enqueueStatement(std::unique_ptr&lt;SQLStatement&gt; statement)
</ins><span class="cx"> {
</span><del>-    LockHolder locker(m_statementMutex);
-    m_statementQueue.append(WTFMove(statementBackend));
</del><ins>+    LockHolder locker(m_frontend.m_statementMutex);
+    m_frontend.m_statementQueue.append(WTFMove(statement));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded()
</span><span class="lines">@@ -463,7 +436,7 @@
</span><span class="cx"> {
</span><span class="cx">     // Only honor the requested state transition if we're not supposed to be
</span><span class="cx">     // cleaning up and shutting down:
</span><del>-    if (m_database-&gt;opened()) {
</del><ins>+    if (m_frontend.m_database-&gt;opened()) {
</ins><span class="cx">         setStateToRequestedState();
</span><span class="cx">         ASSERT(m_nextState == SQLTransactionState::AcquireLock
</span><span class="cx">             || m_nextState == SQLTransactionState::OpenTransactionAndPreflight
</span><span class="lines">@@ -485,9 +458,9 @@
</span><span class="cx">     LOG(StorageAPI, &quot;Database was stopped or interrupted - cancelling work for this transaction&quot;);
</span><span class="cx"> 
</span><span class="cx">     // The current SQLite transaction should be stopped, as well
</span><del>-    if (m_sqliteTransaction) {
-        m_sqliteTransaction-&gt;stop();
-        m_sqliteTransaction = nullptr;
</del><ins>+    if (m_frontend.m_sqliteTransaction) {
+        m_frontend.m_sqliteTransaction-&gt;stop();
+        m_frontend.m_sqliteTransaction = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Terminate the frontend state machine. This also gets the frontend to
</span><span class="lines">@@ -505,17 +478,17 @@
</span><span class="cx">     runStateMachine();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SQLTransactionBackend::executeSQL(std::unique_ptr&lt;SQLStatement&gt; statementBackend)
</del><ins>+void SQLTransactionBackend::executeSQL(std::unique_ptr&lt;SQLStatement&gt; statement)
</ins><span class="cx"> {
</span><del>-    if (m_database-&gt;deleted())
-        statementBackend-&gt;setDatabaseDeletedError();
</del><ins>+    if (m_frontend.m_database-&gt;deleted())
+        statement-&gt;setDatabaseDeletedError();
</ins><span class="cx"> 
</span><del>-    enqueueStatementBackend(WTFMove(statementBackend));
</del><ins>+    enqueueStatement(WTFMove(statement));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown()
</span><span class="cx"> {
</span><del>-    ASSERT(currentThread() == database()-&gt;databaseContext()-&gt;databaseThread()-&gt;getThreadID());
</del><ins>+    ASSERT(currentThread() == m_frontend.m_database-&gt;databaseContext()-&gt;databaseThread()-&gt;getThreadID());
</ins><span class="cx"> 
</span><span class="cx">     // If the transaction is in progress, we should roll it back here, since this
</span><span class="cx">     // is our last opportunity to do something related to this transaction on the
</span><span class="lines">@@ -527,28 +500,28 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::acquireLock()
</span><span class="cx"> {
</span><del>-    m_database-&gt;transactionCoordinator()-&gt;acquireLock(m_frontend);
</del><ins>+    m_frontend.m_database-&gt;transactionCoordinator()-&gt;acquireLock(m_frontend);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::lockAcquired()
</span><span class="cx"> {
</span><del>-    m_lockAcquired = true;
</del><ins>+    m_frontend.m_lockAcquired = true;
</ins><span class="cx"> 
</span><span class="cx">     m_requestedState = SQLTransactionState::OpenTransactionAndPreflight;
</span><span class="cx">     ASSERT(m_requestedState != SQLTransactionState::End);
</span><del>-    m_database-&gt;scheduleTransactionStep(m_frontend);
</del><ins>+    m_frontend.m_database-&gt;scheduleTransactionStep(m_frontend);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::openTransactionAndPreflight()
</span><span class="cx"> {
</span><del>-    ASSERT(!m_database-&gt;sqliteDatabase().transactionInProgress());
-    ASSERT(m_lockAcquired);
</del><ins>+    ASSERT(!m_frontend.m_database-&gt;sqliteDatabase().transactionInProgress());
+    ASSERT(m_frontend.m_lockAcquired);
</ins><span class="cx"> 
</span><span class="cx">     LOG(StorageAPI, &quot;Opening and preflighting transaction %p&quot;, this);
</span><span class="cx"> 
</span><span class="cx">     // If the database was deleted, jump to the error callback
</span><del>-    if (m_database-&gt;deleted()) {
-        m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unable to open a transaction, because the user deleted the database&quot;);
</del><ins>+    if (m_frontend.m_database-&gt;deleted()) {
+        m_frontend.m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unable to open a transaction, because the user deleted the database&quot;);
</ins><span class="cx"> 
</span><span class="cx">         handleTransactionError();
</span><span class="cx">         return;
</span><span class="lines">@@ -555,25 +528,24 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Set the maximum usage for this transaction if this transactions is not read-only
</span><del>-    if (!m_readOnly) {
</del><ins>+    if (!m_frontend.m_readOnly) {
</ins><span class="cx">         acquireOriginLock();
</span><del>-        m_database-&gt;sqliteDatabase().setMaximumSize(m_database-&gt;maximumSize());
</del><ins>+        m_frontend.m_database-&gt;sqliteDatabase().setMaximumSize(m_frontend.m_database-&gt;maximumSize());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ASSERT(!m_sqliteTransaction);
-    m_sqliteTransaction = std::make_unique&lt;SQLiteTransaction&gt;(m_database-&gt;sqliteDatabase(), m_readOnly);
</del><ins>+    ASSERT(!m_frontend.m_sqliteTransaction);
+    m_frontend.m_sqliteTransaction = std::make_unique&lt;SQLiteTransaction&gt;(m_frontend.m_database-&gt;sqliteDatabase(), m_frontend.m_readOnly);
</ins><span class="cx"> 
</span><del>-    m_database-&gt;resetDeletes();
-    m_database-&gt;disableAuthorizer();
-    m_sqliteTransaction-&gt;begin();
-    m_database-&gt;enableAuthorizer();
</del><ins>+    m_frontend.m_database-&gt;resetDeletes();
+    m_frontend.m_database-&gt;disableAuthorizer();
+    m_frontend.m_sqliteTransaction-&gt;begin();
+    m_frontend.m_database-&gt;enableAuthorizer();
</ins><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.1+2: Open a transaction to the database, jumping to the error callback if that fails
</span><del>-    if (!m_sqliteTransaction-&gt;inProgress()) {
-        ASSERT(!m_database-&gt;sqliteDatabase().transactionInProgress());
-        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;unable to begin transaction&quot;,
-            m_database-&gt;sqliteDatabase().lastError(), m_database-&gt;sqliteDatabase().lastErrorMsg());
-        m_sqliteTransaction = nullptr;
</del><ins>+    if (!m_frontend.m_sqliteTransaction-&gt;inProgress()) {
+        ASSERT(!m_frontend.m_database-&gt;sqliteDatabase().transactionInProgress());
+        m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;unable to begin transaction&quot;, m_frontend.m_database-&gt;sqliteDatabase().lastError(), m_frontend.m_database-&gt;sqliteDatabase().lastErrorMsg());
+        m_frontend.m_sqliteTransaction = nullptr;
</ins><span class="cx"> 
</span><span class="cx">         handleTransactionError();
</span><span class="cx">         return;
</span><span class="lines">@@ -583,27 +555,26 @@
</span><span class="cx">     // In multi-process browsers, we take this opportinutiy to update the cached value for
</span><span class="cx">     // the actual version. In single-process browsers, this is just a map lookup.
</span><span class="cx">     String actualVersion;
</span><del>-    if (!m_database-&gt;getActualVersionForTransaction(actualVersion)) {
-        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;unable to read version&quot;,
-            m_database-&gt;sqliteDatabase().lastError(), m_database-&gt;sqliteDatabase().lastErrorMsg());
-        m_database-&gt;disableAuthorizer();
-        m_sqliteTransaction = nullptr;
-        m_database-&gt;enableAuthorizer();
</del><ins>+    if (!m_frontend.m_database-&gt;getActualVersionForTransaction(actualVersion)) {
+        m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;unable to read version&quot;, m_frontend.m_database-&gt;sqliteDatabase().lastError(), m_frontend.m_database-&gt;sqliteDatabase().lastErrorMsg());
+        m_frontend.m_database-&gt;disableAuthorizer();
+        m_frontend.m_sqliteTransaction = nullptr;
+        m_frontend.m_database-&gt;enableAuthorizer();
</ins><span class="cx"> 
</span><span class="cx">         handleTransactionError();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_hasVersionMismatch = !m_database-&gt;expectedVersion().isEmpty() &amp;&amp; (m_database-&gt;expectedVersion() != actualVersion);
</del><ins>+    m_frontend.m_hasVersionMismatch = !m_frontend.m_database-&gt;expectedVersion().isEmpty() &amp;&amp; (m_frontend.m_database-&gt;expectedVersion() != actualVersion);
</ins><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.3: Perform preflight steps, jumping to the error callback if they fail
</span><del>-    if (m_wrapper &amp;&amp; !m_wrapper-&gt;performPreflight(this)) {
-        m_database-&gt;disableAuthorizer();
-        m_sqliteTransaction = nullptr;
-        m_database-&gt;enableAuthorizer();
-        m_transactionError = m_wrapper-&gt;sqlError();
-        if (!m_transactionError)
-            m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unknown error occurred during transaction preflight&quot;);
</del><ins>+    if (m_frontend.m_wrapper &amp;&amp; !m_frontend.m_wrapper-&gt;performPreflight(m_frontend)) {
+        m_frontend.m_database-&gt;disableAuthorizer();
+        m_frontend.m_sqliteTransaction = nullptr;
+        m_frontend.m_database-&gt;enableAuthorizer();
+        m_frontend.m_transactionError = m_frontend.m_wrapper-&gt;sqlError();
+        if (!m_frontend.m_transactionError)
+            m_frontend.m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unknown error occurred during transaction preflight&quot;);
</ins><span class="cx"> 
</span><span class="cx">         handleTransactionError();
</span><span class="cx">         return;
</span><span class="lines">@@ -610,7 +581,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.4: Invoke the transaction callback with the new SQLTransaction object
</span><del>-    if (m_hasCallback) {
</del><ins>+    if (m_frontend.m_callbackWrapper.hasCallback()) {
</ins><span class="cx">         m_frontend.requestTransitToState(SQLTransactionState::DeliverTransactionCallback);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -621,13 +592,13 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::runStatements()
</span><span class="cx"> {
</span><del>-    ASSERT(m_lockAcquired);
</del><ins>+    ASSERT(m_frontend.m_lockAcquired);
</ins><span class="cx"> 
</span><span class="cx">     // If there is a series of statements queued up that are all successful and have no associated
</span><span class="cx">     // SQLStatementCallback objects, then we can burn through the queue
</span><span class="cx">     do {
</span><del>-        if (m_shouldRetryCurrentStatement &amp;&amp; !m_sqliteTransaction-&gt;wasRolledBackBySqlite()) {
-            m_shouldRetryCurrentStatement = false;
</del><ins>+        if (m_frontend.m_shouldRetryCurrentStatement &amp;&amp; !m_frontend.m_sqliteTransaction-&gt;wasRolledBackBySqlite()) {
+            m_frontend.m_shouldRetryCurrentStatement = false;
</ins><span class="cx">             // FIXME - Another place that needs fixing up after &lt;rdar://problem/5628468&gt; is addressed.
</span><span class="cx">             // See ::openTransactionAndPreflight() for discussion
</span><span class="cx"> 
</span><span class="lines">@@ -635,11 +606,11 @@
</span><span class="cx">             // m_shouldRetryCurrentStatement is set to true only when a statement exceeds
</span><span class="cx">             // the quota, which can happen only in a read-write transaction. Therefore, there
</span><span class="cx">             // is no need to check here if the transaction is read-write.
</span><del>-            m_database-&gt;sqliteDatabase().setMaximumSize(m_database-&gt;maximumSize());
</del><ins>+            m_frontend.m_database-&gt;sqliteDatabase().setMaximumSize(m_frontend.m_database-&gt;maximumSize());
</ins><span class="cx">         } else {
</span><span class="cx">             // If the current statement has already been run, failed due to quota constraints, and we're not retrying it,
</span><span class="cx">             // that means it ended in an error. Handle it now
</span><del>-            if (m_currentStatementBackend &amp;&amp; m_currentStatementBackend-&gt;lastExecutionFailedDueToQuota()) {
</del><ins>+            if (m_frontend.m_currentStatement &amp;&amp; m_frontend.m_currentStatement-&gt;lastExecutionFailedDueToQuota()) {
</ins><span class="cx">                 handleCurrentStatementError();
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="lines">@@ -652,38 +623,38 @@
</span><span class="cx">     // If runCurrentStatement() returned false, that means either there was no current statement to run,
</span><span class="cx">     // or the current statement requires a callback to complete. In the later case, it also scheduled
</span><span class="cx">     // the callback or performed any other additional work so we can return.
</span><del>-    if (!m_currentStatementBackend)
</del><ins>+    if (!m_frontend.m_currentStatement)
</ins><span class="cx">         postflightAndCommit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::getNextStatement()
</span><span class="cx"> {
</span><del>-    m_currentStatementBackend = nullptr;
</del><ins>+    m_frontend.m_currentStatement = nullptr;
</ins><span class="cx"> 
</span><del>-    LockHolder locker(m_statementMutex);
-    if (!m_statementQueue.isEmpty())
-        m_currentStatementBackend = m_statementQueue.takeFirst();
</del><ins>+    LockHolder locker(m_frontend.m_statementMutex);
+    if (!m_frontend.m_statementQueue.isEmpty())
+        m_frontend.m_currentStatement = m_frontend.m_statementQueue.takeFirst();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool SQLTransactionBackend::runCurrentStatement()
</span><span class="cx"> {
</span><del>-    if (!m_currentStatementBackend) {
</del><ins>+    if (!m_frontend.m_currentStatement) {
</ins><span class="cx">         // No more statements to run. So move on to the next state.
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_database-&gt;resetAuthorizer();
</del><ins>+    m_frontend.m_database-&gt;resetAuthorizer();
</ins><span class="cx"> 
</span><del>-    if (m_hasVersionMismatch)
-        m_currentStatementBackend-&gt;setVersionMismatchedError();
</del><ins>+    if (m_frontend.m_hasVersionMismatch)
+        m_frontend.m_currentStatement-&gt;setVersionMismatchedError();
</ins><span class="cx"> 
</span><del>-    if (m_currentStatementBackend-&gt;execute(*m_database)) {
-        if (m_database-&gt;lastActionChangedDatabase()) {
</del><ins>+    if (m_frontend.m_currentStatement-&gt;execute(m_frontend.m_database)) {
+        if (m_frontend.m_database-&gt;lastActionChangedDatabase()) {
</ins><span class="cx">             // Flag this transaction as having changed the database for later delegate notification
</span><del>-            m_modifiedDatabase = true;
</del><ins>+            m_frontend.m_modifiedDatabase = true;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (m_currentStatementBackend-&gt;hasStatementCallback()) {
</del><ins>+        if (m_frontend.m_currentStatement-&gt;hasStatementCallback()) {
</ins><span class="cx">             m_frontend.requestTransitToState(SQLTransactionState::DeliverStatementCallback);
</span><span class="cx">             return false;
</span><span class="cx">         }
</span><span class="lines">@@ -693,7 +664,7 @@
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_currentStatementBackend-&gt;lastExecutionFailedDueToQuota()) {
</del><ins>+    if (m_frontend.m_currentStatement-&gt;lastExecutionFailedDueToQuota()) {
</ins><span class="cx">         m_frontend.requestTransitToState(SQLTransactionState::DeliverQuotaIncreaseCallback);
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -706,14 +677,14 @@
</span><span class="cx"> {
</span><span class="cx">     // Spec 4.3.2.6.6: error - Call the statement's error callback, but if there was no error callback,
</span><span class="cx">     // or the transaction was rolled back, jump to the transaction error callback
</span><del>-    if (m_currentStatementBackend-&gt;hasStatementErrorCallback() &amp;&amp; !m_sqliteTransaction-&gt;wasRolledBackBySqlite()) {
</del><ins>+    if (m_frontend.m_currentStatement-&gt;hasStatementErrorCallback() &amp;&amp; !m_frontend.m_sqliteTransaction-&gt;wasRolledBackBySqlite()) {
</ins><span class="cx">         m_frontend.requestTransitToState(SQLTransactionState::DeliverStatementCallback);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_transactionError = m_currentStatementBackend-&gt;sqlError();
-    if (!m_transactionError)
-        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;the statement failed to execute&quot;);
</del><ins>+    m_frontend.m_transactionError = m_frontend.m_currentStatement-&gt;sqlError();
+    if (!m_frontend.m_transactionError)
+        m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;the statement failed to execute&quot;);
</ins><span class="cx"> 
</span><span class="cx">     handleTransactionError();
</span><span class="cx"> }
</span><span class="lines">@@ -720,8 +691,8 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::handleTransactionError()
</span><span class="cx"> {
</span><del>-    ASSERT(m_transactionError);
-    if (m_hasErrorCallback) {
</del><ins>+    ASSERT(m_frontend.m_transactionError);
+    if (m_frontend.m_errorCallbackWrapper.hasCallback()) {
</ins><span class="cx">         m_frontend.requestTransitToState(SQLTransactionState::DeliverTransactionErrorCallback);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -733,13 +704,13 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::postflightAndCommit()
</span><span class="cx"> {
</span><del>-    ASSERT(m_lockAcquired);
</del><ins>+    ASSERT(m_frontend.m_lockAcquired);
</ins><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.7: Perform postflight steps, jumping to the error callback if they fail.
</span><del>-    if (m_wrapper &amp;&amp; !m_wrapper-&gt;performPostflight(this)) {
-        m_transactionError = m_wrapper-&gt;sqlError();
-        if (!m_transactionError)
-            m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unknown error occurred during transaction postflight&quot;);
</del><ins>+    if (m_frontend.m_wrapper &amp;&amp; !m_frontend.m_wrapper-&gt;performPostflight(m_frontend)) {
+        m_frontend.m_transactionError = m_frontend.m_wrapper-&gt;sqlError();
+        if (!m_frontend.m_transactionError)
+            m_frontend.m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, &quot;unknown error occurred during transaction postflight&quot;);
</ins><span class="cx"> 
</span><span class="cx">         handleTransactionError();
</span><span class="cx">         return;
</span><span class="lines">@@ -746,20 +717,19 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.7: Commit the transaction, jumping to the error callback if that fails.
</span><del>-    ASSERT(m_sqliteTransaction);
</del><ins>+    ASSERT(m_frontend.m_sqliteTransaction);
</ins><span class="cx"> 
</span><del>-    m_database-&gt;disableAuthorizer();
-    m_sqliteTransaction-&gt;commit();
-    m_database-&gt;enableAuthorizer();
</del><ins>+    m_frontend.m_database-&gt;disableAuthorizer();
+    m_frontend.m_sqliteTransaction-&gt;commit();
+    m_frontend.m_database-&gt;enableAuthorizer();
</ins><span class="cx"> 
</span><span class="cx">     releaseOriginLockIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     // If the commit failed, the transaction will still be marked as &quot;in progress&quot;
</span><del>-    if (m_sqliteTransaction-&gt;inProgress()) {
-        if (m_wrapper)
-            m_wrapper-&gt;handleCommitFailedAfterPostflight(this);
-        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;unable to commit transaction&quot;,
-            m_database-&gt;sqliteDatabase().lastError(), m_database-&gt;sqliteDatabase().lastErrorMsg());
</del><ins>+    if (m_frontend.m_sqliteTransaction-&gt;inProgress()) {
+        if (m_frontend.m_wrapper)
+            m_frontend.m_wrapper-&gt;handleCommitFailedAfterPostflight(m_frontend);
+        m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, &quot;unable to commit transaction&quot;, m_frontend.m_database-&gt;sqliteDatabase().lastError(), m_frontend.m_database-&gt;sqliteDatabase().lastErrorMsg());
</ins><span class="cx"> 
</span><span class="cx">         handleTransactionError();
</span><span class="cx">         return;
</span><span class="lines">@@ -766,12 +736,12 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Vacuum the database if anything was deleted.
</span><del>-    if (m_database-&gt;hadDeletes())
-        m_database-&gt;incrementalVacuumIfNeeded();
</del><ins>+    if (m_frontend.m_database-&gt;hadDeletes())
+        m_frontend.m_database-&gt;incrementalVacuumIfNeeded();
</ins><span class="cx"> 
</span><span class="cx">     // The commit was successful. If the transaction modified this database, notify the delegates.
</span><del>-    if (m_modifiedDatabase)
-        m_database-&gt;transactionClient()-&gt;didCommitWriteTransaction(database());
</del><ins>+    if (m_frontend.m_modifiedDatabase)
+        m_frontend.m_database-&gt;transactionClient()-&gt;didCommitWriteTransaction(m_frontend.m_database.ptr());
</ins><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.8: Deliver success callback, if there is one.
</span><span class="cx">     m_frontend.requestTransitToState(SQLTransactionState::DeliverSuccessCallback);
</span><span class="lines">@@ -779,35 +749,35 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::cleanupAndTerminate()
</span><span class="cx"> {
</span><del>-    ASSERT(m_lockAcquired);
</del><ins>+    ASSERT(m_frontend.m_lockAcquired);
</ins><span class="cx"> 
</span><span class="cx">     // Spec 4.3.2.9: End transaction steps. There is no next step.
</span><span class="cx">     LOG(StorageAPI, &quot;Transaction %p is complete\n&quot;, this);
</span><del>-    ASSERT(!m_database-&gt;sqliteDatabase().transactionInProgress());
</del><ins>+    ASSERT(!m_frontend.m_database-&gt;sqliteDatabase().transactionInProgress());
</ins><span class="cx"> 
</span><span class="cx">     // Phase 5 cleanup. See comment on the SQLTransaction life-cycle above.
</span><span class="cx">     doCleanup();
</span><del>-    m_database-&gt;inProgressTransactionCompleted();
</del><ins>+    m_frontend.m_database-&gt;inProgressTransactionCompleted();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::cleanupAfterTransactionErrorCallback()
</span><span class="cx"> {
</span><del>-    ASSERT(m_lockAcquired);
</del><ins>+    ASSERT(m_frontend.m_lockAcquired);
</ins><span class="cx"> 
</span><span class="cx">     LOG(StorageAPI, &quot;Transaction %p is complete with an error\n&quot;, this);
</span><del>-    m_database-&gt;disableAuthorizer();
-    if (m_sqliteTransaction) {
</del><ins>+    m_frontend.m_database-&gt;disableAuthorizer();
+    if (m_frontend.m_sqliteTransaction) {
</ins><span class="cx">         // Spec 4.3.2.10: Rollback the transaction.
</span><del>-        m_sqliteTransaction-&gt;rollback();
</del><ins>+        m_frontend.m_sqliteTransaction-&gt;rollback();
</ins><span class="cx"> 
</span><del>-        ASSERT(!m_database-&gt;sqliteDatabase().transactionInProgress());
-        m_sqliteTransaction = nullptr;
</del><ins>+        ASSERT(!m_frontend.m_database-&gt;sqliteDatabase().transactionInProgress());
+        m_frontend.m_sqliteTransaction = nullptr;
</ins><span class="cx">     }
</span><del>-    m_database-&gt;enableAuthorizer();
</del><ins>+    m_frontend.m_database-&gt;enableAuthorizer();
</ins><span class="cx"> 
</span><span class="cx">     releaseOriginLockIfNeeded();
</span><span class="cx"> 
</span><del>-    ASSERT(!m_database-&gt;sqliteDatabase().transactionInProgress());
</del><ins>+    ASSERT(!m_frontend.m_database-&gt;sqliteDatabase().transactionInProgress());
</ins><span class="cx"> 
</span><span class="cx">     cleanupAndTerminate();
</span><span class="cx"> }
</span><span class="lines">@@ -820,7 +790,7 @@
</span><span class="cx">     LOG(StorageAPI, &quot;Scheduling %s for transaction %p\n&quot;, nameForSQLTransactionState(nextState), this);
</span><span class="cx">     m_requestedState = nextState;
</span><span class="cx">     ASSERT(m_requestedState != SQLTransactionState::End);
</span><del>-    m_database-&gt;scheduleTransactionStep(m_frontend);
</del><ins>+    m_frontend.m_database-&gt;scheduleTransactionStep(m_frontend);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // This state function is used as a stub function to plug unimplemented states
</span><span class="lines">@@ -833,16 +803,16 @@
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::acquireOriginLock()
</span><span class="cx"> {
</span><del>-    ASSERT(!m_originLock);
-    m_originLock = DatabaseTracker::tracker().originLockFor(m_database-&gt;securityOrigin());
-    m_originLock-&gt;lock();
</del><ins>+    ASSERT(!m_frontend.m_originLock);
+    m_frontend.m_originLock = DatabaseTracker::tracker().originLockFor(m_frontend.m_database-&gt;securityOrigin());
+    m_frontend.m_originLock-&gt;lock();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SQLTransactionBackend::releaseOriginLockIfNeeded()
</span><span class="cx"> {
</span><del>-    if (m_originLock) {
-        m_originLock-&gt;unlock();
-        m_originLock = nullptr;
</del><ins>+    if (m_frontend.m_originLock) {
+        m_frontend.m_originLock-&gt;unlock();
+        m_frontend.m_originLock = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLTransactionBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -49,21 +49,16 @@
</span><span class="cx"> 
</span><span class="cx"> class SQLTransactionBackend : public SQLTransactionStateMachine&lt;SQLTransactionBackend&gt; {
</span><span class="cx"> public:
</span><del>-    SQLTransactionBackend(Database*, SQLTransaction&amp;, RefPtr&lt;SQLTransactionWrapper&gt;&amp;&amp;, bool readOnly);
</del><ins>+    explicit SQLTransactionBackend(SQLTransaction&amp;);
</ins><span class="cx">     ~SQLTransactionBackend();
</span><span class="cx"> 
</span><span class="cx">     void lockAcquired();
</span><span class="cx">     void performNextStep();
</span><span class="cx"> 
</span><del>-    Database* database() { return m_database.get(); }
-    bool isReadOnly() { return m_readOnly; }
</del><span class="cx">     void notifyDatabaseThreadIsShuttingDown();
</span><span class="cx"> 
</span><span class="cx">     // APIs called from the frontend published via SQLTransactionBackend:
</span><span class="cx">     void requestTransitToState(SQLTransactionState);
</span><del>-    SQLError* transactionError();
-    SQLStatement* currentStatement();
-    void setShouldRetryCurrentStatement(bool);
</del><span class="cx">     void executeSQL(std::unique_ptr&lt;SQLStatement&gt;);
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="lines">@@ -70,7 +65,7 @@
</span><span class="cx"> 
</span><span class="cx">     void doCleanup();
</span><span class="cx"> 
</span><del>-    void enqueueStatementBackend(std::unique_ptr&lt;SQLStatement&gt;);
</del><ins>+    void enqueueStatement(std::unique_ptr&lt;SQLStatement&gt;);
</ins><span class="cx"> 
</span><span class="cx">     // State Machine functions:
</span><span class="cx">     StateFunction stateFunctionFor(SQLTransactionState) override;
</span><span class="lines">@@ -95,26 +90,6 @@
</span><span class="cx">     void releaseOriginLockIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     SQLTransaction&amp; m_frontend;
</span><del>-    std::unique_ptr&lt;SQLStatement&gt; m_currentStatementBackend;
-
-    RefPtr&lt;Database&gt; m_database;
-    RefPtr&lt;SQLTransactionWrapper&gt; m_wrapper;
-    RefPtr&lt;SQLError&gt; m_transactionError;
-
-    bool m_hasCallback;
-    bool m_hasSuccessCallback;
-    bool m_hasErrorCallback;
-    bool m_shouldRetryCurrentStatement;
-    bool m_modifiedDatabase;
-    bool m_lockAcquired;
-    bool m_readOnly;
-    bool m_hasVersionMismatch;
-
-    Lock m_statementMutex;
-    Deque&lt;std::unique_ptr&lt;SQLStatement&gt;&gt; m_statementQueue;
-
-    std::unique_ptr&lt;SQLiteTransaction&gt; m_sqliteTransaction;
-    RefPtr&lt;OriginLock&gt; m_originLock;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebdatabaseSQLTransactionCoordinatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionCoordinator.cpp (204348 => 204349)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionCoordinator.cpp        2016-08-10 20:25:44 UTC (rev 204348)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionCoordinator.cpp        2016-08-10 20:30:14 UTC (rev 204349)
</span><span class="lines">@@ -58,12 +58,12 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;SQLTransaction&gt; firstPendingTransaction = info.pendingTransactions.first();
</span><del>-    if (firstPendingTransaction-&gt;backend().isReadOnly()) {
</del><ins>+    if (firstPendingTransaction-&gt;isReadOnly()) {
</ins><span class="cx">         do {
</span><span class="cx">             firstPendingTransaction = info.pendingTransactions.takeFirst();
</span><span class="cx">             info.activeReadTransactions.add(firstPendingTransaction);
</span><span class="cx">             firstPendingTransaction-&gt;backend().lockAcquired();
</span><del>-        } while (!info.pendingTransactions.isEmpty() &amp;&amp; info.pendingTransactions.first()-&gt;backend().isReadOnly());
</del><ins>+        } while (!info.pendingTransactions.isEmpty() &amp;&amp; info.pendingTransactions.first()-&gt;isReadOnly());
</ins><span class="cx">     } else if (info.activeReadTransactions.isEmpty()) {
</span><span class="cx">         info.pendingTransactions.removeFirst();
</span><span class="cx">         info.activeWriteTransaction = firstPendingTransaction;
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx">     ASSERT(coordinationInfoIterator != m_coordinationInfoMap.end());
</span><span class="cx">     CoordinationInfo&amp; info = coordinationInfoIterator-&gt;value;
</span><span class="cx"> 
</span><del>-    if (transaction.backend().isReadOnly()) {
</del><ins>+    if (transaction.isReadOnly()) {
</ins><span class="cx">         ASSERT(info.activeReadTransactions.contains(&amp;transaction));
</span><span class="cx">         info.activeReadTransactions.remove(&amp;transaction);
</span><span class="cx">     } else {
</span></span></pre>
</div>
</div>

</body>
</html>