| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 SQLTransactionBackendSync::SQLTransactionBackendSync(DatabaseSync* db, PassOwnPt
r<SQLTransactionSyncCallback> callback, bool readOnly) | 54 SQLTransactionBackendSync::SQLTransactionBackendSync(DatabaseSync* db, PassOwnPt
r<SQLTransactionSyncCallback> callback, bool readOnly) |
| 55 : m_database(db) | 55 : m_database(db) |
| 56 , m_callback(callback) | 56 , m_callback(callback) |
| 57 , m_readOnly(readOnly) | 57 , m_readOnly(readOnly) |
| 58 , m_hasVersionMismatch(false) | 58 , m_hasVersionMismatch(false) |
| 59 , m_modifiedDatabase(false) | 59 , m_modifiedDatabase(false) |
| 60 , m_transactionClient(adoptPtr(new SQLTransactionClient())) | 60 , m_transactionClient(adoptPtr(new SQLTransactionClient())) |
| 61 { | 61 { |
| 62 ASSERT(m_database->executionContext()->isContextThread()); | 62 ASSERT(m_database->executionContext()->isContextThread()); |
| 63 #if ENABLE(OILPAN) |
| 64 m_database->registerTransaction(static_cast<SQLTransactionSync*>(this)); |
| 65 #endif |
| 66 } |
| 67 |
| 68 void SQLTransactionBackendSync::rollbackIfInProgress() |
| 69 { |
| 70 ASSERT(!m_database->executionContext() || m_database->executionContext()->is
ContextThread()); |
| 71 if (m_sqliteTransaction && m_sqliteTransaction->inProgress()) |
| 72 rollback(); |
| 63 } | 73 } |
| 64 | 74 |
| 65 SQLTransactionBackendSync::~SQLTransactionBackendSync() | 75 SQLTransactionBackendSync::~SQLTransactionBackendSync() |
| 66 { | 76 { |
| 67 ASSERT(m_database->executionContext()->isContextThread()); | 77 #if ENABLE(OILPAN) |
| 68 if (m_sqliteTransaction && m_sqliteTransaction->inProgress()) | 78 ASSERT(!m_sqliteTransaction || !m_sqliteTransaction->inProgress()); |
| 69 rollback(); | 79 #else |
| 80 rollbackIfInProgress(); |
| 81 #endif |
| 82 } |
| 83 |
| 84 void SQLTransactionBackendSync::trace(Visitor* visitor) |
| 85 { |
| 86 visitor->trace(m_database); |
| 70 } | 87 } |
| 71 | 88 |
| 72 PassRefPtr<SQLResultSet> SQLTransactionBackendSync::executeSQL(const String& sql
Statement, const Vector<SQLValue>& arguments, ExceptionState& exceptionState) | 89 PassRefPtr<SQLResultSet> SQLTransactionBackendSync::executeSQL(const String& sql
Statement, const Vector<SQLValue>& arguments, ExceptionState& exceptionState) |
| 73 { | 90 { |
| 74 ASSERT(m_database->executionContext()->isContextThread()); | 91 ASSERT(m_database->executionContext()->isContextThread()); |
| 75 | 92 |
| 76 m_database->setLastErrorMessage(""); | 93 m_database->setLastErrorMessage(""); |
| 77 | 94 |
| 78 if (!m_database->opened()) { | 95 if (!m_database->opened()) { |
| 79 m_database->setLastErrorMessage("cannot executeSQL because the database
is not open"); | 96 m_database->setLastErrorMessage("cannot executeSQL because the database
is not open"); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (m_database->hadDeletes()) | 239 if (m_database->hadDeletes()) |
| 223 m_database->incrementalVacuumIfNeeded(); | 240 m_database->incrementalVacuumIfNeeded(); |
| 224 | 241 |
| 225 // The commit was successful. If the transaction modified this database, not
ify the delegates. | 242 // The commit was successful. If the transaction modified this database, not
ify the delegates. |
| 226 if (m_modifiedDatabase) | 243 if (m_modifiedDatabase) |
| 227 m_transactionClient->didCommitWriteTransaction(database()); | 244 m_transactionClient->didCommitWriteTransaction(database()); |
| 228 | 245 |
| 229 m_database->reportCommitTransactionResult(0, -1, 0); // OK | 246 m_database->reportCommitTransactionResult(0, -1, 0); // OK |
| 230 } | 247 } |
| 231 | 248 |
| 249 // This can be called while doing weak processing. Do not allocate new on-heap o
bjects. |
| 232 void SQLTransactionBackendSync::rollback() | 250 void SQLTransactionBackendSync::rollback() |
| 233 { | 251 { |
| 234 ASSERT(m_database->executionContext()->isContextThread()); | 252 ASSERT(!m_database->executionContext() || m_database->executionContext()->is
ContextThread()); |
| 235 m_database->disableAuthorizer(); | 253 m_database->disableAuthorizer(); |
| 236 if (m_sqliteTransaction) { | 254 if (m_sqliteTransaction) { |
| 237 m_sqliteTransaction->rollback(); | 255 m_sqliteTransaction->rollback(); |
| 238 m_sqliteTransaction.clear(); | 256 m_sqliteTransaction.clear(); |
| 239 } | 257 } |
| 240 m_database->enableAuthorizer(); | 258 m_database->enableAuthorizer(); |
| 241 | 259 |
| 242 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); | 260 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); |
| 243 } | 261 } |
| 244 | 262 |
| 245 } // namespace WebCore | 263 } // namespace WebCore |
| OLD | NEW |