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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 366 } |
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::trace(Visitor* visitor) | 373 void SQLTransactionBackend::trace(Visitor* visitor) |
374 { | 374 { |
375 visitor->trace(m_frontend); | 375 visitor->trace(m_frontend); |
| 376 visitor->trace(m_currentStatementBackend); |
376 visitor->trace(m_database); | 377 visitor->trace(m_database); |
| 378 visitor->trace(m_statementQueue); |
377 } | 379 } |
378 | 380 |
379 void SQLTransactionBackend::doCleanup() | 381 void SQLTransactionBackend::doCleanup() |
380 { | 382 { |
381 if (!m_frontend) | 383 if (!m_frontend) |
382 return; | 384 return; |
383 m_frontend = nullptr; // Break the reference cycle. See comment about the li
fe-cycle above. | 385 m_frontend = nullptr; // Break the reference cycle. See comment about the li
fe-cycle above. |
384 | 386 |
385 ASSERT(database()->databaseContext()->databaseThread()->isDatabaseThread()); | 387 ASSERT(database()->databaseContext()->databaseThread()->isDatabaseThread()); |
386 | 388 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 &SQLTransactionBackend::sendToFrontendState, // 11. deliverQuota
IncreaseCallback | 461 &SQLTransactionBackend::sendToFrontendState, // 11. deliverQuota
IncreaseCallback |
460 &SQLTransactionBackend::sendToFrontendState // 12. deliverSucce
ssCallback | 462 &SQLTransactionBackend::sendToFrontendState // 12. deliverSucce
ssCallback |
461 }; | 463 }; |
462 | 464 |
463 ASSERT(WTF_ARRAY_LENGTH(stateFunctions) == static_cast<int>(SQLTransactionSt
ate::NumberOfStates)); | 465 ASSERT(WTF_ARRAY_LENGTH(stateFunctions) == static_cast<int>(SQLTransactionSt
ate::NumberOfStates)); |
464 ASSERT(state < SQLTransactionState::NumberOfStates); | 466 ASSERT(state < SQLTransactionState::NumberOfStates); |
465 | 467 |
466 return stateFunctions[static_cast<int>(state)]; | 468 return stateFunctions[static_cast<int>(state)]; |
467 } | 469 } |
468 | 470 |
469 void SQLTransactionBackend::enqueueStatementBackend(PassRefPtr<SQLStatementBacke
nd> statementBackend) | 471 void SQLTransactionBackend::enqueueStatementBackend(PassRefPtrWillBeRawPtr<SQLSt
atementBackend> statementBackend) |
470 { | 472 { |
471 MutexLocker locker(m_statementMutex); | 473 MutexLocker locker(m_statementMutex); |
472 m_statementQueue.append(statementBackend); | 474 m_statementQueue.append(statementBackend); |
473 } | 475 } |
474 | 476 |
475 void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded() | 477 void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded() |
476 { | 478 { |
477 // Only honor the requested state transition if we're not supposed to be | 479 // Only honor the requested state transition if we're not supposed to be |
478 // cleaning up and shutting down: | 480 // cleaning up and shutting down: |
479 if (m_database->opened() && !m_database->isInterrupted()) { | 481 if (m_database->opened() && !m_database->isInterrupted()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 516 |
515 void SQLTransactionBackend::performNextStep() | 517 void SQLTransactionBackend::performNextStep() |
516 { | 518 { |
517 computeNextStateAndCleanupIfNeeded(); | 519 computeNextStateAndCleanupIfNeeded(); |
518 runStateMachine(); | 520 runStateMachine(); |
519 } | 521 } |
520 | 522 |
521 void SQLTransactionBackend::executeSQL(PassOwnPtr<AbstractSQLStatement> statemen
t, | 523 void SQLTransactionBackend::executeSQL(PassOwnPtr<AbstractSQLStatement> statemen
t, |
522 const String& sqlStatement, const Vector<SQLValue>& arguments, int permissio
ns) | 524 const String& sqlStatement, const Vector<SQLValue>& arguments, int permissio
ns) |
523 { | 525 { |
524 RefPtr<SQLStatementBackend> statementBackend; | 526 enqueueStatementBackend(SQLStatementBackend::create(statement, sqlStatement,
arguments, permissions)); |
525 statementBackend = SQLStatementBackend::create(statement, sqlStatement, argu
ments, permissions); | |
526 enqueueStatementBackend(statementBackend); | |
527 } | 527 } |
528 | 528 |
529 void SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown() | 529 void SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown() |
530 { | 530 { |
531 ASSERT(database()->databaseContext()->databaseThread()->isDatabaseThread()); | 531 ASSERT(database()->databaseContext()->databaseThread()->isDatabaseThread()); |
532 | 532 |
533 // If the transaction is in progress, we should roll it back here, since thi
s | 533 // If the transaction is in progress, we should roll it back here, since thi
s |
534 // is our last opportunity to do something related to this transaction on th
e | 534 // is our last opportunity to do something related to this transaction on th
e |
535 // DB thread. Amongst other work, doCleanup() will clear m_sqliteTransaction | 535 // DB thread. Amongst other work, doCleanup() will clear m_sqliteTransaction |
536 // which invokes SQLiteTransaction's destructor, which will do the roll back | 536 // which invokes SQLiteTransaction's destructor, which will do the roll back |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 } | 818 } |
819 | 819 |
820 SQLTransactionState SQLTransactionBackend::sendToFrontendState() | 820 SQLTransactionState SQLTransactionBackend::sendToFrontendState() |
821 { | 821 { |
822 ASSERT(m_nextState != SQLTransactionState::Idle); | 822 ASSERT(m_nextState != SQLTransactionState::Idle); |
823 m_frontend->requestTransitToState(m_nextState); | 823 m_frontend->requestTransitToState(m_nextState); |
824 return SQLTransactionState::Idle; | 824 return SQLTransactionState::Idle; |
825 } | 825 } |
826 | 826 |
827 } // namespace WebCore | 827 } // namespace WebCore |
OLD | NEW |