Chromium Code Reviews| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 if (callback) { | 150 if (callback) { |
| 151 m_executeSqlAllowed = true; | 151 m_executeSqlAllowed = true; |
| 152 shouldDeliverErrorCallback = !callback->handleEvent(this); | 152 shouldDeliverErrorCallback = !callback->handleEvent(this); |
| 153 m_executeSqlAllowed = false; | 153 m_executeSqlAllowed = false; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Spec 4.3.2 5: If the transaction callback was null or raised an exception , jump to the error callback | 156 // Spec 4.3.2 5: If the transaction callback was null or raised an exception , jump to the error callback |
| 157 SQLTransactionState nextState = SQLTransactionState::RunStatements; | 157 SQLTransactionState nextState = SQLTransactionState::RunStatements; |
| 158 if (shouldDeliverErrorCallback) { | 158 if (shouldDeliverErrorCallback) { |
| 159 m_database->reportStartTransactionResult(5, SQLError::UNKNOWN_ERR, 0); | 159 m_database->reportStartTransactionResult(5, SQLError::UNKNOWN_ERR, 0); |
| 160 m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "the SQLTra nsactionCallback was null or threw an exception"); | 160 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the SQ LTransactionCallback was null or threw an exception"); |
| 161 nextState = SQLTransactionState::DeliverTransactionErrorCallback; | 161 nextState = SQLTransactionState::DeliverTransactionErrorCallback; |
| 162 } | 162 } |
| 163 m_database->reportStartTransactionResult(0, -1, 0); // OK | 163 m_database->reportStartTransactionResult(0, -1, 0); // OK |
| 164 return nextState; | 164 return nextState; |
| 165 } | 165 } |
| 166 | 166 |
| 167 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() | 167 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() |
| 168 { | 168 { |
| 169 // Spec 4.3.2.10: If exists, invoke error callback with the last | 169 // Spec 4.3.2.10: If exists, invoke error callback with the last |
| 170 // error to have occurred in this transaction. | 170 // error to have occurred in this transaction. |
| 171 OwnPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallbackWrapper.u nwrap(); | 171 OwnPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallbackWrapper.u nwrap(); |
| 172 if (errorCallback) { | 172 if (errorCallback) { |
| 173 // If we get here with an empty m_transactionError, then the backend | 173 // If we get here with an empty m_transactionError, then the backend |
| 174 // must be waiting in the idle state waiting for this state to finish. | 174 // must be waiting in the idle state waiting for this state to finish. |
| 175 // Hence, it's thread safe to fetch the backend transactionError without | 175 // Hence, it's thread safe to fetch the backend transactionError without |
| 176 // a lock. | 176 // a lock. |
| 177 if (!m_transactionError) | 177 if (!m_transactionError && m_backend->transactionError()) |
| 178 m_transactionError = m_backend->transactionError(); | 178 m_transactionError = SQLErrorData::create(*m_backend->transactionErr or()); |
|
haraken
2014/03/25 11:50:05
I think you should add ASSERT(m_backend->transacti
tkent
2014/03/25 22:07:13
Done.
| |
| 179 | 179 |
| 180 ASSERT(m_transactionError); | 180 ASSERT(m_transactionError); |
| 181 errorCallback->handleEvent(m_transactionError.get()); | 181 RefPtrWillBeRawPtr<SQLError> error = SQLError::create(*m_transactionErro r); |
| 182 errorCallback->handleEvent(error.get()); | |
| 182 | 183 |
| 183 m_transactionError = nullptr; | 184 m_transactionError = nullptr; |
| 184 } | 185 } |
| 185 | 186 |
| 186 clearCallbackWrappers(); | 187 clearCallbackWrappers(); |
| 187 | 188 |
| 188 // Spec 4.3.2.10: Rollback the transaction. | 189 // Spec 4.3.2.10: Rollback the transaction. |
| 189 return SQLTransactionState::CleanupAfterTransactionErrorCallback; | 190 return SQLTransactionState::CleanupAfterTransactionErrorCallback; |
| 190 } | 191 } |
| 191 | 192 |
| 192 SQLTransactionState SQLTransaction::deliverStatementCallback() | 193 SQLTransactionState SQLTransaction::deliverStatementCallback() |
| 193 { | 194 { |
| 194 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback | 195 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback |
| 195 // Otherwise, continue to loop through the statement queue | 196 // Otherwise, continue to loop through the statement queue |
| 196 m_executeSqlAllowed = true; | 197 m_executeSqlAllowed = true; |
| 197 | 198 |
| 198 AbstractSQLStatement* currentAbstractStatement = m_backend->currentStatement (); | 199 AbstractSQLStatement* currentAbstractStatement = m_backend->currentStatement (); |
| 199 SQLStatement* currentStatement = static_cast<SQLStatement*>(currentAbstractS tatement); | 200 SQLStatement* currentStatement = static_cast<SQLStatement*>(currentAbstractS tatement); |
| 200 ASSERT(currentStatement); | 201 ASSERT(currentStatement); |
| 201 | 202 |
| 202 bool result = currentStatement->performCallback(this); | 203 bool result = currentStatement->performCallback(this); |
| 203 | 204 |
| 204 m_executeSqlAllowed = false; | 205 m_executeSqlAllowed = false; |
| 205 | 206 |
| 206 if (result) { | 207 if (result) { |
| 207 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0); | 208 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0); |
| 208 m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "the statem ent callback raised an exception or statement error callback did not return fals e"); | 209 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the st atement callback raised an exception or statement error callback did not return false"); |
| 209 return nextStateForTransactionError(); | 210 return nextStateForTransactionError(); |
| 210 } | 211 } |
| 211 return SQLTransactionState::RunStatements; | 212 return SQLTransactionState::RunStatements; |
| 212 } | 213 } |
| 213 | 214 |
| 214 SQLTransactionState SQLTransaction::deliverQuotaIncreaseCallback() | 215 SQLTransactionState SQLTransaction::deliverQuotaIncreaseCallback() |
| 215 { | 216 { |
| 216 ASSERT(m_backend->currentStatement()); | 217 ASSERT(m_backend->currentStatement()); |
| 217 | 218 |
| 218 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database()); | 219 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 m_successCallbackWrapper.clear(); | 310 m_successCallbackWrapper.clear(); |
| 310 m_errorCallbackWrapper.clear(); | 311 m_errorCallbackWrapper.clear(); |
| 311 } | 312 } |
| 312 | 313 |
| 313 PassOwnPtr<SQLTransactionErrorCallback> SQLTransaction::releaseErrorCallback() | 314 PassOwnPtr<SQLTransactionErrorCallback> SQLTransaction::releaseErrorCallback() |
| 314 { | 315 { |
| 315 return m_errorCallbackWrapper.unwrap(); | 316 return m_errorCallbackWrapper.unwrap(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace WebCore | 319 } // namespace WebCore |
| OLD | NEW |