OLD | NEW |
---|---|
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCall back> errorCallback, PassRefPtr<SQLVoidCallback> successCallback) | 143 void Database::changeVersion(const String& oldVersion, const String& newVersion, PassOwnPtr<SQLTransactionCallback> callback, PassOwnPtr<SQLTransactionErrorCall back> errorCallback, PassOwnPtr<SQLVoidCallback> successCallback) |
144 { | 144 { |
145 ChangeVersionData data(oldVersion, newVersion); | 145 ChangeVersionData data(oldVersion, newVersion); |
146 runTransaction(callback, errorCallback, successCallback, false, &data); | 146 runTransaction(callback, errorCallback, successCallback, false, &data); |
147 } | 147 } |
148 | 148 |
149 void Database::transaction(PassRefPtr<SQLTransactionCallback> callback, PassRefP tr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<SQLVoidCallback> succe ssCallback) | 149 void Database::transaction(PassOwnPtr<SQLTransactionCallback> callback, PassOwnP tr<SQLTransactionErrorCallback> errorCallback, PassOwnPtr<SQLVoidCallback> succe ssCallback) |
150 { | 150 { |
151 runTransaction(callback, errorCallback, successCallback, false); | 151 runTransaction(callback, errorCallback, successCallback, false); |
152 } | 152 } |
153 | 153 |
154 void Database::readTransaction(PassRefPtr<SQLTransactionCallback> callback, Pass RefPtr<SQLTransactionErrorCallback> errorCallback, PassRefPtr<SQLVoidCallback> s uccessCallback) | 154 void Database::readTransaction(PassOwnPtr<SQLTransactionCallback> callback, Pass OwnPtr<SQLTransactionErrorCallback> errorCallback, PassOwnPtr<SQLVoidCallback> s uccessCallback) |
155 { | 155 { |
156 runTransaction(callback, errorCallback, successCallback, true); | 156 runTransaction(callback, errorCallback, successCallback, true); |
157 } | 157 } |
158 | 158 |
159 static void callTransactionErrorCallback(ExecutionContext*, PassRefPtr<SQLTransa ctionErrorCallback> callback, PassRefPtr<SQLError> error) | 159 static void callTransactionErrorCallback(ExecutionContext*, PassOwnPtr<SQLTransa ctionErrorCallback> callback, PassRefPtr<SQLError> error) |
160 { | 160 { |
161 callback->handleEvent(error.get()); | 161 callback->handleEvent(error.get()); |
162 } | 162 } |
163 | 163 |
164 void Database::runTransaction(PassRefPtr<SQLTransactionCallback> callback, PassR efPtr<SQLTransactionErrorCallback> errorCallback, | 164 void Database::runTransaction(PassOwnPtr<SQLTransactionCallback> callback, PassO wnPtr<SQLTransactionErrorCallback> errorCallback, |
165 PassRefPtr<SQLVoidCallback> successCallback, bool readOnly, const ChangeVers ionData* changeVersionData) | 165 PassOwnPtr<SQLVoidCallback> successCallback, bool readOnly, const ChangeVers ionData* changeVersionData) |
166 { | 166 { |
167 RefPtr<SQLTransactionErrorCallback> anotherRefToErrorCallback = errorCallbac k; | 167 RefPtr<SQLTransaction> transaction = SQLTransaction::create(this, callback, successCallback, errorCallback, readOnly); |
168 RefPtr<SQLTransaction> transaction = SQLTransaction::create(this, callback, successCallback, anotherRefToErrorCallback, readOnly); | |
169 | |
170 RefPtr<SQLTransactionBackend> transactionBackend; | 168 RefPtr<SQLTransactionBackend> transactionBackend; |
171 transactionBackend = backend()->runTransaction(transaction.release(), readOn ly, changeVersionData); | 169 transactionBackend = backend()->runTransaction(transaction, readOnly, change VersionData); |
abarth-chromium
2013/12/04 01:55:50
Combine this line with the previous one?
adamk
2013/12/04 02:08:26
Done.
| |
172 if (!transactionBackend && anotherRefToErrorCallback) { | 170 if (!transactionBackend) { |
173 RefPtr<SQLError> error = SQLError::create(SQLError::UNKNOWN_ERR, "databa se has been closed"); | 171 if (OwnPtr<SQLTransactionErrorCallback> callback = transaction->releaseE rrorCallback()) { |
abarth-chromium
2013/12/04 01:55:50
Will this always be non-zero if errorCallback was
adamk
2013/12/04 02:08:26
Added an ASSERT, but it's ugly. Also added a FIXME
| |
174 executionContext()->postTask(createCallbackTask(&callTransactionErrorCal lback, anotherRefToErrorCallback, error.release())); | 172 RefPtr<SQLError> error = SQLError::create(SQLError::UNKNOWN_ERR, "da tabase has been closed"); |
173 executionContext()->postTask(createCallbackTask(&callTransactionErro rCallback, callback.release(), error.release())); | |
174 } | |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 class DeliverPendingCallbackTask : public ExecutionContextTask { | 178 class DeliverPendingCallbackTask : public ExecutionContextTask { |
179 public: | 179 public: |
180 static PassOwnPtr<DeliverPendingCallbackTask> create(PassRefPtr<SQLTransacti on> transaction) | 180 static PassOwnPtr<DeliverPendingCallbackTask> create(PassRefPtr<SQLTransacti on> transaction) |
181 { | 181 { |
182 return adoptPtr(new DeliverPendingCallbackTask(transaction)); | 182 return adoptPtr(new DeliverPendingCallbackTask(transaction)); |
183 } | 183 } |
184 | 184 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteEr rorCode); | 260 backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteEr rorCode); |
261 } | 261 } |
262 | 262 |
263 void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode) | 263 void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode) |
264 { | 264 { |
265 backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteE rrorCode); | 265 backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteE rrorCode); |
266 } | 266 } |
267 | 267 |
268 | 268 |
269 } // namespace WebCore | 269 } // namespace WebCore |
OLD | NEW |