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

Side by Side Diff: Source/modules/webdatabase/Database.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
« no previous file with comments | « Source/modules/webdatabase/Database.h ('k') | Source/modules/webdatabase/Database.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
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/Database.h" 30 #include "modules/webdatabase/Database.h"
31 31
32 #include "core/dom/CrossThreadTask.h" 32 #include "core/dom/CrossThreadTask.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/ExecutionContext.h" 34 #include "core/dom/ExecutionContext.h"
35 #include "core/html/VoidCallback.h"
36 #include "core/page/Page.h" 35 #include "core/page/Page.h"
37 #include "platform/Logging.h" 36 #include "platform/Logging.h"
38 #include "modules/webdatabase/sqlite/SQLiteStatement.h" 37 #include "modules/webdatabase/sqlite/SQLiteStatement.h"
39 #include "modules/webdatabase/ChangeVersionData.h" 38 #include "modules/webdatabase/ChangeVersionData.h"
40 #include "modules/webdatabase/DatabaseCallback.h" 39 #include "modules/webdatabase/DatabaseCallback.h"
41 #include "modules/webdatabase/DatabaseContext.h" 40 #include "modules/webdatabase/DatabaseContext.h"
42 #include "modules/webdatabase/DatabaseManager.h" 41 #include "modules/webdatabase/DatabaseManager.h"
43 #include "modules/webdatabase/DatabaseTask.h" 42 #include "modules/webdatabase/DatabaseTask.h"
44 #include "modules/webdatabase/DatabaseThread.h" 43 #include "modules/webdatabase/DatabaseThread.h"
45 #include "modules/webdatabase/DatabaseTracker.h" 44 #include "modules/webdatabase/DatabaseTracker.h"
46 #include "modules/webdatabase/SQLError.h" 45 #include "modules/webdatabase/SQLError.h"
47 #include "modules/webdatabase/SQLTransaction.h" 46 #include "modules/webdatabase/SQLTransaction.h"
48 #include "modules/webdatabase/SQLTransactionCallback.h" 47 #include "modules/webdatabase/SQLTransactionCallback.h"
49 #include "modules/webdatabase/SQLTransactionErrorCallback.h" 48 #include "modules/webdatabase/SQLTransactionErrorCallback.h"
49 #include "modules/webdatabase/SQLVoidCallback.h"
50 #include "platform/weborigin/SecurityOrigin.h" 50 #include "platform/weborigin/SecurityOrigin.h"
51 #include "wtf/OwnPtr.h" 51 #include "wtf/OwnPtr.h"
52 #include "wtf/PassOwnPtr.h" 52 #include "wtf/PassOwnPtr.h"
53 #include "wtf/PassRefPtr.h" 53 #include "wtf/PassRefPtr.h"
54 #include "wtf/RefPtr.h" 54 #include "wtf/RefPtr.h"
55 #include "wtf/StdLibExtras.h" 55 #include "wtf/StdLibExtras.h"
56 #include "wtf/text/CString.h" 56 #include "wtf/text/CString.h"
57 57
58 namespace WebCore { 58 namespace WebCore {
59 59
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void Database::closeImmediately() 133 void Database::closeImmediately()
134 { 134 {
135 ASSERT(m_executionContext->isContextThread()); 135 ASSERT(m_executionContext->isContextThread());
136 DatabaseThread* databaseThread = databaseContext()->databaseThread(); 136 DatabaseThread* databaseThread = databaseContext()->databaseThread();
137 if (databaseThread && !databaseThread->terminationRequested() && opened()) { 137 if (databaseThread && !databaseThread->terminationRequested() && opened()) {
138 logErrorMessage("forcibly closing database"); 138 logErrorMessage("forcibly closing database");
139 databaseThread->scheduleTask(DatabaseCloseTask::create(this, 0)); 139 databaseThread->scheduleTask(DatabaseCloseTask::create(this, 0));
140 } 140 }
141 } 141 }
142 142
143 void Database::changeVersion(const String& oldVersion, const String& newVersion, 143 void Database::changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCall back> errorCallback, PassRefPtr<SQLVoidCallback> successCallback)
144 PassRefPtr<SQLTransactionCallback> callback, PassRe fPtr<SQLTransactionErrorCallback> errorCallback,
145 PassRefPtr<VoidCallback> successCallback)
146 { 144 {
147 ChangeVersionData data(oldVersion, newVersion); 145 ChangeVersionData data(oldVersion, newVersion);
148 runTransaction(callback, errorCallback, successCallback, false, &data); 146 runTransaction(callback, errorCallback, successCallback, false, &data);
149 } 147 }
150 148
151 void Database::transaction(PassRefPtr<SQLTransactionCallback> callback, PassRefP tr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> successC allback) 149 void Database::transaction(PassRefPtr<SQLTransactionCallback> callback, PassRefP tr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<SQLVoidCallback> succe ssCallback)
152 { 150 {
153 runTransaction(callback, errorCallback, successCallback, false); 151 runTransaction(callback, errorCallback, successCallback, false);
154 } 152 }
155 153
156 void Database::readTransaction(PassRefPtr<SQLTransactionCallback> callback, Pass RefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<VoidCallback> succ essCallback) 154 void Database::readTransaction(PassRefPtr<SQLTransactionCallback> callback, Pass RefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<SQLVoidCallback> s uccessCallback)
157 { 155 {
158 runTransaction(callback, errorCallback, successCallback, true); 156 runTransaction(callback, errorCallback, successCallback, true);
159 } 157 }
160 158
161 static void callTransactionErrorCallback(ExecutionContext*, PassRefPtr<SQLTransa ctionErrorCallback> callback, PassRefPtr<SQLError> error) 159 static void callTransactionErrorCallback(ExecutionContext*, PassRefPtr<SQLTransa ctionErrorCallback> callback, PassRefPtr<SQLError> error)
162 { 160 {
163 callback->handleEvent(error.get()); 161 callback->handleEvent(error.get());
164 } 162 }
165 163
166 void Database::runTransaction(PassRefPtr<SQLTransactionCallback> callback, PassR efPtr<SQLTransactionErrorCallback> errorCallback, 164 void Database::runTransaction(PassRefPtr<SQLTransactionCallback> callback, PassR efPtr<SQLTransactionErrorCallback> errorCallback,
167 PassRefPtr<VoidCallback> successCallback, bool readOnly, const ChangeVersion Data* changeVersionData) 165 PassRefPtr<SQLVoidCallback> successCallback, bool readOnly, const ChangeVers ionData* changeVersionData)
168 { 166 {
169 RefPtr<SQLTransactionErrorCallback> anotherRefToErrorCallback = errorCallbac k; 167 RefPtr<SQLTransactionErrorCallback> anotherRefToErrorCallback = errorCallbac k;
170 RefPtr<SQLTransaction> transaction = SQLTransaction::create(this, callback, successCallback, anotherRefToErrorCallback, readOnly); 168 RefPtr<SQLTransaction> transaction = SQLTransaction::create(this, callback, successCallback, anotherRefToErrorCallback, readOnly);
171 169
172 RefPtr<SQLTransactionBackend> transactionBackend; 170 RefPtr<SQLTransactionBackend> transactionBackend;
173 transactionBackend = backend()->runTransaction(transaction.release(), readOn ly, changeVersionData); 171 transactionBackend = backend()->runTransaction(transaction.release(), readOn ly, changeVersionData);
174 if (!transactionBackend && anotherRefToErrorCallback) { 172 if (!transactionBackend && anotherRefToErrorCallback) {
175 RefPtr<SQLError> error = SQLError::create(SQLError::UNKNOWN_ERR, "databa se has been closed"); 173 RefPtr<SQLError> error = SQLError::create(SQLError::UNKNOWN_ERR, "databa se has been closed");
176 executionContext()->postTask(createCallbackTask(&callTransactionErrorCal lback, anotherRefToErrorCallback, error.release())); 174 executionContext()->postTask(createCallbackTask(&callTransactionErrorCal lback, anotherRefToErrorCallback, error.release()));
177 } 175 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteEr rorCode); 260 backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteEr rorCode);
263 } 261 }
264 262
265 void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode) 263 void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
266 { 264 {
267 backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteE rrorCode); 265 backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteE rrorCode);
268 } 266 }
269 267
270 268
271 } // namespace WebCore 269 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/Database.h ('k') | Source/modules/webdatabase/Database.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698