Changeset 143489 in webkit


Ignore:
Timestamp:
Feb 20, 2013 1:10:18 PM (11 years ago)
Author:
mark.lam@apple.com
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:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r143487 r143489  
     12013-02-20  Mark Lam  <mark.lam@apple.com>
     2
     3        Cleanup the SQLTransaction and SQLTransactionBackend state dispatch
     4        to only honor a state transition request if the associated database
     5        hasn't been interrupted.
     6        https://bugs.webkit.org/show_bug.cgi?id=110247.
     7
     8        Reviewed by Antti Koivisto.
     9
     10        No new tests.
     11
     12        * Modules/webdatabase/SQLTransaction.cpp:
     13        (WebCore::SQLTransaction::performPendingCallback):
     14        (WebCore::SQLTransaction::computeNextStateAndCleanupIfNeeded):
     15        * Modules/webdatabase/SQLTransaction.h:
     16        * Modules/webdatabase/SQLTransactionBackend.cpp:
     17        (WebCore::SQLTransactionBackend::computeNextStateAndCleanupIfNeeded):
     18        (WebCore::SQLTransactionBackend::performNextStep):
     19        * Modules/webdatabase/SQLTransactionBackend.h:
     20
    1212013-02-20  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.cpp

    r143412 r143489  
    248248void SQLTransaction::performPendingCallback()
    249249{
    250     LOG(StorageAPI, "Callback %s\n", nameForSQLTransactionState(m_nextState));
    251 
    252     setStateToRequestedState();
    253     ASSERT(m_nextState == SQLTransactionState::End
    254         || m_nextState == SQLTransactionState::DeliverTransactionCallback
    255         || m_nextState == SQLTransactionState::DeliverTransactionErrorCallback
    256         || m_nextState == SQLTransactionState::DeliverStatementCallback
    257         || m_nextState == SQLTransactionState::DeliverQuotaIncreaseCallback
    258         || m_nextState == SQLTransactionState::DeliverSuccessCallback);
    259 
    260     checkAndHandleClosedOrInterruptedDatabase();
     250    computeNextStateAndCleanupIfNeeded();
    261251    runStateMachine();
    262252}
     
    279269}
    280270
    281 bool SQLTransaction::checkAndHandleClosedOrInterruptedDatabase()
    282 {
    283     if (m_database->opened() && !m_database->isInterrupted())
     271bool SQLTransaction::computeNextStateAndCleanupIfNeeded()
     272{
     273    // Only honor the requested state transition if we're not supposed to be
     274    // cleaning up and shutting down:
     275    if (m_database->opened() && !m_database->isInterrupted()) {
     276        setStateToRequestedState();
     277        ASSERT(m_nextState == SQLTransactionState::End
     278            || m_nextState == SQLTransactionState::DeliverTransactionCallback
     279            || m_nextState == SQLTransactionState::DeliverTransactionErrorCallback
     280            || m_nextState == SQLTransactionState::DeliverStatementCallback
     281            || m_nextState == SQLTransactionState::DeliverQuotaIncreaseCallback
     282            || m_nextState == SQLTransactionState::DeliverSuccessCallback);
     283
     284        LOG(StorageAPI, "Callback %s\n", nameForSQLTransactionState(m_nextState));
    284285        return false;
     286    }
    285287
    286288    clearCallbackWrappers();
  • trunk/Source/WebCore/Modules/webdatabase/SQLTransaction.h

    r143412 r143489  
    6969        bool readOnly);
    7070
    71     bool checkAndHandleClosedOrInterruptedDatabase();
    7271    void clearCallbackWrappers();
    7372
     
    8180    // State Machine functions:
    8281    virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
     82    bool computeNextStateAndCleanupIfNeeded();
    8383
    8484    // State functions:
  • trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp

    r143412 r143489  
    466466}
    467467
    468 void SQLTransactionBackend::checkAndHandleClosedOrInterruptedDatabase()
    469 {
    470     if (m_database->opened() && !m_database->isInterrupted())
     468void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded()
     469{
     470    // Only honor the requested state transition if we're not supposed to be
     471    // cleaning up and shutting down:
     472    if (m_database->opened() && !m_database->isInterrupted()) {
     473        setStateToRequestedState();
     474        ASSERT(m_nextState == SQLTransactionState::AcquireLock
     475            || m_nextState == SQLTransactionState::OpenTransactionAndPreflight
     476            || m_nextState == SQLTransactionState::RunStatements
     477            || m_nextState == SQLTransactionState::PostflightAndCommit
     478            || m_nextState == SQLTransactionState::CleanupAndTerminate
     479            || m_nextState == SQLTransactionState::CleanupAfterTransactionErrorCallback);
     480
     481        LOG(StorageAPI, "State %s\n", nameForSQLTransactionState(m_nextState));
    471482        return;
     483    }
     484
     485    if (m_nextState == SQLTransactionState::End)
     486        return;
     487    m_nextState = SQLTransactionState::End;
    472488
    473489    // If the database was stopped, don't do anything and cancel queued work
     
    481497
    482498    // Terminate the frontend state machine. This also gets the frontend to
    483     // call checkAndHandleClosedOrInterruptedDatabase() and clear its wrappers
     499    // call computeNextStateAndCleanupIfNeeded() and clear its wrappers
    484500    // if needed.
    485501    m_frontend->requestTransitToState(SQLTransactionState::End);
     
    487503    // Redirect to the end state to abort, clean up, and end the transaction.
    488504    doCleanup();
    489     m_nextState = SQLTransactionState::End;
    490505}
    491506
    492507void SQLTransactionBackend::performNextStep()
    493508{
    494     LOG(StorageAPI, "State %s\n", nameForSQLTransactionState(m_nextState));
    495 
    496     setStateToRequestedState();
    497     ASSERT(m_nextState == SQLTransactionState::AcquireLock
    498         || m_nextState == SQLTransactionState::OpenTransactionAndPreflight
    499         || m_nextState == SQLTransactionState::RunStatements
    500         || m_nextState == SQLTransactionState::PostflightAndCommit
    501         || m_nextState == SQLTransactionState::CleanupAndTerminate
    502         || m_nextState == SQLTransactionState::CleanupAfterTransactionErrorCallback);
    503 
    504     checkAndHandleClosedOrInterruptedDatabase();
     509    computeNextStateAndCleanupIfNeeded();
    505510    runStateMachine();
    506511}
  • trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h

    r143412 r143489  
    8888    void enqueueStatementBackend(PassRefPtr<SQLStatementBackend>);
    8989
    90     void checkAndHandleClosedOrInterruptedDatabase();
    91 
    9290    // State Machine functions:
    9391    virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
     92    void computeNextStateAndCleanupIfNeeded();
    9493
    9594    // State functions:
Note: See TracChangeset for help on using the changeset viewer.