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

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

Issue 103083002: Decouple FileSystem and WebSQL callbacks from VoidCallback and it non-refcounted (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 13 matching lines...) Expand all
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/v8/ExceptionState.h" 32 #include "bindings/v8/ExceptionState.h"
33 #include "core/dom/ExceptionCode.h" 33 #include "core/dom/ExceptionCode.h"
34 #include "core/html/VoidCallback.h"
35 #include "platform/Logging.h" 34 #include "platform/Logging.h"
36 #include "modules/webdatabase/AbstractSQLTransactionBackend.h" 35 #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"
43 #include "modules/webdatabase/SQLTransactionCallback.h" 42 #include "modules/webdatabase/SQLTransactionCallback.h"
44 #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.
45 #include "modules/webdatabase/SQLTransactionErrorCallback.h" 44 #include "modules/webdatabase/SQLTransactionErrorCallback.h"
45 #include "modules/webdatabase/SQLVoidCallback.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 WebCore { 49 namespace WebCore {
50 50
51 PassRefPtr<SQLTransaction> SQLTransaction::create(Database* db, PassRefPtr<SQLTr ansactionCallback> callback, 51 PassRefPtr<SQLTransaction> SQLTransaction::create(Database* db, PassRefPtr<SQLTr ansactionCallback> callback,
52 PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCall back> errorCallback, 52 PassRefPtr<SQLVoidCallback> successCallback, PassRefPtr<SQLTransactionErrorC allback> errorCallback,
53 bool readOnly) 53 bool readOnly)
54 { 54 {
55 return adoptRef(new SQLTransaction(db, callback, successCallback, errorCallb ack, readOnly)); 55 return adoptRef(new SQLTransaction(db, callback, successCallback, errorCallb ack, readOnly));
56 } 56 }
57 57
58 SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> callback, 58 SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> callback,
59 PassRefPtr<VoidCallback> successCallback, PassRefPtr<SQLTransactionErrorCall back> errorCallback, 59 PassRefPtr<SQLVoidCallback> successCallback, PassRefPtr<SQLTransactionErrorC allback> 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 ScriptWrappable::init(this); 69 ScriptWrappable::init(this);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database()); 212 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database());
213 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement); 213 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement);
214 214
215 return SQLTransactionState::RunStatements; 215 return SQLTransactionState::RunStatements;
216 } 216 }
217 217
218 SQLTransactionState SQLTransaction::deliverSuccessCallback() 218 SQLTransactionState SQLTransaction::deliverSuccessCallback()
219 { 219 {
220 // Spec 4.3.2.8: Deliver success callback. 220 // Spec 4.3.2.8: Deliver success callback.
221 RefPtr<VoidCallback> successCallback = m_successCallbackWrapper.unwrap(); 221 RefPtr<SQLVoidCallback> successCallback = m_successCallbackWrapper.unwrap();
222 if (successCallback) 222 if (successCallback)
223 successCallback->handleEvent(); 223 successCallback->handleEvent();
224 224
225 clearCallbackWrappers(); 225 clearCallbackWrappers();
226 226
227 // Schedule a "post-success callback" step to return control to the database thread in case there 227 // Schedule a "post-success callback" step to return control to the database thread in case there
228 // are further transactions queued up for this Database 228 // are further transactions queued up for this Database
229 return SQLTransactionState::CleanupAndTerminate; 229 return SQLTransactionState::CleanupAndTerminate;
230 } 230 }
231 231
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 void SQLTransaction::clearCallbackWrappers() 294 void SQLTransaction::clearCallbackWrappers()
295 { 295 {
296 // Release the unneeded callbacks, to break reference cycles. 296 // Release the unneeded callbacks, to break reference cycles.
297 m_callbackWrapper.clear(); 297 m_callbackWrapper.clear();
298 m_successCallbackWrapper.clear(); 298 m_successCallbackWrapper.clear();
299 m_errorCallbackWrapper.clear(); 299 m_errorCallbackWrapper.clear();
300 } 300 }
301 301
302 } // namespace WebCore 302 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/SQLTransaction.h ('k') | Source/modules/webdatabase/SQLVoidCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698