<!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 <andersca@apple.com>
+
+ 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 <simon.fraser@apple.com>
</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& transaction)
</ins><span class="cx"> {
</span><del>- ASSERT(transaction && transaction->database());
</del><ins>+ Database& database = transaction.database();
</ins><span class="cx">
</span><del>- Database* database = transaction->database();
-
</del><span class="cx"> String actualVersion;
</span><del>- if (!database->getVersionFromDatabase(actualVersion)) {
- int sqliteError = database->sqliteDatabase().lastError();
- m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to read the current version",
- sqliteError, database->sqliteDatabase().lastErrorMsg());
</del><ins>+ if (!database.getVersionFromDatabase(actualVersion)) {
+ int sqliteError = database.sqliteDatabase().lastError();
+ m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to read the current version", 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& transaction)
</ins><span class="cx"> {
</span><del>- ASSERT(transaction && transaction->database());
</del><ins>+ Database& database = transaction.database();
</ins><span class="cx">
</span><del>- Database* database = transaction->database();
-
- if (!database->setVersionInDatabase(m_newVersion)) {
- int sqliteError = database->sqliteDatabase().lastError();
- m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to set new version in database",
- sqliteError, database->sqliteDatabase().lastErrorMsg());
</del><ins>+ if (!database.setVersionInDatabase(m_newVersion)) {
+ int sqliteError = database.sqliteDatabase().lastError();
+ m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to set new version in database", sqliteError, database.sqliteDatabase().lastErrorMsg());
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- database->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& transaction)
</ins><span class="cx"> {
</span><del>- transaction->database()->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<ChangeVersionWrapper> create(const String& oldVersion, const String& 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&) override;
+ bool performPostflight(SQLTransaction&) override;
+ SQLError* sqlError() const override { return m_sqlError.get(); };
+ void handleCommitFailedAfterPostflight(SQLTransaction&) override;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> ChangeVersionWrapper(const String& oldVersion, const String& 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 "DatabaseContext.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx"> #include "Logging.h"
</span><ins>+#include "OriginLock.h"
</ins><span class="cx"> #include "SQLError.h"
</span><span class="cx"> #include "SQLStatement.h"
</span><span class="cx"> #include "SQLStatementCallback.h"
</span><span class="lines">@@ -42,6 +43,7 @@
</span><span class="cx"> #include "SQLTransactionCallback.h"
</span><span class="cx"> #include "SQLTransactionClient.h" // FIXME: Should be used in the backend only.
</span><span class="cx"> #include "SQLTransactionErrorCallback.h"
</span><ins>+#include "SQLiteTransaction.h"
</ins><span class="cx"> #include "VoidCallback.h"
</span><span class="cx"> #include <wtf/StdLibExtras.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="lines">@@ -58,9 +60,14 @@
</span><span class="cx"> , m_callbackWrapper(WTFMove(callback), m_database->scriptExecutionContext())
</span><span class="cx"> , m_successCallbackWrapper(WTFMove(successCallback), m_database->scriptExecutionContext())
</span><span class="cx"> , m_errorCallbackWrapper(WTFMove(errorCallback), m_database->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<SQLTransactionErrorCallback> 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->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->performCallback(this);
-
</del><ins>+ bool result = m_currentStatement->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->transactionClient()->didExceedQuota(&database());
- m_backend.setShouldRetryCurrentStatement(shouldRetryCurrentStatement);
</del><ins>+ m_shouldRetryCurrentStatement = m_database->transactionClient()->didExceedQuota(&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<SQLTransactionWrapper> {
</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&) = 0;
+ virtual bool performPostflight(SQLTransaction&) = 0;
</ins><span class="cx"> virtual SQLError* sqlError() const = 0;
</span><del>- virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0;
</del><ins>+ virtual void handleCommitFailedAfterPostflight(SQLTransaction&) = 0;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class SQLTransaction : public ThreadSafeRefCounted<SQLTransaction>, public SQLTransactionStateMachine<SQLTransaction> {
</span><span class="lines">@@ -67,15 +67,15 @@
</span><span class="cx"> void performPendingCallback();
</span><span class="cx">
</span><span class="cx"> Database& database() { return m_database; }
</span><ins>+ bool isReadOnly() const { return m_readOnly; }
</ins><span class="cx"> SQLTransactionBackend& 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<Database>&&, RefPtr<SQLTransactionCallback>&&, RefPtr<VoidCallback>&& successCallback, RefPtr<SQLTransactionErrorCallback>&&, RefPtr<SQLTransactionWrapper>&&, 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<VoidCallback> m_successCallbackWrapper;
</span><span class="cx"> SQLCallbackWrapper<SQLTransactionErrorCallback> m_errorCallbackWrapper;
</span><span class="cx">
</span><ins>+ RefPtr<SQLTransactionWrapper> m_wrapper;
+
</ins><span class="cx"> bool m_executeSqlAllowed;
</span><span class="cx"> RefPtr<SQLError> 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<std::unique_ptr<SQLStatement>> m_statementQueue;
+
+ std::unique_ptr<SQLStatement> m_currentStatement;
+
+ std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
+ RefPtr<OriginLock> 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& frontend, RefPtr<SQLTransactionWrapper>&& wrapper, bool readOnly)
</del><ins>+SQLTransactionBackend::SQLTransactionBackend(SQLTransaction& 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()->databaseContext()->databaseThread()->getThreadID());
</del><ins>+ ASSERT(currentThread() == m_frontend.database().databaseContext()->databaseThread()->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->transactionCoordinator()->releaseLock(m_frontend);
</del><ins>+ if (m_frontend.m_lockAcquired)
+ m_frontend.m_database->transactionCoordinator()->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<int>(state)];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void SQLTransactionBackend::enqueueStatementBackend(std::unique_ptr<SQLStatement> statementBackend)
</del><ins>+void SQLTransactionBackend::enqueueStatement(std::unique_ptr<SQLStatement> 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->opened()) {
</del><ins>+ if (m_frontend.m_database->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, "Database was stopped or interrupted - cancelling work for this transaction");
</span><span class="cx">
</span><span class="cx"> // The current SQLite transaction should be stopped, as well
</span><del>- if (m_sqliteTransaction) {
- m_sqliteTransaction->stop();
- m_sqliteTransaction = nullptr;
</del><ins>+ if (m_frontend.m_sqliteTransaction) {
+ m_frontend.m_sqliteTransaction->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<SQLStatement> statementBackend)
</del><ins>+void SQLTransactionBackend::executeSQL(std::unique_ptr<SQLStatement> statement)
</ins><span class="cx"> {
</span><del>- if (m_database->deleted())
- statementBackend->setDatabaseDeletedError();
</del><ins>+ if (m_frontend.m_database->deleted())
+ statement->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()->databaseContext()->databaseThread()->getThreadID());
</del><ins>+ ASSERT(currentThread() == m_frontend.m_database->databaseContext()->databaseThread()->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->transactionCoordinator()->acquireLock(m_frontend);
</del><ins>+ m_frontend.m_database->transactionCoordinator()->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->scheduleTransactionStep(m_frontend);
</del><ins>+ m_frontend.m_database->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->sqliteDatabase().transactionInProgress());
- ASSERT(m_lockAcquired);
</del><ins>+ ASSERT(!m_frontend.m_database->sqliteDatabase().transactionInProgress());
+ ASSERT(m_frontend.m_lockAcquired);
</ins><span class="cx">
</span><span class="cx"> LOG(StorageAPI, "Opening and preflighting transaction %p", this);
</span><span class="cx">
</span><span class="cx"> // If the database was deleted, jump to the error callback
</span><del>- if (m_database->deleted()) {
- m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to open a transaction, because the user deleted the database");
</del><ins>+ if (m_frontend.m_database->deleted()) {
+ m_frontend.m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to open a transaction, because the user deleted the database");
</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->sqliteDatabase().setMaximumSize(m_database->maximumSize());
</del><ins>+ m_frontend.m_database->sqliteDatabase().setMaximumSize(m_frontend.m_database->maximumSize());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- ASSERT(!m_sqliteTransaction);
- m_sqliteTransaction = std::make_unique<SQLiteTransaction>(m_database->sqliteDatabase(), m_readOnly);
</del><ins>+ ASSERT(!m_frontend.m_sqliteTransaction);
+ m_frontend.m_sqliteTransaction = std::make_unique<SQLiteTransaction>(m_frontend.m_database->sqliteDatabase(), m_frontend.m_readOnly);
</ins><span class="cx">
</span><del>- m_database->resetDeletes();
- m_database->disableAuthorizer();
- m_sqliteTransaction->begin();
- m_database->enableAuthorizer();
</del><ins>+ m_frontend.m_database->resetDeletes();
+ m_frontend.m_database->disableAuthorizer();
+ m_frontend.m_sqliteTransaction->begin();
+ m_frontend.m_database->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->inProgress()) {
- ASSERT(!m_database->sqliteDatabase().transactionInProgress());
- m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to begin transaction",
- m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
- m_sqliteTransaction = nullptr;
</del><ins>+ if (!m_frontend.m_sqliteTransaction->inProgress()) {
+ ASSERT(!m_frontend.m_database->sqliteDatabase().transactionInProgress());
+ m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to begin transaction", m_frontend.m_database->sqliteDatabase().lastError(), m_frontend.m_database->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->getActualVersionForTransaction(actualVersion)) {
- m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to read version",
- m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
- m_database->disableAuthorizer();
- m_sqliteTransaction = nullptr;
- m_database->enableAuthorizer();
</del><ins>+ if (!m_frontend.m_database->getActualVersionForTransaction(actualVersion)) {
+ m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to read version", m_frontend.m_database->sqliteDatabase().lastError(), m_frontend.m_database->sqliteDatabase().lastErrorMsg());
+ m_frontend.m_database->disableAuthorizer();
+ m_frontend.m_sqliteTransaction = nullptr;
+ m_frontend.m_database->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->expectedVersion().isEmpty() && (m_database->expectedVersion() != actualVersion);
</del><ins>+ m_frontend.m_hasVersionMismatch = !m_frontend.m_database->expectedVersion().isEmpty() && (m_frontend.m_database->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 && !m_wrapper->performPreflight(this)) {
- m_database->disableAuthorizer();
- m_sqliteTransaction = nullptr;
- m_database->enableAuthorizer();
- m_transactionError = m_wrapper->sqlError();
- if (!m_transactionError)
- m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction preflight");
</del><ins>+ if (m_frontend.m_wrapper && !m_frontend.m_wrapper->performPreflight(m_frontend)) {
+ m_frontend.m_database->disableAuthorizer();
+ m_frontend.m_sqliteTransaction = nullptr;
+ m_frontend.m_database->enableAuthorizer();
+ m_frontend.m_transactionError = m_frontend.m_wrapper->sqlError();
+ if (!m_frontend.m_transactionError)
+ m_frontend.m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction preflight");
</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 && !m_sqliteTransaction->wasRolledBackBySqlite()) {
- m_shouldRetryCurrentStatement = false;
</del><ins>+ if (m_frontend.m_shouldRetryCurrentStatement && !m_frontend.m_sqliteTransaction->wasRolledBackBySqlite()) {
+ m_frontend.m_shouldRetryCurrentStatement = false;
</ins><span class="cx"> // FIXME - Another place that needs fixing up after <rdar://problem/5628468> 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->sqliteDatabase().setMaximumSize(m_database->maximumSize());
</del><ins>+ m_frontend.m_database->sqliteDatabase().setMaximumSize(m_frontend.m_database->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 && m_currentStatementBackend->lastExecutionFailedDueToQuota()) {
</del><ins>+ if (m_frontend.m_currentStatement && m_frontend.m_currentStatement->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->resetAuthorizer();
</del><ins>+ m_frontend.m_database->resetAuthorizer();
</ins><span class="cx">
</span><del>- if (m_hasVersionMismatch)
- m_currentStatementBackend->setVersionMismatchedError();
</del><ins>+ if (m_frontend.m_hasVersionMismatch)
+ m_frontend.m_currentStatement->setVersionMismatchedError();
</ins><span class="cx">
</span><del>- if (m_currentStatementBackend->execute(*m_database)) {
- if (m_database->lastActionChangedDatabase()) {
</del><ins>+ if (m_frontend.m_currentStatement->execute(m_frontend.m_database)) {
+ if (m_frontend.m_database->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->hasStatementCallback()) {
</del><ins>+ if (m_frontend.m_currentStatement->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->lastExecutionFailedDueToQuota()) {
</del><ins>+ if (m_frontend.m_currentStatement->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->hasStatementErrorCallback() && !m_sqliteTransaction->wasRolledBackBySqlite()) {
</del><ins>+ if (m_frontend.m_currentStatement->hasStatementErrorCallback() && !m_frontend.m_sqliteTransaction->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->sqlError();
- if (!m_transactionError)
- m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "the statement failed to execute");
</del><ins>+ m_frontend.m_transactionError = m_frontend.m_currentStatement->sqlError();
+ if (!m_frontend.m_transactionError)
+ m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "the statement failed to execute");
</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 && !m_wrapper->performPostflight(this)) {
- m_transactionError = m_wrapper->sqlError();
- if (!m_transactionError)
- m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction postflight");
</del><ins>+ if (m_frontend.m_wrapper && !m_frontend.m_wrapper->performPostflight(m_frontend)) {
+ m_frontend.m_transactionError = m_frontend.m_wrapper->sqlError();
+ if (!m_frontend.m_transactionError)
+ m_frontend.m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction postflight");
</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->disableAuthorizer();
- m_sqliteTransaction->commit();
- m_database->enableAuthorizer();
</del><ins>+ m_frontend.m_database->disableAuthorizer();
+ m_frontend.m_sqliteTransaction->commit();
+ m_frontend.m_database->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 "in progress"
</span><del>- if (m_sqliteTransaction->inProgress()) {
- if (m_wrapper)
- m_wrapper->handleCommitFailedAfterPostflight(this);
- m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to commit transaction",
- m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg());
</del><ins>+ if (m_frontend.m_sqliteTransaction->inProgress()) {
+ if (m_frontend.m_wrapper)
+ m_frontend.m_wrapper->handleCommitFailedAfterPostflight(m_frontend);
+ m_frontend.m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to commit transaction", m_frontend.m_database->sqliteDatabase().lastError(), m_frontend.m_database->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->hadDeletes())
- m_database->incrementalVacuumIfNeeded();
</del><ins>+ if (m_frontend.m_database->hadDeletes())
+ m_frontend.m_database->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->transactionClient()->didCommitWriteTransaction(database());
</del><ins>+ if (m_frontend.m_modifiedDatabase)
+ m_frontend.m_database->transactionClient()->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, "Transaction %p is complete\n", this);
</span><del>- ASSERT(!m_database->sqliteDatabase().transactionInProgress());
</del><ins>+ ASSERT(!m_frontend.m_database->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->inProgressTransactionCompleted();
</del><ins>+ m_frontend.m_database->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, "Transaction %p is complete with an error\n", this);
</span><del>- m_database->disableAuthorizer();
- if (m_sqliteTransaction) {
</del><ins>+ m_frontend.m_database->disableAuthorizer();
+ if (m_frontend.m_sqliteTransaction) {
</ins><span class="cx"> // Spec 4.3.2.10: Rollback the transaction.
</span><del>- m_sqliteTransaction->rollback();
</del><ins>+ m_frontend.m_sqliteTransaction->rollback();
</ins><span class="cx">
</span><del>- ASSERT(!m_database->sqliteDatabase().transactionInProgress());
- m_sqliteTransaction = nullptr;
</del><ins>+ ASSERT(!m_frontend.m_database->sqliteDatabase().transactionInProgress());
+ m_frontend.m_sqliteTransaction = nullptr;
</ins><span class="cx"> }
</span><del>- m_database->enableAuthorizer();
</del><ins>+ m_frontend.m_database->enableAuthorizer();
</ins><span class="cx">
</span><span class="cx"> releaseOriginLockIfNeeded();
</span><span class="cx">
</span><del>- ASSERT(!m_database->sqliteDatabase().transactionInProgress());
</del><ins>+ ASSERT(!m_frontend.m_database->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, "Scheduling %s for transaction %p\n", nameForSQLTransactionState(nextState), this);
</span><span class="cx"> m_requestedState = nextState;
</span><span class="cx"> ASSERT(m_requestedState != SQLTransactionState::End);
</span><del>- m_database->scheduleTransactionStep(m_frontend);
</del><ins>+ m_frontend.m_database->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->securityOrigin());
- m_originLock->lock();
</del><ins>+ ASSERT(!m_frontend.m_originLock);
+ m_frontend.m_originLock = DatabaseTracker::tracker().originLockFor(m_frontend.m_database->securityOrigin());
+ m_frontend.m_originLock->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->unlock();
- m_originLock = nullptr;
</del><ins>+ if (m_frontend.m_originLock) {
+ m_frontend.m_originLock->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<SQLTransactionBackend> {
</span><span class="cx"> public:
</span><del>- SQLTransactionBackend(Database*, SQLTransaction&, RefPtr<SQLTransactionWrapper>&&, bool readOnly);
</del><ins>+ explicit SQLTransactionBackend(SQLTransaction&);
</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<SQLStatement>);
</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<SQLStatement>);
</del><ins>+ void enqueueStatement(std::unique_ptr<SQLStatement>);
</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& m_frontend;
</span><del>- std::unique_ptr<SQLStatement> m_currentStatementBackend;
-
- RefPtr<Database> m_database;
- RefPtr<SQLTransactionWrapper> m_wrapper;
- RefPtr<SQLError> 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<std::unique_ptr<SQLStatement>> m_statementQueue;
-
- std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
- RefPtr<OriginLock> 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<SQLTransaction> firstPendingTransaction = info.pendingTransactions.first();
</span><del>- if (firstPendingTransaction->backend().isReadOnly()) {
</del><ins>+ if (firstPendingTransaction->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->backend().lockAcquired();
</span><del>- } while (!info.pendingTransactions.isEmpty() && info.pendingTransactions.first()->backend().isReadOnly());
</del><ins>+ } while (!info.pendingTransactions.isEmpty() && info.pendingTransactions.first()->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& info = coordinationInfoIterator->value;
</span><span class="cx">
</span><del>- if (transaction.backend().isReadOnly()) {
</del><ins>+ if (transaction.isReadOnly()) {
</ins><span class="cx"> ASSERT(info.activeReadTransactions.contains(&transaction));
</span><span class="cx"> info.activeReadTransactions.remove(&transaction);
</span><span class="cx"> } else {
</span></span></pre>
</div>
</div>
</body>
</html>