| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 m_backend->requestTransitToState(m_nextState); | 262 m_backend->requestTransitToState(m_nextState); |
| 263 return SQLTransactionState::Idle; | 263 return SQLTransactionState::Idle; |
| 264 } | 264 } |
| 265 | 265 |
| 266 void SQLTransaction::performPendingCallback() | 266 void SQLTransaction::performPendingCallback() |
| 267 { | 267 { |
| 268 computeNextStateAndCleanupIfNeeded(); | 268 computeNextStateAndCleanupIfNeeded(); |
| 269 runStateMachine(); | 269 runStateMachine(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu
e>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* callba
ckError, ExceptionState& exceptionState) | 272 void SQLTransaction::executeSql(ScriptState* scriptState, const String& sqlState
ment, const Nullable<Vector<ScriptValue>>& arguments, SQLStatementCallback* call
back, SQLStatementErrorCallback* callbackError, ExceptionState& exceptionState) |
| 273 { | 273 { |
| 274 if (!m_executeSqlAllowed) { | 274 if (!m_executeSqlAllowed) { |
| 275 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di
sallowed."); | 275 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di
sallowed."); |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 | 278 |
| 279 if (!m_database->opened()) { | 279 if (!m_database->opened()) { |
| 280 exceptionState.throwDOMException(InvalidStateError, "The database has no
t been opened."); | 280 exceptionState.throwDOMException(InvalidStateError, "The database has no
t been opened."); |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 | 283 |
| 284 int permissions = DatabaseAuthorizer::ReadWriteMask; | 284 int permissions = DatabaseAuthorizer::ReadWriteMask; |
| 285 if (!m_database->databaseContext()->allowDatabaseAccess()) | 285 if (!m_database->databaseContext()->allowDatabaseAccess()) |
| 286 permissions |= DatabaseAuthorizer::NoAccessMask; | 286 permissions |= DatabaseAuthorizer::NoAccessMask; |
| 287 else if (m_readOnly) | 287 else if (m_readOnly) |
| 288 permissions |= DatabaseAuthorizer::ReadOnlyMask; | 288 permissions |= DatabaseAuthorizer::ReadOnlyMask; |
| 289 | 289 |
| 290 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c
allbackError); | 290 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c
allbackError); |
| 291 m_backend->executeSQL(statement, sqlStatement, arguments, permissions); | 291 Vector<SQLValue> sqlValues; |
| 292 if (!arguments.isNull()) |
| 293 sqlValues = toImplArray<SQLValue>(arguments.get(), scriptState->isolate(
), exceptionState); |
| 294 |
| 295 m_backend->executeSQL(statement, sqlStatement, sqlValues, permissions); |
| 296 } |
| 297 |
| 298 void SQLTransaction::executeSql(ScriptState* scriptState, const String& sqlState
ment, ExceptionState& exceptionState) |
| 299 { |
| 300 executeSql(scriptState, sqlStatement, Vector<ScriptValue>(), nullptr, nullpt
r, exceptionState); |
| 292 } | 301 } |
| 293 | 302 |
| 294 bool SQLTransaction::computeNextStateAndCleanupIfNeeded() | 303 bool SQLTransaction::computeNextStateAndCleanupIfNeeded() |
| 295 { | 304 { |
| 296 // Only honor the requested state transition if we're not supposed to be | 305 // Only honor the requested state transition if we're not supposed to be |
| 297 // cleaning up and shutting down: | 306 // cleaning up and shutting down: |
| 298 if (m_database->opened()) { | 307 if (m_database->opened()) { |
| 299 setStateToRequestedState(); | 308 setStateToRequestedState(); |
| 300 ASSERT(m_nextState == SQLTransactionState::End | 309 ASSERT(m_nextState == SQLTransactionState::End |
| 301 || m_nextState == SQLTransactionState::DeliverTransactionCallback | 310 || m_nextState == SQLTransactionState::DeliverTransactionCallback |
| (...skipping 18 matching lines...) Expand all Loading... |
| 320 m_successCallback.clear(); | 329 m_successCallback.clear(); |
| 321 m_errorCallback.clear(); | 330 m_errorCallback.clear(); |
| 322 } | 331 } |
| 323 | 332 |
| 324 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() | 333 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() |
| 325 { | 334 { |
| 326 return m_errorCallback.release(); | 335 return m_errorCallback.release(); |
| 327 } | 336 } |
| 328 | 337 |
| 329 } // namespace blink | 338 } // namespace blink |
| OLD | NEW |