Title: [143489] trunk/Source/WebCore
Revision
143489
Author
mark....@apple.com
Date
2013-02-20 13:10:18 -0800 (Wed, 20 Feb 2013)

Log Message

Cleanup the SQLTransaction and SQLTransactionBackend state dispatch
to only honor a state transition request if the associated database
hasn't been interrupted.
https://bugs.webkit.org/show_bug.cgi?id=110247.

Reviewed by Antti Koivisto.

No new tests.

* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::performPendingCallback):
(WebCore::SQLTransaction::computeNextStateAndCleanupIfNeeded):
* Modules/webdatabase/SQLTransaction.h:
* Modules/webdatabase/SQLTransactionBackend.cpp:
(WebCore::SQLTransactionBackend::computeNextStateAndCleanupIfNeeded):
(WebCore::SQLTransactionBackend::performNextStep):
* Modules/webdatabase/SQLTransactionBackend.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143488 => 143489)


--- trunk/Source/WebCore/ChangeLog	2013-02-20 21:09:16 UTC (rev 143488)
+++ trunk/Source/WebCore/ChangeLog	2013-02-20 21:10:18 UTC (rev 143489)
@@ -1,3 +1,23 @@
+2013-02-20  Mark Lam  <mark....@apple.com>
+
+        Cleanup the SQLTransaction and SQLTransactionBackend state dispatch
+        to only honor a state transition request if the associated database
+        hasn't been interrupted.
+        https://bugs.webkit.org/show_bug.cgi?id=110247.
+
+        Reviewed by Antti Koivisto.
+
+        No new tests.
+
+        * Modules/webdatabase/SQLTransaction.cpp:
+        (WebCore::SQLTransaction::performPendingCallback):
+        (WebCore::SQLTransaction::computeNextStateAndCleanupIfNeeded):
+        * Modules/webdatabase/SQLTransaction.h:
+        * Modules/webdatabase/SQLTransactionBackend.cpp:
+        (WebCore::SQLTransactionBackend::computeNextStateAndCleanupIfNeeded):
+        (WebCore::SQLTransactionBackend::performNextStep):
+        * Modules/webdatabase/SQLTransactionBackend.h:
+
 2013-02-20  Alexey Proskuryakov  <a...@apple.com>
 
         ResourceHandle::loadResourceSynchronously should have blob support in cross-platform code

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp (143488 => 143489)


--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp	2013-02-20 21:09:16 UTC (rev 143488)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp	2013-02-20 21:10:18 UTC (rev 143489)
@@ -247,17 +247,7 @@
 
 void SQLTransaction::performPendingCallback()
 {
-    LOG(StorageAPI, "Callback %s\n", nameForSQLTransactionState(m_nextState));
-
-    setStateToRequestedState();
-    ASSERT(m_nextState == SQLTransactionState::End
-        || m_nextState == SQLTransactionState::DeliverTransactionCallback
-        || m_nextState == SQLTransactionState::DeliverTransactionErrorCallback
-        || m_nextState == SQLTransactionState::DeliverStatementCallback
-        || m_nextState == SQLTransactionState::DeliverQuotaIncreaseCallback
-        || m_nextState == SQLTransactionState::DeliverSuccessCallback);
-
-    checkAndHandleClosedOrInterruptedDatabase();
+    computeNextStateAndCleanupIfNeeded();
     runStateMachine();
 }
 
@@ -278,10 +268,22 @@
     m_backend->executeSQL(statement.release(), sqlStatement, arguments, permissions);
 }
 
-bool SQLTransaction::checkAndHandleClosedOrInterruptedDatabase()
+bool SQLTransaction::computeNextStateAndCleanupIfNeeded()
 {
-    if (m_database->opened() && !m_database->isInterrupted())
+    // Only honor the requested state transition if we're not supposed to be
+    // cleaning up and shutting down:
+    if (m_database->opened() && !m_database->isInterrupted()) {
+        setStateToRequestedState();
+        ASSERT(m_nextState == SQLTransactionState::End
+            || m_nextState == SQLTransactionState::DeliverTransactionCallback
+            || m_nextState == SQLTransactionState::DeliverTransactionErrorCallback
+            || m_nextState == SQLTransactionState::DeliverStatementCallback
+            || m_nextState == SQLTransactionState::DeliverQuotaIncreaseCallback
+            || m_nextState == SQLTransactionState::DeliverSuccessCallback);
+
+        LOG(StorageAPI, "Callback %s\n", nameForSQLTransactionState(m_nextState));
         return false;
+    }
 
     clearCallbackWrappers();
     m_nextState = SQLTransactionState::CleanupAndTerminate;

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h (143488 => 143489)


--- trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h	2013-02-20 21:09:16 UTC (rev 143488)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h	2013-02-20 21:10:18 UTC (rev 143489)
@@ -68,7 +68,6 @@
         PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCallback>,
         bool readOnly);
 
-    bool checkAndHandleClosedOrInterruptedDatabase();
     void clearCallbackWrappers();
 
     // APIs called from the backend published via AbstractSQLTransaction:
@@ -80,6 +79,7 @@
 
     // State Machine functions:
     virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
+    bool computeNextStateAndCleanupIfNeeded();
 
     // State functions:
     SQLTransactionState deliverTransactionCallback();

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp (143488 => 143489)


--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp	2013-02-20 21:09:16 UTC (rev 143488)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp	2013-02-20 21:10:18 UTC (rev 143489)
@@ -465,11 +465,27 @@
     m_statementQueue.append(statementBackend);
 }
 
-void SQLTransactionBackend::checkAndHandleClosedOrInterruptedDatabase()
+void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded()
 {
-    if (m_database->opened() && !m_database->isInterrupted())
+    // Only honor the requested state transition if we're not supposed to be
+    // cleaning up and shutting down:
+    if (m_database->opened() && !m_database->isInterrupted()) {
+        setStateToRequestedState();
+        ASSERT(m_nextState == SQLTransactionState::AcquireLock
+            || m_nextState == SQLTransactionState::OpenTransactionAndPreflight
+            || m_nextState == SQLTransactionState::RunStatements
+            || m_nextState == SQLTransactionState::PostflightAndCommit
+            || m_nextState == SQLTransactionState::CleanupAndTerminate
+            || m_nextState == SQLTransactionState::CleanupAfterTransactionErrorCallback);
+
+        LOG(StorageAPI, "State %s\n", nameForSQLTransactionState(m_nextState));
         return;
+    }
 
+    if (m_nextState == SQLTransactionState::End)
+        return;
+    m_nextState = SQLTransactionState::End;
+
     // If the database was stopped, don't do anything and cancel queued work
     LOG(StorageAPI, "Database was stopped or interrupted - cancelling work for this transaction");
 
@@ -480,28 +496,17 @@
     }
 
     // Terminate the frontend state machine. This also gets the frontend to
-    // call checkAndHandleClosedOrInterruptedDatabase() and clear its wrappers
+    // call computeNextStateAndCleanupIfNeeded() and clear its wrappers
     // if needed.
     m_frontend->requestTransitToState(SQLTransactionState::End);
 
     // Redirect to the end state to abort, clean up, and end the transaction.
     doCleanup();
-    m_nextState = SQLTransactionState::End;
 }
 
 void SQLTransactionBackend::performNextStep()
 {
-    LOG(StorageAPI, "State %s\n", nameForSQLTransactionState(m_nextState));
-
-    setStateToRequestedState();
-    ASSERT(m_nextState == SQLTransactionState::AcquireLock
-        || m_nextState == SQLTransactionState::OpenTransactionAndPreflight
-        || m_nextState == SQLTransactionState::RunStatements
-        || m_nextState == SQLTransactionState::PostflightAndCommit
-        || m_nextState == SQLTransactionState::CleanupAndTerminate
-        || m_nextState == SQLTransactionState::CleanupAfterTransactionErrorCallback);
-
-    checkAndHandleClosedOrInterruptedDatabase();
+    computeNextStateAndCleanupIfNeeded();
     runStateMachine();
 }
 

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h (143488 => 143489)


--- trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h	2013-02-20 21:09:16 UTC (rev 143488)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h	2013-02-20 21:10:18 UTC (rev 143489)
@@ -87,10 +87,9 @@
 
     void enqueueStatementBackend(PassRefPtr<SQLStatementBackend>);
 
-    void checkAndHandleClosedOrInterruptedDatabase();
-
     // State Machine functions:
     virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
+    void computeNextStateAndCleanupIfNeeded();
 
     // State functions:
     SQLTransactionState acquireLock();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to