| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 { | 77 { |
| 78 ASSERT(executionContext()->isContextThread()); | 78 ASSERT(executionContext()->isContextThread()); |
| 79 | 79 |
| 80 if (sqliteDatabase().transactionInProgress()) { | 80 if (sqliteDatabase().transactionInProgress()) { |
| 81 reportChangeVersionResult(1, SQLError::DATABASE_ERR, 0); | 81 reportChangeVersionResult(1, SQLError::DATABASE_ERR, 0); |
| 82 setLastErrorMessage("unable to changeVersion from within a transaction")
; | 82 setLastErrorMessage("unable to changeVersion from within a transaction")
; |
| 83 exceptionState.throwDOMException(SQLDatabaseError, "Unable to change ver
sion from within a transaction."); | 83 exceptionState.throwDOMException(SQLDatabaseError, "Unable to change ver
sion from within a transaction."); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 | 86 |
| 87 RefPtr<SQLTransactionSync> transaction = SQLTransactionSync::create(this, ch
angeVersionCallback, false); | 87 RefPtrWillBeRawPtr<SQLTransactionSync> transaction = SQLTransactionSync::cre
ate(this, changeVersionCallback, false); |
| 88 transaction->begin(exceptionState); | 88 transaction->begin(exceptionState); |
| 89 if (exceptionState.hadException()) { | 89 if (exceptionState.hadException()) { |
| 90 ASSERT(!lastErrorMessage().isEmpty()); | 90 ASSERT(!lastErrorMessage().isEmpty()); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 String actualVersion; | 94 String actualVersion; |
| 95 if (!getVersionFromDatabase(actualVersion)) { | 95 if (!getVersionFromDatabase(actualVersion)) { |
| 96 reportChangeVersionResult(2, SQLError::UNKNOWN_ERR, sqliteDatabase().las
tError()); | 96 reportChangeVersionResult(2, SQLError::UNKNOWN_ERR, sqliteDatabase().las
tError()); |
| 97 setLastErrorMessage("unable to read the current version", sqliteDatabase
().lastError(), sqliteDatabase().lastErrorMsg()); | 97 setLastErrorMessage("unable to read the current version", sqliteDatabase
().lastError(), sqliteDatabase().lastErrorMsg()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void DatabaseSync::transaction(PassOwnPtr<SQLTransactionSyncCallback> callback,
ExceptionState& exceptionState) | 136 void DatabaseSync::transaction(PassOwnPtr<SQLTransactionSyncCallback> callback,
ExceptionState& exceptionState) |
| 137 { | 137 { |
| 138 runTransaction(callback, false, exceptionState); | 138 runTransaction(callback, false, exceptionState); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void DatabaseSync::readTransaction(PassOwnPtr<SQLTransactionSyncCallback> callba
ck, ExceptionState& exceptionState) | 141 void DatabaseSync::readTransaction(PassOwnPtr<SQLTransactionSyncCallback> callba
ck, ExceptionState& exceptionState) |
| 142 { | 142 { |
| 143 runTransaction(callback, true, exceptionState); | 143 runTransaction(callback, true, exceptionState); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void DatabaseSync::rollbackTransaction(PassRefPtr<SQLTransactionSync> transactio
n) | 146 void DatabaseSync::rollbackTransaction(SQLTransactionSync& transaction) |
| 147 { | 147 { |
| 148 ASSERT(!lastErrorMessage().isEmpty()); | 148 ASSERT(!lastErrorMessage().isEmpty()); |
| 149 transaction->rollback(); | 149 transaction.rollback(); |
| 150 setLastErrorMessage(""); | 150 setLastErrorMessage(""); |
| 151 return; | 151 return; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DatabaseSync::runTransaction(PassOwnPtr<SQLTransactionSyncCallback> callbac
k, bool readOnly, ExceptionState& exceptionState) | 154 void DatabaseSync::runTransaction(PassOwnPtr<SQLTransactionSyncCallback> callbac
k, bool readOnly, ExceptionState& exceptionState) |
| 155 { | 155 { |
| 156 ASSERT(executionContext()->isContextThread()); | 156 ASSERT(executionContext()->isContextThread()); |
| 157 | 157 |
| 158 if (sqliteDatabase().transactionInProgress()) { | 158 if (sqliteDatabase().transactionInProgress()) { |
| 159 setLastErrorMessage("unable to start a transaction from within a transac
tion"); | 159 setLastErrorMessage("unable to start a transaction from within a transac
tion"); |
| 160 exceptionState.throwDOMException(SQLDatabaseError, "Unable to start a tr
ansaction from within a transaction."); | 160 exceptionState.throwDOMException(SQLDatabaseError, "Unable to start a tr
ansaction from within a transaction."); |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 | 163 |
| 164 RefPtr<SQLTransactionSync> transaction = SQLTransactionSync::create(this, ca
llback, readOnly); | 164 RefPtrWillBeRawPtr<SQLTransactionSync> transaction = SQLTransactionSync::cre
ate(this, callback, readOnly); |
| 165 transaction->begin(exceptionState); | 165 transaction->begin(exceptionState); |
| 166 if (exceptionState.hadException()) { | 166 if (exceptionState.hadException()) { |
| 167 rollbackTransaction(transaction); | 167 rollbackTransaction(*transaction); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 | 170 |
| 171 transaction->execute(exceptionState); | 171 transaction->execute(exceptionState); |
| 172 if (exceptionState.hadException()) { | 172 if (exceptionState.hadException()) { |
| 173 rollbackTransaction(transaction); | 173 rollbackTransaction(*transaction); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 | 176 |
| 177 transaction->commit(exceptionState); | 177 transaction->commit(exceptionState); |
| 178 if (exceptionState.hadException()) { | 178 if (exceptionState.hadException()) { |
| 179 rollbackTransaction(transaction); | 179 rollbackTransaction(*transaction); |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 | 182 |
| 183 setLastErrorMessage(""); | 183 setLastErrorMessage(""); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void DatabaseSync::closeImmediately() | 186 void DatabaseSync::closeImmediately() |
| 187 { | 187 { |
| 188 ASSERT(executionContext()->isContextThread()); | 188 ASSERT(executionContext()->isContextThread()); |
| 189 | 189 |
| 190 if (!opened()) | 190 if (!opened()) |
| 191 return; | 191 return; |
| 192 | 192 |
| 193 logErrorMessage("forcibly closing database"); | 193 logErrorMessage("forcibly closing database"); |
| 194 closeDatabase(); | 194 closeDatabase(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 #if ENABLE(OILPAN) |
| 198 void DatabaseSync::registerTransaction(SQLTransactionSync* sync) |
| 199 { |
| 200 ObserverMap::AddResult result = m_observers.add(sync, nullptr); |
| 201 ASSERT(result.isNewEntry); |
| 202 result.storedValue->value = adoptPtr(new TransactionObserver(sync)); |
| 203 } |
| 204 |
| 205 DatabaseSync::TransactionObserver::~TransactionObserver() |
| 206 { |
| 207 m_sync->rollbackIfInProgress(); |
| 208 } |
| 209 #endif |
| 210 |
| 197 } // namespace WebCore | 211 } // namespace WebCore |
| OLD | NEW |