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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // No error callback, so fast-forward to: | 149 // No error callback, so fast-forward to: |
150 // Transaction Step 11 - Rollback the transaction. | 150 // Transaction Step 11 - Rollback the transaction. |
151 return SQLTransactionState::CleanupAfterTransactionErrorCallback; | 151 return SQLTransactionState::CleanupAfterTransactionErrorCallback; |
152 } | 152 } |
153 | 153 |
154 SQLTransactionState SQLTransaction::deliverTransactionCallback() { | 154 SQLTransactionState SQLTransaction::deliverTransactionCallback() { |
155 bool shouldDeliverErrorCallback = false; | 155 bool shouldDeliverErrorCallback = false; |
156 InspectorInstrumentation::AsyncTask asyncTask( | 156 InspectorInstrumentation::AsyncTask asyncTask( |
157 m_database->getExecutionContext(), this); | 157 m_database->getExecutionContext(), this); |
158 | 158 |
159 // Spec 4.3.2 4: Invoke the transaction callback with the new SQLTransaction o
bject | 159 // Spec 4.3.2 4: Invoke the transaction callback with the new SQLTransaction |
| 160 // object. |
160 if (SQLTransactionCallback* callback = m_callback.release()) { | 161 if (SQLTransactionCallback* callback = m_callback.release()) { |
161 m_executeSqlAllowed = true; | 162 m_executeSqlAllowed = true; |
162 shouldDeliverErrorCallback = !callback->handleEvent(this); | 163 shouldDeliverErrorCallback = !callback->handleEvent(this); |
163 m_executeSqlAllowed = false; | 164 m_executeSqlAllowed = false; |
164 } | 165 } |
165 | 166 |
166 // Spec 4.3.2 5: If the transaction callback was null or raised an exception,
jump to the error callback | 167 // Spec 4.3.2 5: If the transaction callback was null or raised an exception, |
| 168 // jump to the error callback. |
167 SQLTransactionState nextState = SQLTransactionState::RunStatements; | 169 SQLTransactionState nextState = SQLTransactionState::RunStatements; |
168 if (shouldDeliverErrorCallback) { | 170 if (shouldDeliverErrorCallback) { |
169 m_database->reportStartTransactionResult(5, SQLError::kUnknownErr, 0); | 171 m_database->reportStartTransactionResult(5, SQLError::kUnknownErr, 0); |
170 m_transactionError = SQLErrorData::create( | 172 m_transactionError = SQLErrorData::create( |
171 SQLError::kUnknownErr, | 173 SQLError::kUnknownErr, |
172 "the SQLTransactionCallback was null or threw an exception"); | 174 "the SQLTransactionCallback was null or threw an exception"); |
173 nextState = SQLTransactionState::DeliverTransactionErrorCallback; | 175 nextState = SQLTransactionState::DeliverTransactionErrorCallback; |
174 } | 176 } |
175 m_database->reportStartTransactionResult(0, -1, 0); // OK | 177 m_database->reportStartTransactionResult(0, -1, 0); // OK |
176 return nextState; | 178 return nextState; |
(...skipping 23 matching lines...) Expand all Loading... |
200 } | 202 } |
201 | 203 |
202 clearCallbacks(); | 204 clearCallbacks(); |
203 | 205 |
204 // Spec 4.3.2.10: Rollback the transaction. | 206 // Spec 4.3.2.10: Rollback the transaction. |
205 return SQLTransactionState::CleanupAfterTransactionErrorCallback; | 207 return SQLTransactionState::CleanupAfterTransactionErrorCallback; |
206 } | 208 } |
207 | 209 |
208 SQLTransactionState SQLTransaction::deliverStatementCallback() { | 210 SQLTransactionState SQLTransaction::deliverStatementCallback() { |
209 DCHECK(isMainThread()); | 211 DCHECK(isMainThread()); |
210 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to
the transaction error callback | 212 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to |
211 // Otherwise, continue to loop through the statement queue | 213 // the transaction error callback. Otherwise, continue to loop through the |
| 214 // statement queue. |
212 m_executeSqlAllowed = true; | 215 m_executeSqlAllowed = true; |
213 | 216 |
214 SQLStatement* currentStatement = m_backend->currentStatement(); | 217 SQLStatement* currentStatement = m_backend->currentStatement(); |
215 ASSERT(currentStatement); | 218 ASSERT(currentStatement); |
216 | 219 |
217 bool result = currentStatement->performCallback(this); | 220 bool result = currentStatement->performCallback(this); |
218 | 221 |
219 m_executeSqlAllowed = false; | 222 m_executeSqlAllowed = false; |
220 | 223 |
221 if (result) { | 224 if (result) { |
(...skipping 24 matching lines...) Expand all Loading... |
246 m_database->getExecutionContext(), this); | 249 m_database->getExecutionContext(), this); |
247 InspectorInstrumentation::asyncTaskCanceled(m_database->getExecutionContext(), | 250 InspectorInstrumentation::asyncTaskCanceled(m_database->getExecutionContext(), |
248 this); | 251 this); |
249 | 252 |
250 // Spec 4.3.2.8: Deliver success callback. | 253 // Spec 4.3.2.8: Deliver success callback. |
251 if (VoidCallback* successCallback = m_successCallback.release()) | 254 if (VoidCallback* successCallback = m_successCallback.release()) |
252 successCallback->handleEvent(); | 255 successCallback->handleEvent(); |
253 | 256 |
254 clearCallbacks(); | 257 clearCallbacks(); |
255 | 258 |
256 // Schedule a "post-success callback" step to return control to the database t
hread in case there | 259 // Schedule a "post-success callback" step to return control to the database |
257 // are further transactions queued up for this Database | 260 // thread in case there are further transactions queued up for this Database. |
258 return SQLTransactionState::CleanupAndTerminate; | 261 return SQLTransactionState::CleanupAndTerminate; |
259 } | 262 } |
260 | 263 |
261 // This state function is used as a stub function to plug unimplemented states | 264 // This state function is used as a stub function to plug unimplemented states |
262 // in the state dispatch table. They are unimplemented because they should | 265 // in the state dispatch table. They are unimplemented because they should |
263 // never be reached in the course of correct execution. | 266 // never be reached in the course of correct execution. |
264 SQLTransactionState SQLTransaction::unreachableState() { | 267 SQLTransactionState SQLTransaction::unreachableState() { |
265 ASSERT_NOT_REACHED(); | 268 ASSERT_NOT_REACHED(); |
266 return SQLTransactionState::End; | 269 return SQLTransactionState::End; |
267 } | 270 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 m_callback.clear(); | 358 m_callback.clear(); |
356 m_successCallback.clear(); | 359 m_successCallback.clear(); |
357 m_errorCallback.clear(); | 360 m_errorCallback.clear(); |
358 } | 361 } |
359 | 362 |
360 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() { | 363 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() { |
361 return m_errorCallback.release(); | 364 return m_errorCallback.release(); |
362 } | 365 } |
363 | 366 |
364 } // namespace blink | 367 } // namespace blink |
OLD | NEW |