| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void Database::transaction(PassOwnPtr<SQLTransactionCallback> callback, PassOwnP
tr<SQLTransactionErrorCallback> errorCallback, PassOwnPtr<VoidCallback> successC
allback) | 122 void Database::transaction(PassOwnPtr<SQLTransactionCallback> callback, PassOwnP
tr<SQLTransactionErrorCallback> errorCallback, PassOwnPtr<VoidCallback> successC
allback) |
| 123 { | 123 { |
| 124 runTransaction(callback, errorCallback, successCallback, false); | 124 runTransaction(callback, errorCallback, successCallback, false); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void Database::readTransaction(PassOwnPtr<SQLTransactionCallback> callback, Pass
OwnPtr<SQLTransactionErrorCallback> errorCallback, PassOwnPtr<VoidCallback> succ
essCallback) | 127 void Database::readTransaction(PassOwnPtr<SQLTransactionCallback> callback, Pass
OwnPtr<SQLTransactionErrorCallback> errorCallback, PassOwnPtr<VoidCallback> succ
essCallback) |
| 128 { | 128 { |
| 129 runTransaction(callback, errorCallback, successCallback, true); | 129 runTransaction(callback, errorCallback, successCallback, true); |
| 130 } | 130 } |
| 131 | 131 |
| 132 static void callTransactionErrorCallback(ExecutionContext*, PassOwnPtr<SQLTransa
ctionErrorCallback> callback, PassRefPtr<SQLError> error) | 132 static void callTransactionErrorCallback(ExecutionContext*, PassOwnPtr<SQLTransa
ctionErrorCallback> callback, PassOwnPtr<SQLErrorData> errorData) |
| 133 { | 133 { |
| 134 RefPtrWillBeRawPtr<SQLError> error = SQLError::create(*errorData); |
| 134 callback->handleEvent(error.get()); | 135 callback->handleEvent(error.get()); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void Database::runTransaction(PassOwnPtr<SQLTransactionCallback> callback, PassO
wnPtr<SQLTransactionErrorCallback> errorCallback, | 138 void Database::runTransaction(PassOwnPtr<SQLTransactionCallback> callback, PassO
wnPtr<SQLTransactionErrorCallback> errorCallback, |
| 138 PassOwnPtr<VoidCallback> successCallback, bool readOnly, const ChangeVersion
Data* changeVersionData) | 139 PassOwnPtr<VoidCallback> successCallback, bool readOnly, const ChangeVersion
Data* changeVersionData) |
| 139 { | 140 { |
| 140 // FIXME: Rather than passing errorCallback to SQLTransaction and then somet
imes firing it ourselves, | 141 // FIXME: Rather than passing errorCallback to SQLTransaction and then somet
imes firing it ourselves, |
| 141 // this code should probably be pushed down into DatabaseBackend so that we
only create the SQLTransaction | 142 // this code should probably be pushed down into DatabaseBackend so that we
only create the SQLTransaction |
| 142 // if we're actually going to run it. | 143 // if we're actually going to run it. |
| 143 #if !ASSERT_DISABLED | 144 #if !ASSERT_DISABLED |
| 144 SQLTransactionErrorCallback* originalErrorCallback = errorCallback.get(); | 145 SQLTransactionErrorCallback* originalErrorCallback = errorCallback.get(); |
| 145 #endif | 146 #endif |
| 146 RefPtrWillBeRawPtr<SQLTransaction> transaction = SQLTransaction::create(this
, callback, successCallback, errorCallback, readOnly); | 147 RefPtrWillBeRawPtr<SQLTransaction> transaction = SQLTransaction::create(this
, callback, successCallback, errorCallback, readOnly); |
| 147 RefPtrWillBeRawPtr<SQLTransactionBackend> transactionBackend = backend()->ru
nTransaction(transaction, readOnly, changeVersionData); | 148 RefPtrWillBeRawPtr<SQLTransactionBackend> transactionBackend = backend()->ru
nTransaction(transaction, readOnly, changeVersionData); |
| 148 if (!transactionBackend) { | 149 if (!transactionBackend) { |
| 149 OwnPtr<SQLTransactionErrorCallback> callback = transaction->releaseError
Callback(); | 150 OwnPtr<SQLTransactionErrorCallback> callback = transaction->releaseError
Callback(); |
| 150 ASSERT(callback == originalErrorCallback); | 151 ASSERT(callback == originalErrorCallback); |
| 151 if (callback) { | 152 if (callback) { |
| 152 RefPtr<SQLError> error = SQLError::create(SQLError::UNKNOWN_ERR, "da
tabase has been closed"); | 153 OwnPtr<SQLErrorData> error = SQLErrorData::create(SQLError::UNKNOWN_
ERR, "database has been closed"); |
| 153 executionContext()->postTask(createCallbackTask(&callTransactionErro
rCallback, callback.release(), error.release())); | 154 executionContext()->postTask(createCallbackTask(&callTransactionErro
rCallback, callback.release(), error.release())); |
| 154 } | 155 } |
| 155 } | 156 } |
| 156 } | 157 } |
| 157 | 158 |
| 158 // This object is constructed in a database thread, and destructed in the | 159 // This object is constructed in a database thread, and destructed in the |
| 159 // context thread. | 160 // context thread. |
| 160 class DeliverPendingCallbackTask FINAL : public ExecutionContextTask { | 161 class DeliverPendingCallbackTask FINAL : public ExecutionContextTask { |
| 161 public: | 162 public: |
| 162 static PassOwnPtr<DeliverPendingCallbackTask> create(PassRefPtrWillBeRawPtr<
SQLTransaction> transaction) | 163 static PassOwnPtr<DeliverPendingCallbackTask> create(PassRefPtrWillBeRawPtr<
SQLTransaction> transaction) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteEr
rorCode); | 243 backend()->reportStartTransactionResult(errorSite, webSqlErrorCode, sqliteEr
rorCode); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode,
int sqliteErrorCode) | 246 void Database::reportCommitTransactionResult(int errorSite, int webSqlErrorCode,
int sqliteErrorCode) |
| 246 { | 247 { |
| 247 backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteE
rrorCode); | 248 backend()->reportCommitTransactionResult(errorSite, webSqlErrorCode, sqliteE
rrorCode); |
| 248 } | 249 } |
| 249 | 250 |
| 250 | 251 |
| 251 } // namespace WebCore | 252 } // namespace WebCore |
| OLD | NEW |