Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: Source/modules/webdatabase/SQLTransaction.cpp

Issue 949193002: [bindings] Remove SQLTransaction's usage of custom binding. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Introducing V8BindingForModules Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "modules/webdatabase/SQLTransaction.h" 30 #include "modules/webdatabase/SQLTransaction.h"
31 31
32 #include "bindings/core/v8/ExceptionState.h" 32 #include "bindings/core/v8/ExceptionState.h"
33 #include "bindings/modules/v8/V8BindingForModules.h"
33 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
34 #include "core/html/VoidCallback.h" 35 #include "core/html/VoidCallback.h"
35 #include "core/inspector/InspectorInstrumentation.h" 36 #include "core/inspector/InspectorInstrumentation.h"
36 #include "modules/webdatabase/Database.h" 37 #include "modules/webdatabase/Database.h"
37 #include "modules/webdatabase/DatabaseAuthorizer.h" 38 #include "modules/webdatabase/DatabaseAuthorizer.h"
38 #include "modules/webdatabase/DatabaseContext.h" 39 #include "modules/webdatabase/DatabaseContext.h"
39 #include "modules/webdatabase/SQLError.h" 40 #include "modules/webdatabase/SQLError.h"
40 #include "modules/webdatabase/SQLStatementCallback.h" 41 #include "modules/webdatabase/SQLStatementCallback.h"
41 #include "modules/webdatabase/SQLStatementErrorCallback.h" 42 #include "modules/webdatabase/SQLStatementErrorCallback.h"
42 #include "modules/webdatabase/SQLTransactionBackend.h" 43 #include "modules/webdatabase/SQLTransactionBackend.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 m_backend->requestTransitToState(m_nextState); 263 m_backend->requestTransitToState(m_nextState);
263 return SQLTransactionState::Idle; 264 return SQLTransactionState::Idle;
264 } 265 }
265 266
266 void SQLTransaction::performPendingCallback() 267 void SQLTransaction::performPendingCallback()
267 { 268 {
268 computeNextStateAndCleanupIfNeeded(); 269 computeNextStateAndCleanupIfNeeded();
269 runStateMachine(); 270 runStateMachine();
270 } 271 }
271 272
272 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu e>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* callba ckError, ExceptionState& exceptionState) 273 void SQLTransaction::executeSql(const String& sqlStatement, const Nullable<Vecto r<ScriptValue>>& arguments, SQLStatementCallback* callback, SQLStatementErrorCal lback* callbackError, ExceptionState& exceptionState)
273 { 274 {
274 if (!m_executeSqlAllowed) { 275 if (!m_executeSqlAllowed) {
275 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di sallowed."); 276 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di sallowed.");
276 return; 277 return;
277 } 278 }
278 279
279 if (!m_database->opened()) { 280 if (!m_database->opened()) {
280 exceptionState.throwDOMException(InvalidStateError, "The database has no t been opened."); 281 exceptionState.throwDOMException(InvalidStateError, "The database has no t been opened.");
281 return; 282 return;
282 } 283 }
283 284
284 int permissions = DatabaseAuthorizer::ReadWriteMask; 285 int permissions = DatabaseAuthorizer::ReadWriteMask;
285 if (!m_database->databaseContext()->allowDatabaseAccess()) 286 if (!m_database->databaseContext()->allowDatabaseAccess())
286 permissions |= DatabaseAuthorizer::NoAccessMask; 287 permissions |= DatabaseAuthorizer::NoAccessMask;
287 else if (m_readOnly) 288 else if (m_readOnly)
288 permissions |= DatabaseAuthorizer::ReadOnlyMask; 289 permissions |= DatabaseAuthorizer::ReadOnlyMask;
289 290
290 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c allbackError); 291 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c allbackError);
291 m_backend->executeSQL(statement, sqlStatement, arguments, permissions); 292 m_backend->executeSQL(statement, sqlStatement, toSQLValueArray(arguments), p ermissions);
293 }
294
295 void SQLTransaction::executeSql(const String& sqlStatement, ExceptionState& exce ptionState)
296 {
297 executeSql(sqlStatement, Vector<ScriptValue>(), nullptr, nullptr, exceptionS tate);
292 } 298 }
293 299
294 bool SQLTransaction::computeNextStateAndCleanupIfNeeded() 300 bool SQLTransaction::computeNextStateAndCleanupIfNeeded()
295 { 301 {
296 // Only honor the requested state transition if we're not supposed to be 302 // Only honor the requested state transition if we're not supposed to be
297 // cleaning up and shutting down: 303 // cleaning up and shutting down:
298 if (m_database->opened()) { 304 if (m_database->opened()) {
299 setStateToRequestedState(); 305 setStateToRequestedState();
300 ASSERT(m_nextState == SQLTransactionState::End 306 ASSERT(m_nextState == SQLTransactionState::End
301 || m_nextState == SQLTransactionState::DeliverTransactionCallback 307 || m_nextState == SQLTransactionState::DeliverTransactionCallback
(...skipping 18 matching lines...) Expand all
320 m_successCallback.clear(); 326 m_successCallback.clear();
321 m_errorCallback.clear(); 327 m_errorCallback.clear();
322 } 328 }
323 329
324 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() 330 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback()
325 { 331 {
326 return m_errorCallback.release(); 332 return m_errorCallback.release();
327 } 333 }
328 334
329 } // namespace blink 335 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698