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) { |
178 m_transactionError = m_backend->transactionError(); | 178 ASSERT(m_backend->transactionError()); |
179 | 179 m_transactionError = SQLErrorData::create(*m_backend->transactionErr
or()); |
| 180 } |
180 ASSERT(m_transactionError); | 181 ASSERT(m_transactionError); |
181 errorCallback->handleEvent(m_transactionError.get()); | 182 RefPtrWillBeRawPtr<SQLError> error = SQLError::create(*m_transactionErro
r); |
| 183 errorCallback->handleEvent(error.get()); |
182 | 184 |
183 m_transactionError = nullptr; | 185 m_transactionError = nullptr; |
184 } | 186 } |
185 | 187 |
186 clearCallbackWrappers(); | 188 clearCallbackWrappers(); |
187 | 189 |
188 // Spec 4.3.2.10: Rollback the transaction. | 190 // Spec 4.3.2.10: Rollback the transaction. |
189 return SQLTransactionState::CleanupAfterTransactionErrorCallback; | 191 return SQLTransactionState::CleanupAfterTransactionErrorCallback; |
190 } | 192 } |
191 | 193 |
192 SQLTransactionState SQLTransaction::deliverStatementCallback() | 194 SQLTransactionState SQLTransaction::deliverStatementCallback() |
193 { | 195 { |
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 | 196 // 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 | 197 // Otherwise, continue to loop through the statement queue |
196 m_executeSqlAllowed = true; | 198 m_executeSqlAllowed = true; |
197 | 199 |
198 AbstractSQLStatement* currentAbstractStatement = m_backend->currentStatement
(); | 200 AbstractSQLStatement* currentAbstractStatement = m_backend->currentStatement
(); |
199 SQLStatement* currentStatement = static_cast<SQLStatement*>(currentAbstractS
tatement); | 201 SQLStatement* currentStatement = static_cast<SQLStatement*>(currentAbstractS
tatement); |
200 ASSERT(currentStatement); | 202 ASSERT(currentStatement); |
201 | 203 |
202 bool result = currentStatement->performCallback(this); | 204 bool result = currentStatement->performCallback(this); |
203 | 205 |
204 m_executeSqlAllowed = false; | 206 m_executeSqlAllowed = false; |
205 | 207 |
206 if (result) { | 208 if (result) { |
207 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0); | 209 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"); | 210 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(); | 211 return nextStateForTransactionError(); |
210 } | 212 } |
211 return SQLTransactionState::RunStatements; | 213 return SQLTransactionState::RunStatements; |
212 } | 214 } |
213 | 215 |
214 SQLTransactionState SQLTransaction::deliverQuotaIncreaseCallback() | 216 SQLTransactionState SQLTransaction::deliverQuotaIncreaseCallback() |
215 { | 217 { |
216 ASSERT(m_backend->currentStatement()); | 218 ASSERT(m_backend->currentStatement()); |
217 | 219 |
218 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee
dQuota(database()); | 220 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(); | 311 m_successCallbackWrapper.clear(); |
310 m_errorCallbackWrapper.clear(); | 312 m_errorCallbackWrapper.clear(); |
311 } | 313 } |
312 | 314 |
313 PassOwnPtr<SQLTransactionErrorCallback> SQLTransaction::releaseErrorCallback() | 315 PassOwnPtr<SQLTransactionErrorCallback> SQLTransaction::releaseErrorCallback() |
314 { | 316 { |
315 return m_errorCallbackWrapper.unwrap(); | 317 return m_errorCallbackWrapper.unwrap(); |
316 } | 318 } |
317 | 319 |
318 } // namespace WebCore | 320 } // namespace WebCore |
OLD | NEW |