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

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: Created 5 years, 10 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(const String& sqlStatement, const Vector<ScriptV alue>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* cal lbackError, 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 Vector<SQLValue> sqlArguments;
291 for (unsigned i = 0; i < arguments.size(); ++i) {
292 v8::Local<v8::Value> arg = arguments[i].v8Value();
293 if (arg.IsEmpty() || arg->IsNull()) {
294 sqlArguments.append(SQLValue());
295 } else if (arg->IsNumber()) {
296 sqlArguments.append(SQLValue(arg->NumberValue()));
297 } else {
298 String stringValue;
299 arguments[i].toString(stringValue);
300 sqlArguments.append(SQLValue(stringValue));
301 }
302 }
290 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c allbackError); 303 SQLStatement* statement = SQLStatement::create(m_database.get(), callback, c allbackError);
291 m_backend->executeSQL(statement, sqlStatement, arguments, permissions); 304 m_backend->executeSQL(statement, sqlStatement, sqlArguments, permissions);
305 }
306
307 void SQLTransaction::executeSql(const String& sqlStatement, ExceptionState& exce ptionState)
308 {
309 executeSql(sqlStatement, Vector<ScriptValue>(), nullptr, nullptr, exceptionS tate);
292 } 310 }
293 311
294 bool SQLTransaction::computeNextStateAndCleanupIfNeeded() 312 bool SQLTransaction::computeNextStateAndCleanupIfNeeded()
295 { 313 {
296 // Only honor the requested state transition if we're not supposed to be 314 // Only honor the requested state transition if we're not supposed to be
297 // cleaning up and shutting down: 315 // cleaning up and shutting down:
298 if (m_database->opened()) { 316 if (m_database->opened()) {
299 setStateToRequestedState(); 317 setStateToRequestedState();
300 ASSERT(m_nextState == SQLTransactionState::End 318 ASSERT(m_nextState == SQLTransactionState::End
301 || m_nextState == SQLTransactionState::DeliverTransactionCallback 319 || m_nextState == SQLTransactionState::DeliverTransactionCallback
(...skipping 18 matching lines...) Expand all
320 m_successCallback.clear(); 338 m_successCallback.clear();
321 m_errorCallback.clear(); 339 m_errorCallback.clear();
322 } 340 }
323 341
324 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() 342 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback()
325 { 343 {
326 return m_errorCallback.release(); 344 return m_errorCallback.release();
327 } 345 }
328 346
329 } // namespace blink 347 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698