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

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

Issue 561143002: Web SQL: Remove unnecessary abstraction. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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 15 matching lines...) Expand all
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 "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
34 #include "core/html/VoidCallback.h" 34 #include "core/html/VoidCallback.h"
35 #include "platform/Logging.h" 35 #include "platform/Logging.h"
36 #include "modules/webdatabase/AbstractSQLTransactionBackend.h"
37 #include "modules/webdatabase/Database.h" 36 #include "modules/webdatabase/Database.h"
38 #include "modules/webdatabase/DatabaseAuthorizer.h" 37 #include "modules/webdatabase/DatabaseAuthorizer.h"
39 #include "modules/webdatabase/DatabaseContext.h" 38 #include "modules/webdatabase/DatabaseContext.h"
40 #include "modules/webdatabase/SQLError.h" 39 #include "modules/webdatabase/SQLError.h"
41 #include "modules/webdatabase/SQLStatementCallback.h" 40 #include "modules/webdatabase/SQLStatementCallback.h"
42 #include "modules/webdatabase/SQLStatementErrorCallback.h" 41 #include "modules/webdatabase/SQLStatementErrorCallback.h"
42 #include "modules/webdatabase/SQLTransactionBackend.h"
43 #include "modules/webdatabase/SQLTransactionCallback.h" 43 #include "modules/webdatabase/SQLTransactionCallback.h"
44 #include "modules/webdatabase/SQLTransactionClient.h" // FIXME: Should be used i n the backend only. 44 #include "modules/webdatabase/SQLTransactionClient.h" // FIXME: Should be used i n the backend only.
45 #include "modules/webdatabase/SQLTransactionErrorCallback.h" 45 #include "modules/webdatabase/SQLTransactionErrorCallback.h"
46 #include "wtf/StdLibExtras.h" 46 #include "wtf/StdLibExtras.h"
47 #include "wtf/Vector.h" 47 #include "wtf/Vector.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 PassRefPtrWillBeRawPtr<SQLTransaction> SQLTransaction::create(Database* db, Pass OwnPtrWillBeRawPtr<SQLTransactionCallback> callback, 51 PassRefPtrWillBeRawPtr<SQLTransaction> SQLTransaction::create(Database* db, Pass OwnPtrWillBeRawPtr<SQLTransactionCallback> callback,
52 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr <SQLTransactionErrorCallback> errorCallback, 52 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr <SQLTransactionErrorCallback> errorCallback,
53 bool readOnly) 53 bool readOnly)
54 { 54 {
55 return adoptRefWillBeNoop(new SQLTransaction(db, callback, successCallback, errorCallback, readOnly)); 55 return adoptRefWillBeNoop(new SQLTransaction(db, callback, successCallback, errorCallback, readOnly));
56 } 56 }
57 57
58 SQLTransaction::SQLTransaction(Database* db, PassOwnPtrWillBeRawPtr<SQLTransacti onCallback> callback, 58 SQLTransaction::SQLTransaction(Database* db, PassOwnPtrWillBeRawPtr<SQLTransacti onCallback> callback,
59 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr <SQLTransactionErrorCallback> errorCallback, 59 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr <SQLTransactionErrorCallback> errorCallback,
60 bool readOnly) 60 bool readOnly)
61 : m_database(db) 61 : m_database(db)
62 , m_callbackWrapper(callback, db->executionContext()) 62 , m_callbackWrapper(callback, db->executionContext())
63 , m_successCallbackWrapper(successCallback, db->executionContext()) 63 , m_successCallbackWrapper(successCallback, db->executionContext())
64 , m_errorCallbackWrapper(errorCallback, db->executionContext()) 64 , m_errorCallbackWrapper(errorCallback, db->executionContext())
65 , m_executeSqlAllowed(false) 65 , m_executeSqlAllowed(false)
66 , m_readOnly(readOnly) 66 , m_readOnly(readOnly)
67 { 67 {
68 ASSERT(m_database); 68 ASSERT(m_database);
69 } 69 }
70 70
71 SQLTransaction::~SQLTransaction()
72 {
73 }
74
71 void SQLTransaction::trace(Visitor* visitor) 75 void SQLTransaction::trace(Visitor* visitor)
72 { 76 {
73 visitor->trace(m_database); 77 visitor->trace(m_database);
74 visitor->trace(m_backend); 78 visitor->trace(m_backend);
75 visitor->trace(m_callbackWrapper); 79 visitor->trace(m_callbackWrapper);
76 visitor->trace(m_successCallbackWrapper); 80 visitor->trace(m_successCallbackWrapper);
77 visitor->trace(m_errorCallbackWrapper); 81 visitor->trace(m_errorCallbackWrapper);
78 AbstractSQLTransaction::trace(visitor);
79 } 82 }
80 83
81 bool SQLTransaction::hasCallback() const 84 bool SQLTransaction::hasCallback() const
82 { 85 {
83 return m_callbackWrapper.hasCallback(); 86 return m_callbackWrapper.hasCallback();
84 } 87 }
85 88
86 bool SQLTransaction::hasSuccessCallback() const 89 bool SQLTransaction::hasSuccessCallback() const
87 { 90 {
88 return m_successCallbackWrapper.hasCallback(); 91 return m_successCallbackWrapper.hasCallback();
89 } 92 }
90 93
91 bool SQLTransaction::hasErrorCallback() const 94 bool SQLTransaction::hasErrorCallback() const
92 { 95 {
93 return m_errorCallbackWrapper.hasCallback(); 96 return m_errorCallbackWrapper.hasCallback();
94 } 97 }
95 98
96 void SQLTransaction::setBackend(AbstractSQLTransactionBackend* backend) 99 void SQLTransaction::setBackend(SQLTransactionBackend* backend)
97 { 100 {
98 ASSERT(!m_backend); 101 ASSERT(!m_backend);
99 m_backend = backend; 102 m_backend = backend;
100 } 103 }
101 104
102 SQLTransaction::StateFunction SQLTransaction::stateFunctionFor(SQLTransactionSta te state) 105 SQLTransaction::StateFunction SQLTransaction::stateFunctionFor(SQLTransactionSta te state)
103 { 106 {
104 static const StateFunction stateFunctions[] = { 107 static const StateFunction stateFunctions[] = {
105 &SQLTransaction::unreachableState, // 0. illegal 108 &SQLTransaction::unreachableState, // 0. illegal
106 &SQLTransaction::unreachableState, // 1. idle 109 &SQLTransaction::unreachableState, // 1. idle
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Spec 4.3.2.10: Rollback the transaction. 196 // Spec 4.3.2.10: Rollback the transaction.
194 return SQLTransactionState::CleanupAfterTransactionErrorCallback; 197 return SQLTransactionState::CleanupAfterTransactionErrorCallback;
195 } 198 }
196 199
197 SQLTransactionState SQLTransaction::deliverStatementCallback() 200 SQLTransactionState SQLTransaction::deliverStatementCallback()
198 { 201 {
199 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback 202 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback
200 // Otherwise, continue to loop through the statement queue 203 // Otherwise, continue to loop through the statement queue
201 m_executeSqlAllowed = true; 204 m_executeSqlAllowed = true;
202 205
203 AbstractSQLStatement* currentAbstractStatement = m_backend->currentStatement (); 206 SQLStatement* currentStatement = m_backend->currentStatement();
204 SQLStatement* currentStatement = static_cast<SQLStatement*>(currentAbstractS tatement);
205 ASSERT(currentStatement); 207 ASSERT(currentStatement);
206 208
207 bool result = currentStatement->performCallback(this); 209 bool result = currentStatement->performCallback(this);
208 210
209 m_executeSqlAllowed = false; 211 m_executeSqlAllowed = false;
210 212
211 if (result) { 213 if (result) {
212 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0); 214 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0);
213 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the st atement callback raised an exception or statement error callback did not return false"); 215 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the st atement callback raised an exception or statement error callback did not return false");
214 return nextStateForTransactionError(); 216 return nextStateForTransactionError();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 m_successCallbackWrapper.clear(); 316 m_successCallbackWrapper.clear();
315 m_errorCallbackWrapper.clear(); 317 m_errorCallbackWrapper.clear();
316 } 318 }
317 319
318 PassOwnPtrWillBeRawPtr<SQLTransactionErrorCallback> SQLTransaction::releaseError Callback() 320 PassOwnPtrWillBeRawPtr<SQLTransactionErrorCallback> SQLTransaction::releaseError Callback()
319 { 321 {
320 return m_errorCallbackWrapper.unwrap(); 322 return m_errorCallbackWrapper.unwrap();
321 } 323 }
322 324
323 } // namespace blink 325 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698