| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 | 367 |
| 368 SQLTransactionBackend::~SQLTransactionBackend() | 368 SQLTransactionBackend::~SQLTransactionBackend() |
| 369 { | 369 { |
| 370 ASSERT(!m_sqliteTransaction); | 370 ASSERT(!m_sqliteTransaction); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void SQLTransactionBackend::doCleanup() | 373 void SQLTransactionBackend::doCleanup() |
| 374 { | 374 { |
| 375 if (!m_frontend) | 375 if (!m_frontend) |
| 376 return; | 376 return; |
| 377 m_frontend = 0; // Break the reference cycle. See comment about the life-cyc
le above. | 377 m_frontend = nullptr; // Break the reference cycle. See comment about the li
fe-cycle above. |
| 378 | 378 |
| 379 ASSERT(database()->databaseContext()->databaseThread()->isDatabaseThread()); | 379 ASSERT(database()->databaseContext()->databaseThread()->isDatabaseThread()); |
| 380 | 380 |
| 381 MutexLocker locker(m_statementMutex); | 381 MutexLocker locker(m_statementMutex); |
| 382 m_statementQueue.clear(); | 382 m_statementQueue.clear(); |
| 383 | 383 |
| 384 if (m_sqliteTransaction) { | 384 if (m_sqliteTransaction) { |
| 385 // In the event we got here because of an interruption or error (i.e. if | 385 // In the event we got here because of an interruption or error (i.e. if |
| 386 // the transaction is in progress), we should roll it back here. Clearin
g | 386 // the transaction is in progress), we should roll it back here. Clearin
g |
| 387 // m_sqliteTransaction invokes SQLiteTransaction's destructor which does | 387 // m_sqliteTransaction invokes SQLiteTransaction's destructor which does |
| (...skipping 22 matching lines...) Expand all Loading... |
| 410 // m_currentStatementBackend may be accessed asynchronously by the | 410 // m_currentStatementBackend may be accessed asynchronously by the |
| 411 // frontend's deliverStatementCallback() state. Similarly, | 411 // frontend's deliverStatementCallback() state. Similarly, |
| 412 // m_transactionError may be accessed by deliverTransactionErrorCallback(). | 412 // m_transactionError may be accessed by deliverTransactionErrorCallback(). |
| 413 // This occurs if requests for transition to those states have already been | 413 // This occurs if requests for transition to those states have already been |
| 414 // registered with the frontend just prior to a clean up request arriving. | 414 // registered with the frontend just prior to a clean up request arriving. |
| 415 // | 415 // |
| 416 // So instead, let our destructor handle their clean up since this | 416 // So instead, let our destructor handle their clean up since this |
| 417 // SQLTransactionBackend is guaranteed to not destruct until the frontend | 417 // SQLTransactionBackend is guaranteed to not destruct until the frontend |
| 418 // is also destructing. | 418 // is also destructing. |
| 419 | 419 |
| 420 m_wrapper = 0; | 420 m_wrapper = nullptr; |
| 421 } | 421 } |
| 422 | 422 |
| 423 AbstractSQLStatement* SQLTransactionBackend::currentStatement() | 423 AbstractSQLStatement* SQLTransactionBackend::currentStatement() |
| 424 { | 424 { |
| 425 return m_currentStatementBackend->frontend(); | 425 return m_currentStatementBackend->frontend(); |
| 426 } | 426 } |
| 427 | 427 |
| 428 PassRefPtr<SQLError> SQLTransactionBackend::transactionError() | 428 PassRefPtr<SQLError> SQLTransactionBackend::transactionError() |
| 429 { | 429 { |
| 430 return m_transactionError; | 430 return m_transactionError; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 getNextStatement(); | 638 getNextStatement(); |
| 639 } | 639 } |
| 640 nextState = runCurrentStatementAndGetNextState(); | 640 nextState = runCurrentStatementAndGetNextState(); |
| 641 } while (nextState == SQLTransactionState::RunStatements); | 641 } while (nextState == SQLTransactionState::RunStatements); |
| 642 | 642 |
| 643 return nextState; | 643 return nextState; |
| 644 } | 644 } |
| 645 | 645 |
| 646 void SQLTransactionBackend::getNextStatement() | 646 void SQLTransactionBackend::getNextStatement() |
| 647 { | 647 { |
| 648 m_currentStatementBackend = 0; | 648 m_currentStatementBackend = nullptr; |
| 649 | 649 |
| 650 MutexLocker locker(m_statementMutex); | 650 MutexLocker locker(m_statementMutex); |
| 651 if (!m_statementQueue.isEmpty()) | 651 if (!m_statementQueue.isEmpty()) |
| 652 m_currentStatementBackend = m_statementQueue.takeFirst(); | 652 m_currentStatementBackend = m_statementQueue.takeFirst(); |
| 653 } | 653 } |
| 654 | 654 |
| 655 SQLTransactionState SQLTransactionBackend::runCurrentStatementAndGetNextState() | 655 SQLTransactionState SQLTransactionBackend::runCurrentStatementAndGetNextState() |
| 656 { | 656 { |
| 657 if (!m_currentStatementBackend) { | 657 if (!m_currentStatementBackend) { |
| 658 // No more statements to run. So move on to the next state. | 658 // No more statements to run. So move on to the next state. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 812 } |
| 813 | 813 |
| 814 SQLTransactionState SQLTransactionBackend::sendToFrontendState() | 814 SQLTransactionState SQLTransactionBackend::sendToFrontendState() |
| 815 { | 815 { |
| 816 ASSERT(m_nextState != SQLTransactionState::Idle); | 816 ASSERT(m_nextState != SQLTransactionState::Idle); |
| 817 m_frontend->requestTransitToState(m_nextState); | 817 m_frontend->requestTransitToState(m_nextState); |
| 818 return SQLTransactionState::Idle; | 818 return SQLTransactionState::Idle; |
| 819 } | 819 } |
| 820 | 820 |
| 821 } // namespace WebCore | 821 } // namespace WebCore |
| OLD | NEW |