| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 VoidCallback* successCallback, SQLTransactionErrorCallback* errorCallback, | 58 VoidCallback* successCallback, SQLTransactionErrorCallback* errorCallback, |
| 59 bool readOnly) | 59 bool readOnly) |
| 60 : m_database(db) | 60 : m_database(db) |
| 61 , m_callback(callback) | 61 , m_callback(callback) |
| 62 , m_successCallback(successCallback) | 62 , m_successCallback(successCallback) |
| 63 , m_errorCallback(errorCallback) | 63 , m_errorCallback(errorCallback) |
| 64 , m_executeSqlAllowed(false) | 64 , m_executeSqlAllowed(false) |
| 65 , m_readOnly(readOnly) | 65 , m_readOnly(readOnly) |
| 66 { | 66 { |
| 67 ASSERT(m_database); | 67 ASSERT(m_database); |
| 68 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarting(d
b->executionContext(), "SQLTransaction"); | 68 m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarting(d
b->getExecutionContext(), "SQLTransaction"); |
| 69 } | 69 } |
| 70 | 70 |
| 71 SQLTransaction::~SQLTransaction() | 71 SQLTransaction::~SQLTransaction() |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| 75 DEFINE_TRACE(SQLTransaction) | 75 DEFINE_TRACE(SQLTransaction) |
| 76 { | 76 { |
| 77 visitor->trace(m_database); | 77 visitor->trace(m_database); |
| 78 visitor->trace(m_backend); | 78 visitor->trace(m_backend); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return SQLTransactionState::CleanupAfterTransactionErrorCallback; | 147 return SQLTransactionState::CleanupAfterTransactionErrorCallback; |
| 148 } | 148 } |
| 149 | 149 |
| 150 SQLTransactionState SQLTransaction::deliverTransactionCallback() | 150 SQLTransactionState SQLTransaction::deliverTransactionCallback() |
| 151 { | 151 { |
| 152 bool shouldDeliverErrorCallback = false; | 152 bool shouldDeliverErrorCallback = false; |
| 153 | 153 |
| 154 // Spec 4.3.2 4: Invoke the transaction callback with the new SQLTransaction
object | 154 // Spec 4.3.2 4: Invoke the transaction callback with the new SQLTransaction
object |
| 155 if (SQLTransactionCallback* callback = m_callback.release()) { | 155 if (SQLTransactionCallback* callback = m_callback.release()) { |
| 156 m_executeSqlAllowed = true; | 156 m_executeSqlAllowed = true; |
| 157 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncCallbackStarting(m_database->executionContext(), m_asyncOperationId); | 157 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceA
syncCallbackStarting(m_database->getExecutionContext(), m_asyncOperationId); |
| 158 shouldDeliverErrorCallback = !callback->handleEvent(this); | 158 shouldDeliverErrorCallback = !callback->handleEvent(this); |
| 159 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 159 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
| 160 m_executeSqlAllowed = false; | 160 m_executeSqlAllowed = false; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Spec 4.3.2 5: If the transaction callback was null or raised an exception
, jump to the error callback | 163 // Spec 4.3.2 5: If the transaction callback was null or raised an exception
, jump to the error callback |
| 164 SQLTransactionState nextState = SQLTransactionState::RunStatements; | 164 SQLTransactionState nextState = SQLTransactionState::RunStatements; |
| 165 if (shouldDeliverErrorCallback) { | 165 if (shouldDeliverErrorCallback) { |
| 166 m_database->reportStartTransactionResult(5, SQLError::UNKNOWN_ERR, 0); | 166 m_database->reportStartTransactionResult(5, SQLError::UNKNOWN_ERR, 0); |
| 167 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the SQ
LTransactionCallback was null or threw an exception"); | 167 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the SQ
LTransactionCallback was null or threw an exception"); |
| 168 nextState = SQLTransactionState::DeliverTransactionErrorCallback; | 168 nextState = SQLTransactionState::DeliverTransactionErrorCallback; |
| 169 } | 169 } |
| 170 m_database->reportStartTransactionResult(0, -1, 0); // OK | 170 m_database->reportStartTransactionResult(0, -1, 0); // OK |
| 171 return nextState; | 171 return nextState; |
| 172 } | 172 } |
| 173 | 173 |
| 174 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() | 174 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() |
| 175 { | 175 { |
| 176 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
OperationCompletedCallbackStarting(m_database->executionContext(), m_asyncOperat
ionId); | 176 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
OperationCompletedCallbackStarting(m_database->getExecutionContext(), m_asyncOpe
rationId); |
| 177 | 177 |
| 178 // Spec 4.3.2.10: If exists, invoke error callback with the last | 178 // Spec 4.3.2.10: If exists, invoke error callback with the last |
| 179 // error to have occurred in this transaction. | 179 // error to have occurred in this transaction. |
| 180 if (SQLTransactionErrorCallback* errorCallback = m_errorCallback.release())
{ | 180 if (SQLTransactionErrorCallback* errorCallback = m_errorCallback.release())
{ |
| 181 // If we get here with an empty m_transactionError, then the backend | 181 // If we get here with an empty m_transactionError, then the backend |
| 182 // must be waiting in the idle state waiting for this state to finish. | 182 // must be waiting in the idle state waiting for this state to finish. |
| 183 // Hence, it's thread safe to fetch the backend transactionError without | 183 // Hence, it's thread safe to fetch the backend transactionError without |
| 184 // a lock. | 184 // a lock. |
| 185 if (!m_transactionError) { | 185 if (!m_transactionError) { |
| 186 ASSERT(m_backend->transactionError()); | 186 ASSERT(m_backend->transactionError()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 ASSERT(m_backend->currentStatement()); | 225 ASSERT(m_backend->currentStatement()); |
| 226 | 226 |
| 227 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee
dQuota(database()); | 227 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee
dQuota(database()); |
| 228 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement); | 228 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement); |
| 229 | 229 |
| 230 return SQLTransactionState::RunStatements; | 230 return SQLTransactionState::RunStatements; |
| 231 } | 231 } |
| 232 | 232 |
| 233 SQLTransactionState SQLTransaction::deliverSuccessCallback() | 233 SQLTransactionState SQLTransaction::deliverSuccessCallback() |
| 234 { | 234 { |
| 235 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
OperationCompletedCallbackStarting(m_database->executionContext(), m_asyncOperat
ionId); | 235 InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsync
OperationCompletedCallbackStarting(m_database->getExecutionContext(), m_asyncOpe
rationId); |
| 236 | 236 |
| 237 // Spec 4.3.2.8: Deliver success callback. | 237 // Spec 4.3.2.8: Deliver success callback. |
| 238 if (VoidCallback* successCallback = m_successCallback.release()) | 238 if (VoidCallback* successCallback = m_successCallback.release()) |
| 239 successCallback->handleEvent(); | 239 successCallback->handleEvent(); |
| 240 | 240 |
| 241 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); | 241 InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); |
| 242 clearCallbacks(); | 242 clearCallbacks(); |
| 243 | 243 |
| 244 // Schedule a "post-success callback" step to return control to the database
thread in case there | 244 // Schedule a "post-success callback" step to return control to the database
thread in case there |
| 245 // are further transactions queued up for this Database | 245 // are further transactions queued up for this Database |
| (...skipping 28 matching lines...) Expand all Loading... |
| 274 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di
sallowed."); | 274 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di
sallowed."); |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 | 277 |
| 278 if (!m_database->opened()) { | 278 if (!m_database->opened()) { |
| 279 exceptionState.throwDOMException(InvalidStateError, "The database has no
t been opened."); | 279 exceptionState.throwDOMException(InvalidStateError, "The database has no
t been opened."); |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 | 282 |
| 283 int permissions = DatabaseAuthorizer::ReadWriteMask; | 283 int permissions = DatabaseAuthorizer::ReadWriteMask; |
| 284 if (!m_database->databaseContext()->allowDatabaseAccess()) | 284 if (!m_database->getDatabaseContext()->allowDatabaseAccess()) |
| 285 permissions |= DatabaseAuthorizer::NoAccessMask; | 285 permissions |= DatabaseAuthorizer::NoAccessMask; |
| 286 else if (m_readOnly) | 286 else if (m_readOnly) |
| 287 permissions |= DatabaseAuthorizer::ReadOnlyMask; | 287 permissions |= DatabaseAuthorizer::ReadOnlyMask; |
| 288 | 288 |
| 289 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c
allbackError); | 289 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c
allbackError); |
| 290 m_backend->executeSQL(statement, sqlStatement, arguments, permissions); | 290 m_backend->executeSQL(statement, sqlStatement, arguments, permissions); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void SQLTransaction::executeSql(ScriptState* scriptState, const String& sqlState
ment, ExceptionState& exceptionState) | 293 void SQLTransaction::executeSql(ScriptState* scriptState, const String& sqlState
ment, ExceptionState& exceptionState) |
| 294 { | 294 { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 m_successCallback.clear(); | 332 m_successCallback.clear(); |
| 333 m_errorCallback.clear(); | 333 m_errorCallback.clear(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() | 336 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() |
| 337 { | 337 { |
| 338 return m_errorCallback.release(); | 338 return m_errorCallback.release(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |