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

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

Issue 563703002: Oilpan: Enable oilpan for callback classes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 30 matching lines...) Expand all
41 #include "modules/webdatabase/SQLTransactionBackend.h" 41 #include "modules/webdatabase/SQLTransactionBackend.h"
42 #include "modules/webdatabase/SQLTransactionCallback.h" 42 #include "modules/webdatabase/SQLTransactionCallback.h"
43 #include "modules/webdatabase/SQLTransactionClient.h" // FIXME: Should be used i n the backend only. 43 #include "modules/webdatabase/SQLTransactionClient.h" // FIXME: Should be used i n the backend only.
44 #include "modules/webdatabase/SQLTransactionErrorCallback.h" 44 #include "modules/webdatabase/SQLTransactionErrorCallback.h"
45 #include "platform/Logging.h" 45 #include "platform/Logging.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, SQLT ransactionCallback* callback,
52 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr <SQLTransactionErrorCallback> errorCallback, 52 VoidCallback* successCallback, 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, SQLTransactionCallback* callback,
59 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr <SQLTransactionErrorCallback> errorCallback, 59 VoidCallback* successCallback, 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 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // No error callback, so fast-forward to: 145 // No error callback, so fast-forward to:
146 // Transaction Step 11 - Rollback the transaction. 146 // Transaction Step 11 - Rollback the transaction.
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 OwnPtrWillBeRawPtr<SQLTransactionCallback> callback = m_callbackWrapper.unwr ap(); 155 SQLTransactionCallback* callback = m_callbackWrapper.unwrap();
156 if (callback) { 156 if (callback) {
157 m_executeSqlAllowed = true; 157 m_executeSqlAllowed = true;
158 shouldDeliverErrorCallback = !callback->handleEvent(this); 158 shouldDeliverErrorCallback = !callback->handleEvent(this);
159 m_executeSqlAllowed = false; 159 m_executeSqlAllowed = false;
160 } 160 }
161 161
162 // Spec 4.3.2 5: If the transaction callback was null or raised an exception , jump to the error callback 162 // Spec 4.3.2 5: If the transaction callback was null or raised an exception , jump to the error callback
163 SQLTransactionState nextState = SQLTransactionState::RunStatements; 163 SQLTransactionState nextState = SQLTransactionState::RunStatements;
164 if (shouldDeliverErrorCallback) { 164 if (shouldDeliverErrorCallback) {
165 m_database->reportStartTransactionResult(5, SQLError::UNKNOWN_ERR, 0); 165 m_database->reportStartTransactionResult(5, SQLError::UNKNOWN_ERR, 0);
166 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the SQ LTransactionCallback was null or threw an exception"); 166 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the SQ LTransactionCallback was null or threw an exception");
167 nextState = SQLTransactionState::DeliverTransactionErrorCallback; 167 nextState = SQLTransactionState::DeliverTransactionErrorCallback;
168 } 168 }
169 m_database->reportStartTransactionResult(0, -1, 0); // OK 169 m_database->reportStartTransactionResult(0, -1, 0); // OK
170 return nextState; 170 return nextState;
171 } 171 }
172 172
173 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() 173 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback()
174 { 174 {
175 // Spec 4.3.2.10: If exists, invoke error callback with the last 175 // Spec 4.3.2.10: If exists, invoke error callback with the last
176 // error to have occurred in this transaction. 176 // error to have occurred in this transaction.
177 OwnPtrWillBeRawPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallb ackWrapper.unwrap(); 177 SQLTransactionErrorCallback* errorCallback = m_errorCallbackWrapper.unwrap() ;
178 if (errorCallback) { 178 if (errorCallback) {
179 // If we get here with an empty m_transactionError, then the backend 179 // If we get here with an empty m_transactionError, then the backend
180 // must be waiting in the idle state waiting for this state to finish. 180 // must be waiting in the idle state waiting for this state to finish.
181 // Hence, it's thread safe to fetch the backend transactionError without 181 // Hence, it's thread safe to fetch the backend transactionError without
182 // a lock. 182 // a lock.
183 if (!m_transactionError) { 183 if (!m_transactionError) {
184 ASSERT(m_backend->transactionError()); 184 ASSERT(m_backend->transactionError());
185 m_transactionError = SQLErrorData::create(*m_backend->transactionErr or()); 185 m_transactionError = SQLErrorData::create(*m_backend->transactionErr or());
186 } 186 }
187 ASSERT(m_transactionError); 187 ASSERT(m_transactionError);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database()); 225 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database());
226 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement); 226 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement);
227 227
228 return SQLTransactionState::RunStatements; 228 return SQLTransactionState::RunStatements;
229 } 229 }
230 230
231 SQLTransactionState SQLTransaction::deliverSuccessCallback() 231 SQLTransactionState SQLTransaction::deliverSuccessCallback()
232 { 232 {
233 // Spec 4.3.2.8: Deliver success callback. 233 // Spec 4.3.2.8: Deliver success callback.
234 OwnPtrWillBeRawPtr<VoidCallback> successCallback = m_successCallbackWrapper. unwrap(); 234 VoidCallback* successCallback = m_successCallbackWrapper.unwrap();
235 if (successCallback) 235 if (successCallback)
236 successCallback->handleEvent(); 236 successCallback->handleEvent();
237 237
238 clearCallbackWrappers(); 238 clearCallbackWrappers();
239 239
240 // Schedule a "post-success callback" step to return control to the database thread in case there 240 // Schedule a "post-success callback" step to return control to the database thread in case there
241 // are further transactions queued up for this Database 241 // are further transactions queued up for this Database
242 return SQLTransactionState::CleanupAndTerminate; 242 return SQLTransactionState::CleanupAndTerminate;
243 } 243 }
244 244
(...skipping 12 matching lines...) Expand all
257 m_backend->requestTransitToState(m_nextState); 257 m_backend->requestTransitToState(m_nextState);
258 return SQLTransactionState::Idle; 258 return SQLTransactionState::Idle;
259 } 259 }
260 260
261 void SQLTransaction::performPendingCallback() 261 void SQLTransaction::performPendingCallback()
262 { 262 {
263 computeNextStateAndCleanupIfNeeded(); 263 computeNextStateAndCleanupIfNeeded();
264 runStateMachine(); 264 runStateMachine();
265 } 265 }
266 266
267 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu e>& arguments, PassOwnPtrWillBeRawPtr<SQLStatementCallback> callback, PassOwnPtr WillBeRawPtr<SQLStatementErrorCallback> callbackError, ExceptionState& exception State) 267 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu e>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* callba ckError, ExceptionState& exceptionState)
268 { 268 {
269 if (!m_executeSqlAllowed) { 269 if (!m_executeSqlAllowed) {
270 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di sallowed."); 270 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di sallowed.");
271 return; 271 return;
272 } 272 }
273 273
274 if (!m_database->opened()) { 274 if (!m_database->opened()) {
275 exceptionState.throwDOMException(InvalidStateError, "The database has no t been opened."); 275 exceptionState.throwDOMException(InvalidStateError, "The database has no t been opened.");
276 return; 276 return;
277 } 277 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 void SQLTransaction::clearCallbackWrappers() 312 void SQLTransaction::clearCallbackWrappers()
313 { 313 {
314 // Release the unneeded callbacks, to break reference cycles. 314 // Release the unneeded callbacks, to break reference cycles.
315 m_callbackWrapper.clear(); 315 m_callbackWrapper.clear();
316 m_successCallbackWrapper.clear(); 316 m_successCallbackWrapper.clear();
317 m_errorCallbackWrapper.clear(); 317 m_errorCallbackWrapper.clear();
318 } 318 }
319 319
320 PassOwnPtrWillBeRawPtr<SQLTransactionErrorCallback> SQLTransaction::releaseError Callback() 320 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback()
321 { 321 {
322 return m_errorCallbackWrapper.unwrap(); 322 return m_errorCallbackWrapper.unwrap();
323 } 323 }
324 324
325 } // namespace blink 325 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/SQLTransaction.h ('k') | Source/modules/webdatabase/SQLTransactionCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698