Changeset 63278 in webkit
- Timestamp:
- Jul 13, 2010 9:46:52 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 45 added
- 36 edited
- 1 copied
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r63276 r63278 1 2010-07-13 Dumitru Daniliuc <dumi@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 Porting as many async DB tests as possible to sync DBs. 6 https://bugs.webkit.org/show_bug.cgi?id=40607 7 8 * fast/workers/storage/change-version-handle-reuse-sync-expected.txt: Added. 9 * fast/workers/storage/change-version-handle-reuse-sync.html: Added. 10 * fast/workers/storage/change-version-sync-expected.txt: Added. 11 * fast/workers/storage/change-version-sync.html: Added. 12 * fast/workers/storage/empty-statement-sync-expected.txt: Added. 13 * fast/workers/storage/empty-statement-sync.html: Added. 14 * fast/workers/storage/execute-sql-args-sync-expected.txt: Added. 15 * fast/workers/storage/execute-sql-args-sync.html: Added. 16 * fast/workers/storage/executesql-accepts-only-one-statement-sync-expected.txt: Added. 17 * fast/workers/storage/executesql-accepts-only-one-statement-sync.html: Added. 18 * fast/workers/storage/multiple-transactions-on-different-handles-sync-expected.txt: Added. 19 * fast/workers/storage/multiple-transactions-on-different-handles-sync.html: Added. 20 * fast/workers/storage/open-database-creation-callback-sync-expected.txt: Added. 21 * fast/workers/storage/open-database-creation-callback-sync.html: Added. 22 * fast/workers/storage/open-database-empty-version-sync-expected.txt: Added. 23 * fast/workers/storage/open-database-empty-version-sync.html: Added. 24 * fast/workers/storage/open-database-inputs-sync-expected.txt: Copied from LayoutTests/fast/workers/storage/open-database-sync-inputs-expected.txt. 25 * fast/workers/storage/open-database-inputs-sync.html: Copied from LayoutTests/fast/workers/storage/open-database-sync-inputs.html. 26 * fast/workers/storage/open-database-set-empty-version-sync-expected.txt: Added. 27 * fast/workers/storage/open-database-set-empty-version-sync.html: Added. 28 * fast/workers/storage/open-database-sync-inputs-expected.txt: Removed. 29 * fast/workers/storage/open-database-sync-inputs.html: Removed. 30 * fast/workers/storage/open-database-while-transaction-in-progress-sync-expected.txt: Added. 31 * fast/workers/storage/open-database-while-transaction-in-progress-sync.html: Added. 32 * fast/workers/storage/resources/change-version-handle-reuse-sync.js: Added. 33 (catch): 34 * fast/workers/storage/resources/change-version-sync-1.js: Added. 35 (): 36 (try): 37 * fast/workers/storage/resources/change-version-sync-2.js: Added. 38 * fast/workers/storage/resources/empty-statement-sync.js: Added. 39 * fast/workers/storage/resources/execute-sql-args-sync.js: Added. 40 (throwOnToStringObject.toString): 41 (var): 42 (): 43 (runTransactionTest): 44 (runTransactionTests): 45 * fast/workers/storage/resources/executesql-accepts-only-one-statement-sync.js: Added. 46 (executeStatement): 47 * fast/workers/storage/resources/multiple-transactions-on-different-handles-sync.js: Added. 48 (runTransaction): 49 (var): 50 * fast/workers/storage/resources/multiple-transactions-sync.js: Added. 51 (checkCompletion): 52 (runTest.db): 53 (runTest): 54 * fast/workers/storage/resources/open-database-creation-callback-sync.js: Added. 55 * fast/workers/storage/resources/open-database-empty-version-sync.js: Added. 56 * fast/workers/storage/resources/open-database-inputs-sync.js: Copied from LayoutTests/fast/workers/storage/resources/open-database-sync-inputs.js. 57 * fast/workers/storage/resources/open-database-set-empty-version-sync.js: Added. 58 * fast/workers/storage/resources/open-database-sync-inputs.js: Removed. 59 * fast/workers/storage/resources/open-database-while-transaction-in-progress-sync.js: Added. 60 (openTestDatabase): 61 * fast/workers/storage/resources/sql-data-types-sync.js: Added. 62 (): 63 (testDBValues): 64 * fast/workers/storage/resources/sql-exception-codes-sync.js: Added. 65 (testTransaction): 66 (): 67 (testInvalidStatement): 68 (testIncorrectNumberOfBindParameters): 69 (testBindParameterOfWrongType.badString.toString): 70 (testBindParameterOfWrongType): 71 (testVersionMismatch.testTransaction): 72 (testVersionMismatch): 73 * fast/workers/storage/resources/test-authorizer-sync.js: Added. 74 (cleanup): 75 (executeStatement): 76 (createTableCallback): 77 (createStatementsCallback): 78 (otherStatementsCallback): 79 (dropStatementsCallback): 80 (testReadWriteMode): 81 (testReadOnlyMode): 82 * fast/workers/storage/resources/transaction-in-transaction-sync.js: Added. 83 * fast/workers/storage/sql-data-types-sync-expected.txt: Added. 84 * fast/workers/storage/sql-data-types-sync.html: Added. 85 * fast/workers/storage/sql-exception-codes-sync-expected.txt: Added. 86 * fast/workers/storage/sql-exception-codes-sync.html: Added. 87 * fast/workers/storage/test-authorizer-sync-expected.txt: Added. 88 * fast/workers/storage/test-authorizer-sync.html: Added. 89 * fast/workers/storage/transaction-in-transaction-sync-expected.txt: Added. 90 * fast/workers/storage/transaction-in-transaction-sync.html: Added. 91 1 92 2010-07-13 Maciej Stachowiak <mjs@apple.com> 2 93 -
trunk/LayoutTests/fast/workers/storage/open-database-inputs-sync.html
r62230 r63278 5 5 </head> 6 6 7 <body onload="runTest('resources/open-database- sync-inputs.js')">7 <body onload="runTest('resources/open-database-inputs-sync.js')"> 8 8 This test makes sure that openDatabaseSync() accepts only valid parameters. 9 9 <pre id="console"> -
trunk/WebCore/CMakeLists.txt
r63198 r63278 1429 1429 storage/SQLResultSetRowList.cpp 1430 1430 storage/SQLStatement.cpp 1431 storage/SQLStatementSync.cpp 1431 1432 storage/SQLTransaction.cpp 1432 1433 storage/SQLTransactionClient.cpp -
trunk/WebCore/ChangeLog
r63275 r63278 1 2010-07-13 Dumitru Daniliuc <dumi@chromium.org> 2 3 Reviewed by Darin Fisher 4 5 Implementing DatabaseSync::transaction() and DatabaseSync::changeVersion(). 6 https://bugs.webkit.org/show_bug.cgi?id=40607 7 8 Tests: fast/workers/storage/change-version-handle-reuse-sync.html 9 fast/workers/storage/change-version-sync.html 10 fast/workers/storage/empty-statement-sync.html 11 fast/workers/storage/execute-sql-args-sync.html 12 fast/workers/storage/executesql-accepts-only-one-statement-sync.html 13 fast/workers/storage/multiple-transactions-on-different-handles-sync.html 14 fast/workers/storage/open-database-creation-callback-sync.html 15 fast/workers/storage/open-database-empty-version-sync.html 16 fast/workers/storage/open-database-inputs-sync.html 17 fast/workers/storage/open-database-set-empty-version-sync.html 18 fast/workers/storage/open-database-while-transaction-in-progress-sync.html 19 fast/workers/storage/sql-data-types-sync.html 20 fast/workers/storage/sql-exception-codes-sync.html 21 fast/workers/storage/test-authorizer-sync.html 22 fast/workers/storage/transaction-in-transaction-sync.html 23 24 * CMakeLists.txt: 25 * GNUmakefile.am: 26 * WebCore.gypi: 27 * WebCore.pro: 28 * WebCore.vcproj/WebCore.vcproj: 29 * WebCore.xcodeproj/project.pbxproj: 30 * storage/AbstractDatabase.cpp: 31 (WebCore::AbstractDatabase::maximumSize): 32 (WebCore::AbstractDatabase::incrementalVacuumIfNeeded): 33 * storage/AbstractDatabase.h: 34 (WebCore::AbstractDatabase::sqliteDatabase): 35 * storage/ChangeVersionWrapper.cpp: 36 (WebCore::ChangeVersionWrapper::performPreflight): 37 (WebCore::ChangeVersionWrapper::performPostflight): 38 * storage/Database.cpp: 39 (WebCore::Database::performGetTableNames): 40 * storage/Database.h: 41 * storage/DatabaseAuthorizer.cpp: 42 (WebCore::DatabaseAuthorizer::createVTable): 43 (WebCore::DatabaseAuthorizer::dropVTable): 44 * storage/DatabaseCallback.h: 45 * storage/DatabaseSync.cpp: 46 (WebCore::ChangeVersionPreflightStep::create): 47 (WebCore::ChangeVersionPreflightStep::performStep): 48 (WebCore::ChangeVersionPreflightStep::ChangeVersionPreflightStep): 49 (WebCore::ChangeVersionPostflightStep::create): 50 (WebCore::ChangeVersionPostflightStep::performStep): 51 (WebCore::ChangeVersionPostflightStep::ChangeVersionPostflightStep): 52 (WebCore::DatabaseSync::changeVersion): 53 (WebCore::DatabaseSync::transaction): 54 (WebCore::DatabaseSync::runTransaction): 55 * storage/DatabaseSync.h: 56 * storage/DatabaseTracker.cpp: 57 (WebCore::DatabaseTracker::getMaxSizeForDatabase): 58 * storage/SQLError.h: 59 * storage/SQLResultSet.cpp: 60 * storage/SQLResultSet.h: 61 * storage/SQLStatementCallback.h: 62 * storage/SQLStatementErrorCallback.h: 63 * storage/SQLStatementSync.cpp: Copied from WebCore/storage/SQLStatement.cpp. 64 (WebCore::SQLStatementSync::SQLStatementSync): 65 (WebCore::SQLStatementSync::execute): 66 * storage/SQLStatementSync.h: Added. 67 * storage/SQLTransaction.cpp: 68 (WebCore::SQLTransaction::runCurrentStatement): 69 (WebCore::SQLTransaction::deliverQuotaIncreaseCallback): 70 (WebCore::SQLTransaction::postflightAndCommit): 71 * storage/SQLTransaction.h: 72 * storage/SQLTransactionCallback.h: 73 * storage/SQLTransactionClient.cpp: 74 (WebCore::SQLTransactionClient::didCommitWriteTransaction): 75 (WebCore::SQLTransactionClient::didExecuteStatement): 76 (WebCore::SQLTransactionClient::didExceedQuota): 77 * storage/SQLTransactionClient.h: 78 * storage/SQLTransactionErrorCallback.h: 79 * storage/SQLTransactionSync.cpp: 80 (WebCore::transactionClient): 81 (WebCore::SQLTransactionSync::create): 82 (WebCore::SQLTransactionSync::SQLTransactionSync): 83 (WebCore::SQLTransactionSync::~SQLTransactionSync): 84 (WebCore::SQLTransactionSync::executeSQL): 85 (WebCore::SQLTransactionSync::begin): 86 (WebCore::SQLTransactionSync::execute): 87 (WebCore::SQLTransactionSync::commit): 88 (WebCore::SQLTransactionSync::rollback): 89 * storage/SQLTransactionSync.h: 90 (WebCore::SQLTransactionSync::SQLTransactionSyncOptionalStep::~SQLTransactionSyncOptionalStep): 91 * storage/SQLTransactionSyncCallback.h: 92 * storage/chromium/SQLTransactionClientChromium.cpp: 93 (WebCore::SQLTransactionClient::didCommitWriteTransaction): 94 (WebCore::SQLTransactionClient::didExecuteStatement): 95 (WebCore::SQLTransactionClient::didExceedQuota): 96 1 97 2010-07-13 Sheriff Bot <webkit.review.bot@gmail.com> 2 98 -
trunk/WebCore/GNUmakefile.am
r63230 r63278 2528 2528 WebCore/storage/SQLStatementCallback.h \ 2529 2529 WebCore/storage/SQLStatementErrorCallback.h \ 2530 WebCore/storage/SQLStatementSync.cpp \ 2531 WebCore/storage/SQLStatementSync.h \ 2530 2532 WebCore/storage/SQLTransaction.cpp \ 2531 2533 WebCore/storage/SQLTransaction.h \ -
trunk/WebCore/WebCore.gypi
r63230 r63278 3510 3510 'storage/SQLStatementCallback.h', 3511 3511 'storage/SQLStatementErrorCallback.h', 3512 'storage/SQLStatementSync.cpp', 3513 'storage/SQLStatementSync.h', 3512 3514 'storage/SQLTransaction.cpp', 3513 3515 'storage/SQLTransaction.h', -
trunk/WebCore/WebCore.pro
r63230 r63278 2380 2380 storage/SQLResultSetRowList.cpp \ 2381 2381 storage/SQLStatement.cpp \ 2382 storage/SQLStatementSync.cpp \ 2382 2383 storage/SQLTransaction.cpp \ 2383 2384 storage/SQLTransactionClient.cpp \ … … 2458 2459 storage/SQLResultSetRowList.h \ 2459 2460 storage/SQLStatement.h \ 2461 storage/SQLStatementSync.h \ 2460 2462 storage/SQLTransaction.h \ 2461 2463 storage/SQLTransactionClient.h \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r63230 r63278 50082 50082 </File> 50083 50083 <File 50084 RelativePath="..\storage\SQLStatementSync.cpp" 50085 > 50086 </File> 50087 <File 50088 RelativePath="..\storage\SQLStatementSync.h" 50089 > 50090 </File> 50091 <File 50084 50092 RelativePath="..\storage\SQLTransaction.cpp" 50085 50093 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r63230 r63278 4300 4300 B525A96511CA2340003A23A8 /* JSSQLException.h in Headers */ = {isa = PBXBuildFile; fileRef = B525A96311CA2340003A23A8 /* JSSQLException.h */; }; 4301 4301 B525A96611CA2340003A23A8 /* JSSQLException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B525A96411CA2340003A23A8 /* JSSQLException.cpp */; }; 4302 B550B52511DC68A800923885 /* SQLStatementSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B550B52111DC68A800923885 /* SQLStatementSync.cpp */; }; 4303 B550B52611DC68A800923885 /* SQLStatementSync.h in Headers */ = {isa = PBXBuildFile; fileRef = B550B52211DC68A800923885 /* SQLStatementSync.h */; }; 4302 4304 B55D5AA4119131FC00BCC315 /* JSSQLTransactionSyncCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B55D5AA2119131FC00BCC315 /* JSSQLTransactionSyncCallback.h */; }; 4303 4305 B55D5AA5119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55D5AA3119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp */; }; … … 9892 9894 B525A96311CA2340003A23A8 /* JSSQLException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLException.h; sourceTree = "<group>"; }; 9893 9895 B525A96411CA2340003A23A8 /* JSSQLException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLException.cpp; sourceTree = "<group>"; }; 9896 B550B52111DC68A800923885 /* SQLStatementSync.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLStatementSync.cpp; sourceTree = "<group>"; }; 9897 B550B52211DC68A800923885 /* SQLStatementSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLStatementSync.h; sourceTree = "<group>"; }; 9894 9898 B55D5AA2119131FC00BCC315 /* JSSQLTransactionSyncCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLTransactionSyncCallback.h; sourceTree = "<group>"; }; 9895 9899 B55D5AA3119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionSyncCallback.cpp; sourceTree = "<group>"; }; … … 11352 11356 1A7CCB160CD9469A00B7B64E /* SQLStatementErrorCallback.h */, 11353 11357 B59DD68F1190298E007E9684 /* SQLStatementErrorCallback.idl */, 11358 B550B52111DC68A800923885 /* SQLStatementSync.cpp */, 11359 B550B52211DC68A800923885 /* SQLStatementSync.h */, 11354 11360 1ABFE7520CD968D000FE4834 /* SQLTransaction.cpp */, 11355 11361 1A7CCB220CD946FD00B7B64E /* SQLTransaction.h */, … … 19292 19298 1A7CCB190CD9469A00B7B64E /* SQLStatementCallback.h in Headers */, 19293 19299 1A7CCB1A0CD9469A00B7B64E /* SQLStatementErrorCallback.h in Headers */, 19300 B550B52611DC68A800923885 /* SQLStatementSync.h in Headers */, 19294 19301 1A7CCB240CD946FD00B7B64E /* SQLTransaction.h in Headers */, 19295 19302 1A7CCB1B0CD9469A00B7B64E /* SQLTransactionCallback.h in Headers */, … … 21746 21753 1AFE117D0CBFFB36003017FA /* SQLResultSetRowList.cpp in Sources */, 21747 21754 515B039A0CD1642A00B7EA9C /* SQLStatement.cpp in Sources */, 21755 B550B52511DC68A800923885 /* SQLStatementSync.cpp in Sources */, 21748 21756 1ABFE7530CD968D000FE4834 /* SQLTransaction.cpp in Sources */, 21749 21757 B51BF6F0102C9E590002C15A /* SQLTransactionClient.cpp in Sources */, -
trunk/WebCore/storage/AbstractDatabase.cpp
r62153 r63278 33 33 #include "DatabaseAuthorizer.h" 34 34 #include "DatabaseTracker.h" 35 #include "ExceptionCode.h"36 35 #include "Logging.h" 37 36 #include "SQLiteStatement.h" … … 463 462 } 464 463 464 unsigned long long AbstractDatabase::maximumSize() const 465 { 466 return DatabaseTracker::tracker().getMaxSizeForDatabase(this); 467 } 468 469 void AbstractDatabase::incrementalVacuumIfNeeded() 470 { 471 int64_t freeSpaceSize = m_sqliteDatabase.freeSpaceSize(); 472 int64_t totalSize = m_sqliteDatabase.totalSize(); 473 if (totalSize <= 10 * freeSpaceSize) 474 m_sqliteDatabase.runIncrementalVacuumCommand(); 475 } 476 465 477 } // namespace WebCore 466 478 -
trunk/WebCore/storage/AbstractDatabase.h
r62153 r63278 32 32 #if ENABLE(DATABASE) 33 33 34 #include "ExceptionCode.h" 34 35 #include "PlatformString.h" 35 36 #include "SQLiteDatabase.h" … … 45 46 class ScriptExecutionContext; 46 47 class SecurityOrigin; 47 48 typedef int ExceptionCode;49 48 50 49 class AbstractDatabase : public ThreadSafeShared<AbstractDatabase> { … … 66 65 virtual unsigned long estimatedSize() const; 67 66 virtual String fileName() const; 67 SQLiteDatabase& sqliteDatabase() { return m_sqliteDatabase; } 68 69 unsigned long long maximumSize() const; 70 void incrementalVacuumIfNeeded(); 68 71 69 72 // FIXME: move all version-related methods to a DatabaseVersionTracker class … … 104 107 String m_filename; 105 108 106 SQLiteDatabase m_sqliteDatabase;107 108 109 #ifndef NDEBUG 109 110 String databaseDebugName() const { return m_contextThreadSecurityOrigin->toString() + "::" + m_name; } … … 117 118 bool m_new; 118 119 120 SQLiteDatabase m_sqliteDatabase; 121 119 122 RefPtr<DatabaseAuthorizer> m_databaseAuthorizer; 120 123 }; -
trunk/WebCore/storage/ChangeVersionWrapper.cpp
r60508 r63278 51 51 if (!transaction->database()->getVersionFromDatabase(actualVersion)) { 52 52 LOG_ERROR("Unable to retrieve actual current version from database"); 53 m_sqlError = SQLError::create( 0, "unable to verify current version of database");53 m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to verify current version of database"); 54 54 return false; 55 55 } … … 57 57 if (actualVersion != m_oldVersion) { 58 58 LOG_ERROR("Old version doesn't match actual version"); 59 m_sqlError = SQLError::create( 2, "current version of the database and `oldVersion` argument do not match");59 m_sqlError = SQLError::create(SQLError::VERSION_ERR, "current version of the database and `oldVersion` argument do not match"); 60 60 return false; 61 61 } … … 70 70 if (!transaction->database()->setVersionInDatabase(m_newVersion)) { 71 71 LOG_ERROR("Unable to set new version in database"); 72 m_sqlError = SQLError::create( 0, "unable to set new version in database");72 m_sqlError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to set new version in database"); 73 73 return false; 74 74 } -
trunk/WebCore/storage/Database.cpp
r62411 r63278 37 37 #include "DatabaseTracker.h" 38 38 #include "Document.h" 39 #include "ExceptionCode.h"40 39 #include "InspectorController.h" 41 40 #include "Logging.h" … … 337 336 disableAuthorizer(); 338 337 339 SQLiteStatement statement( m_sqliteDatabase, "SELECT name FROM sqlite_master WHERE type='table';");338 SQLiteStatement statement(sqliteDatabase(), "SELECT name FROM sqlite_master WHERE type='table';"); 340 339 if (statement.prepare() != SQLResultOk) { 341 340 LOG_ERROR("Unable to retrieve list of tables for database %s", databaseDebugName().ascii().data()); … … 398 397 } 399 398 400 void Database::incrementalVacuumIfNeeded()401 {402 int64_t freeSpaceSize = m_sqliteDatabase.freeSpaceSize();403 int64_t totalSize = m_sqliteDatabase.totalSize();404 if (totalSize <= 10 * freeSpaceSize)405 m_sqliteDatabase.runIncrementalVacuumCommand();406 }407 408 399 } // namespace WebCore 409 400 -
trunk/WebCore/storage/Database.h
r62411 r63278 32 32 #if ENABLE(DATABASE) 33 33 #include "AbstractDatabase.h" 34 #include "ExceptionCode.h" 34 35 #include "PlatformString.h" 35 #include "SQLiteDatabase.h"36 36 37 37 #include <wtf/Deque.h> … … 67 67 68 68 virtual SecurityOrigin* securityOrigin() const; 69 SQLiteDatabase& sqliteDatabase() { return m_sqliteDatabase; }70 69 71 70 virtual void markAsDeletedAndClose(); … … 83 82 SQLTransactionClient* transactionClient() const; 84 83 SQLTransactionCoordinator* transactionCoordinator() const; 85 86 void incrementalVacuumIfNeeded();87 84 88 85 private: -
trunk/WebCore/storage/DatabaseAuthorizer.cpp
r62153 r63278 291 291 292 292 // Allow only the FTS3 extension 293 if ( moduleName != "fts3")293 if (!equalIgnoringCase(moduleName, "fts3")) 294 294 return SQLAuthDeny; 295 295 … … 304 304 305 305 // Allow only the FTS3 extension 306 if ( moduleName != "fts3")306 if (!equalIgnoringCase(moduleName, "fts3")) 307 307 return SQLAuthDeny; 308 308 -
trunk/WebCore/storage/DatabaseCallback.h
r58989 r63278 34 34 #if ENABLE(DATABASE) 35 35 36 #include <wtf/Thread ing.h>36 #include <wtf/ThreadSafeShared.h> 37 37 38 38 namespace WebCore { -
trunk/WebCore/storage/DatabaseSync.cpp
r62153 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 … … 33 35 #include "DatabaseCallback.h" 34 36 #include "DatabaseTracker.h" 35 #include "ExceptionCode.h"36 37 #include "Logging.h" 38 #include "SQLException.h" 39 #include "SQLTransactionSync.h" 37 40 #include "SQLTransactionSyncCallback.h" 38 41 #include "ScriptExecutionContext.h" … … 88 91 } 89 92 90 void DatabaseSync::changeVersion(const String& , const String&, PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&)93 void DatabaseSync::changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionSyncCallback> changeVersionCallback, ExceptionCode& ec) 91 94 { 92 95 ASSERT(m_scriptExecutionContext->isContextThread()); 96 97 if (sqliteDatabase().transactionInProgress()) { 98 ec = SQLException::DATABASE_ERR; 99 return; 100 } 101 102 RefPtr<SQLTransactionSync> transaction = SQLTransactionSync::create(this, changeVersionCallback, false); 103 if ((ec = transaction->begin())) 104 return; 105 106 String actualVersion; 107 if (!getVersionFromDatabase(actualVersion)) { 108 ec = SQLException::UNKNOWN_ERR; 109 return; 110 } 111 112 if (actualVersion != oldVersion) { 113 ec = SQLException::VERSION_ERR; 114 return; 115 } 116 117 if ((ec = transaction->execute())) 118 return; 119 120 if (!setVersionInDatabase(newVersion)) { 121 ec = SQLException::UNKNOWN_ERR; 122 return; 123 } 124 125 if ((ec = transaction->commit())) 126 return; 127 128 setExpectedVersion(newVersion); 93 129 } 94 130 95 void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback> , bool, ExceptionCode&)131 void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback> callback, bool readOnly, ExceptionCode& ec) 96 132 { 97 133 ASSERT(m_scriptExecutionContext->isContextThread()); 134 135 if (sqliteDatabase().transactionInProgress()) { 136 ec = SQLException::DATABASE_ERR; 137 return; 138 } 139 140 RefPtr<SQLTransactionSync> transaction = SQLTransactionSync::create(this, callback, readOnly); 141 if ((ec = transaction->begin()) || (ec = transaction->execute()) || (ec = transaction->commit())) 142 transaction->rollback(); 98 143 } 99 144 -
trunk/WebCore/storage/DatabaseSync.h
r62153 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 … … 32 34 #if ENABLE(DATABASE) 33 35 #include "AbstractDatabase.h" 36 #include "ExceptionCode.h" 34 37 #include "PlatformString.h" 35 38 #include <wtf/Forward.h> … … 41 44 42 45 class DatabaseCallback; 46 class SQLTransactionSync; 43 47 class SQLTransactionSyncCallback; 44 48 class ScriptExecutionContext; -
trunk/WebCore/storage/DatabaseSync.idl
r58989 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 -
trunk/WebCore/storage/DatabaseTracker.cpp
r62411 r63278 222 222 unsigned long long DatabaseTracker::getMaxSizeForDatabase(const AbstractDatabase* database) 223 223 { 224 ASSERT(currentThread() == database->scriptExecutionContext()->databaseThread()->getThreadID());225 224 // The maximum size for a database is the full quota for its origin, minus the current usage within the origin, 226 225 // plus the current usage of the given database -
trunk/WebCore/storage/SQLError.h
r61352 r63278 33 33 34 34 #include "PlatformString.h" 35 #include <wtf/Thread ing.h>35 #include <wtf/ThreadSafeShared.h> 36 36 37 37 namespace WebCore { -
trunk/WebCore/storage/SQLResultSet.cpp
r43699 r63278 31 31 32 32 #if ENABLE(DATABASE) 33 34 #include "ExceptionCode.h"35 #include "SQLValue.h"36 33 37 34 namespace WebCore { -
trunk/WebCore/storage/SQLResultSet.h
r43699 r63278 32 32 #if ENABLE(DATABASE) 33 33 34 #include "ExceptionCode.h" 34 35 #include "SQLResultSetRowList.h" 35 #include <wtf/Thread ing.h>36 #include <wtf/ThreadSafeShared.h> 36 37 37 38 namespace WebCore { 38 39 typedef int ExceptionCode;40 39 41 40 class SQLResultSet : public ThreadSafeShared<SQLResultSet> { -
trunk/WebCore/storage/SQLStatementCallback.h
r58801 r63278 31 31 #if ENABLE(DATABASE) 32 32 33 #include <wtf/Thread ing.h>33 #include <wtf/ThreadSafeShared.h> 34 34 35 35 namespace WebCore { -
trunk/WebCore/storage/SQLStatementErrorCallback.h
r57530 r63278 32 32 #if ENABLE(DATABASE) 33 33 34 #include <wtf/Thread ing.h>34 #include <wtf/ThreadSafeShared.h> 35 35 36 36 namespace WebCore { -
trunk/WebCore/storage/SQLStatementSync.cpp
r62424 r63278 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 26 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28 */ 29 28 30 #include "config.h" 29 #include "SQLStatement .h"31 #include "SQLStatementSync.h" 30 32 31 33 #if ENABLE(DATABASE) 32 34 33 #include "Database.h" 34 #include "Logging.h" 35 #include "SQLError.h" 35 #include "DatabaseSync.h" 36 #include "SQLException.h" 37 #include "SQLResultSet.h" 38 #include "SQLValue.h" 36 39 #include "SQLiteDatabase.h" 37 40 #include "SQLiteStatement.h" 38 #include "SQLStatementCallback.h" 39 #include "SQLStatementErrorCallback.h" 40 #include "SQLTransaction.h" 41 #include "SQLValue.h" 41 #include <wtf/PassRefPtr.h> 42 #include <wtf/RefPtr.h> 42 43 43 44 namespace WebCore { 44 45 45 PassRefPtr<SQLStatement> SQLStatement::create(const String& statement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> errorCallback, bool readOnly) 46 SQLStatementSync::SQLStatementSync(const String& statement, const Vector<SQLValue>& arguments, bool readOnly) 47 : m_statement(statement) 48 , m_arguments(arguments) 49 , m_readOnly(readOnly) 46 50 { 47 return adoptRef(new SQLStatement(statement, arguments, callback, errorCallback, readOnly));51 ASSERT(!m_statement.isEmpty()); 48 52 } 49 53 50 SQLStatement::SQLStatement(const String& statement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> errorCallback, bool readOnly) 51 : m_statement(statement.crossThreadString()) 52 , m_arguments(arguments) 53 , m_statementCallback(callback) 54 , m_statementErrorCallback(errorCallback) 55 , m_readOnly(readOnly) 54 PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionCode& ec) 56 55 { 57 }58 59 bool SQLStatement::execute(Database* db)60 {61 ASSERT(!m_resultSet);62 63 // If we're re-running this statement after a quota violation, we need to clear that error now64 clearFailureDueToQuota();65 66 // This transaction might have been marked bad while it was being set up on the main thread,67 // so if there is still an error, return false.68 if (m_error)69 return false;70 71 56 if (m_readOnly) 72 57 db->setAuthorizerReadOnly(); … … 76 61 SQLiteStatement statement(*database, m_statement); 77 62 int result = statement.prepare(); 78 79 63 if (result != SQLResultOk) { 80 LOG(StorageAPI, "Unable to verify correctness of statement %s - error %i (%s)", m_statement.ascii().data(), result, database->lastErrorMsg()); 81 m_error = SQLError::create(SQLError::SYNTAX_ERR, database->lastErrorMsg()); 82 return false; 64 ec = SQLException::SYNTAX_ERR; 65 return 0; 83 66 } 84 67 85 // FIXME: If the statement uses the ?### syntax supported by sqlite, the bind parameter count is very likely off from the number of question marks.86 // If this is the case, they might be trying to do something fishy or malicious87 68 if (statement.bindParameterCount() != m_arguments.size()) { 88 LOG(StorageAPI, "Bind parameter count doesn't match number of question marks"); 89 m_error = SQLError::create(SQLError::SYNTAX_ERR, "number of '?'s in statement string does not match argument count"); 90 return false; 69 ec = SQLException::SYNTAX_ERR; 70 return 0; 91 71 } 92 72 … … 94 74 result = statement.bindValue(i + 1, m_arguments[i]); 95 75 if (result == SQLResultFull) { 96 setFailureDueToQuota();97 return false;76 ec = SQLException::QUOTA_ERR; 77 return 0; 98 78 } 99 79 100 80 if (result != SQLResultOk) { 101 LOG(StorageAPI, "Failed to bind value index %i to statement for query '%s'", i + 1, m_statement.ascii().data()); 102 m_error = SQLError::create(SQLError::DATABASE_ERR, database->lastErrorMsg()); 103 return false; 81 ec = SQLException::DATABASE_ERR; 82 return 0; 104 83 } 105 84 } … … 124 103 125 104 if (result != SQLResultDone) { 126 m_error = SQLError::create(SQLError::DATABASE_ERR, database->lastErrorMsg());127 return false;105 ec = SQLException::DATABASE_ERR; 106 return 0; 128 107 } 129 108 } else if (result == SQLResultDone) { 130 // Didn't find anything, or was an insert 109 // Didn't find anything, or was an insert. 131 110 if (db->lastActionWasInsert()) 132 111 resultSet->setInsertId(database->lastInsertRowID()); 133 112 } else if (result == SQLResultFull) { 134 // Return the Quota error - the delegate will be asked for more space and this statement might be re-run135 setFailureDueToQuota();136 return false;113 // Quota error, the delegate will be asked for more space and this statement might be re-run. 114 ec = SQLException::QUOTA_ERR; 115 return 0; 137 116 } else { 138 m_error = SQLError::create(SQLError::DATABASE_ERR, database->lastErrorMsg());139 return false;117 ec = SQLException::DATABASE_ERR; 118 return 0; 140 119 } 141 120 142 // FIXME: If the spec allows triggers, and we want to be "accurate" in a different way, we'd use143 // sqlite3_total_changes() here instead of sqlite3_changed, because that includes rows modified from within a trigger144 // For now, this seems sufficient145 121 resultSet->setRowsAffected(database->lastChanges()); 146 147 m_resultSet = resultSet; 148 return true; 149 } 150 151 void SQLStatement::setDatabaseDeletedError() 152 { 153 ASSERT(!m_error && !m_resultSet); 154 m_error = SQLError::create(SQLError::UNKNOWN_ERR, "unable to execute statement, because the user deleted the database"); 155 } 156 157 void SQLStatement::setVersionMismatchedError() 158 { 159 ASSERT(!m_error && !m_resultSet); 160 m_error = SQLError::create(SQLError::VERSION_ERR, "current version of the database and `oldVersion` argument do not match"); 161 } 162 163 bool SQLStatement::performCallback(SQLTransaction* transaction) 164 { 165 ASSERT(transaction); 166 167 bool callbackError = false; 168 169 // Call the appropriate statement callback and track if it resulted in an error, 170 // because then we need to jump to the transaction error callback. 171 if (m_error) { 172 ASSERT(m_statementErrorCallback); 173 callbackError = m_statementErrorCallback->handleEvent(transaction->database()->scriptExecutionContext(), transaction, m_error.get()); 174 } else if (m_statementCallback) 175 callbackError = !m_statementCallback->handleEvent(transaction->database()->scriptExecutionContext(), transaction, m_resultSet.get()); 176 177 // Now release our callbacks, to break reference cycles. 178 m_statementCallback = 0; 179 m_statementErrorCallback = 0; 180 181 return callbackError; 182 } 183 184 void SQLStatement::setFailureDueToQuota() 185 { 186 ASSERT(!m_error && !m_resultSet); 187 m_error = SQLError::create(SQLError::QUOTA_ERR, "there was not enough remaining storage space, or the storage quota was reached and the user declined to allow more space"); 188 } 189 190 void SQLStatement::clearFailureDueToQuota() 191 { 192 if (lastExecutionFailedDueToQuota()) 193 m_error = 0; 194 } 195 196 bool SQLStatement::lastExecutionFailedDueToQuota() const 197 { 198 return m_error && m_error->code() == SQLError::QUOTA_ERR; 122 return resultSet.release(); 199 123 } 200 124 -
trunk/WebCore/storage/SQLTransaction.cpp
r62411 r63278 34 34 #include "Database.h" 35 35 #include "DatabaseThread.h" 36 #include "ExceptionCode.h"37 36 #include "Logging.h" 38 37 #include "PlatformString.h" … … 371 370 m_modifiedDatabase = true; 372 371 // Also dirty the size of this database file for calculating quota usage 373 m_database->transactionClient()->didExecuteStatement( this);372 m_database->transactionClient()->didExecuteStatement(database()); 374 373 } 375 374 … … 433 432 ASSERT(!m_shouldRetryCurrentStatement); 434 433 435 m_shouldRetryCurrentStatement = m_database->transactionClient()->didExceedQuota( this);434 m_shouldRetryCurrentStatement = m_database->transactionClient()->didExceedQuota(database()); 436 435 437 436 m_nextStep = &SQLTransaction::runStatements; … … 473 472 // The commit was successful. If the transaction modified this database, notify the delegates. 474 473 if (m_modifiedDatabase) 475 m_database->transactionClient()->didCommit Transaction(this);474 m_database->transactionClient()->didCommitWriteTransaction(database()); 476 475 477 476 // Now release our unneeded callbacks, to break reference cycles. -
trunk/WebCore/storage/SQLTransaction.h
r60508 r63278 31 31 #if ENABLE(DATABASE) 32 32 33 #include <wtf/Threading.h> 34 33 #include "ExceptionCode.h" 35 34 #include "SQLStatement.h" 36 35 #include <wtf/Deque.h> 37 36 #include <wtf/Forward.h> 37 #include <wtf/ThreadSafeShared.h> 38 38 #include <wtf/Vector.h> 39 39 40 40 namespace WebCore { 41 42 typedef int ExceptionCode;43 41 44 42 class Database; -
trunk/WebCore/storage/SQLTransactionCallback.h
r58801 r63278 32 32 #if ENABLE(DATABASE) 33 33 34 #include <wtf/Thread ing.h>34 #include <wtf/ThreadSafeShared.h> 35 35 36 36 namespace WebCore { -
trunk/WebCore/storage/SQLTransactionClient.cpp
r57668 r63278 34 34 #if ENABLE(DATABASE) 35 35 36 #include "Chrome.h" 37 #include "ChromeClient.h" 38 #include "Database.h" 39 #include "DatabaseThread.h" 36 #include "AbstractDatabase.h" 40 37 #include "DatabaseTracker.h" 41 #include "Document.h" 42 #include "Page.h" 43 #include "SQLTransaction.h" 38 #include "ScriptExecutionContext.h" 39 #include "SecurityOrigin.h" 44 40 45 41 namespace WebCore { 46 42 47 void SQLTransactionClient::didCommit Transaction(SQLTransaction* transaction)43 void SQLTransactionClient::didCommitWriteTransaction(AbstractDatabase* database) 48 44 { 49 ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID());50 Database* database = transaction->database();51 45 DatabaseTracker::tracker().scheduleNotifyDatabaseChanged( 52 46 database->securityOrigin(), database->stringIdentifier()); 53 47 } 54 48 55 void SQLTransactionClient::didExecuteStatement( SQLTransaction* transaction)49 void SQLTransactionClient::didExecuteStatement(AbstractDatabase* database) 56 50 { 57 ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID()); 58 DatabaseTracker::tracker().databaseChanged(transaction->database()); 51 DatabaseTracker::tracker().databaseChanged(database); 59 52 } 60 53 61 bool SQLTransactionClient::didExceedQuota( SQLTransaction* transaction)54 bool SQLTransactionClient::didExceedQuota(AbstractDatabase* database) 62 55 { 63 ASSERT(transaction->database()->scriptExecutionContext()->isContextThread()); 64 Database* database = transaction->database(); 65 56 ASSERT(database->scriptExecutionContext()->isContextThread()); 66 57 unsigned long long currentQuota = DatabaseTracker::tracker().quotaForOrigin(database->securityOrigin()); 67 58 database->scriptExecutionContext()->databaseExceededQuota(database->stringIdentifier()); -
trunk/WebCore/storage/SQLTransactionClient.h
r52060 r63278 38 38 namespace WebCore { 39 39 40 class SQLTransaction;40 class AbstractDatabase; 41 41 42 // A client to the SQLTransaction class. Allows SQLTransaction to notify interested 43 // parties that certain things have happened in a transaction. 44 class SQLTransactionClient : public Noncopyable { 45 public: 46 void didCommitTransaction(SQLTransaction*); 47 void didExecuteStatement(SQLTransaction*); 48 bool didExceedQuota(SQLTransaction*); 49 }; 42 // A client to the SQLTransaction class. Allows SQLTransaction to notify interested 43 // parties that certain things have happened in a transaction. 44 class SQLTransactionClient : public Noncopyable { 45 public: 46 void didCommitWriteTransaction(AbstractDatabase*); 47 void didExecuteStatement(AbstractDatabase*); 48 bool didExceedQuota(AbstractDatabase*); 49 }; 50 50 51 } 51 52 -
trunk/WebCore/storage/SQLTransactionErrorCallback.h
r58801 r63278 32 32 #if ENABLE(DATABASE) 33 33 34 #include <wtf/Thread ing.h>34 #include <wtf/ThreadSafeShared.h> 35 35 36 36 namespace WebCore { -
trunk/WebCore/storage/SQLTransactionSync.cpp
r58437 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 … … 33 35 34 36 #include "DatabaseSync.h" 35 #include "ExceptionCode.h"36 37 #include "PlatformString.h" 38 #include "SQLException.h" 37 39 #include "SQLResultSet.h" 40 #include "SQLStatementSync.h" 41 #include "SQLTransactionClient.h" 38 42 #include "SQLTransactionSyncCallback.h" 39 43 #include "SQLValue.h" 44 #include "SQLiteTransaction.h" 40 45 #include "ScriptExecutionContext.h" 41 46 #include <wtf/PassRefPtr.h> … … 53 58 , m_callback(callback) 54 59 , m_readOnly(readOnly) 55 { 56 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 57 ASSERT(callback); 60 , m_modifiedDatabase(false) 61 , m_transactionClient(new SQLTransactionClient()) 62 { 63 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 58 64 } 59 65 … … 61 67 { 62 68 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 63 } 64 65 PassRefPtr<SQLResultSet> SQLTransactionSync::executeSQL(const String&, const Vector<SQLValue>&, ExceptionCode&) 66 { 67 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 69 if (m_sqliteTransaction && m_sqliteTransaction->inProgress()) 70 rollback(); 71 } 72 73 PassRefPtr<SQLResultSet> SQLTransactionSync::executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, ExceptionCode& ec) 74 { 75 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 76 if (!m_database->opened()) { 77 ec = SQLException::UNKNOWN_ERR; 78 return 0; 79 } 80 81 if (!m_database->versionMatchesExpected()) { 82 ec = SQLException::VERSION_ERR; 83 return 0; 84 } 85 86 if (sqlStatement.isEmpty()) 87 return 0; 88 89 bool readOnlyMode = m_readOnly || m_database->scriptExecutionContext()->isDatabaseReadOnly(); 90 SQLStatementSync statement(sqlStatement, arguments, readOnlyMode); 91 92 m_database->resetAuthorizer(); 93 bool retryStatement = true; 94 RefPtr<SQLResultSet> resultSet; 95 while (retryStatement) { 96 retryStatement = false; 97 resultSet = statement.execute(m_database.get(), ec); 98 if (!resultSet) { 99 if (m_sqliteTransaction->wasRolledBackBySqlite()) 100 return 0; 101 102 if (ec == SQLException::QUOTA_ERR) { 103 if (m_transactionClient->didExceedQuota(database())) { 104 ec = 0; 105 retryStatement = true; 106 } else 107 return 0; 108 } 109 } 110 } 111 112 if (m_database->lastActionChangedDatabase()) { 113 m_modifiedDatabase = true; 114 m_transactionClient->didExecuteStatement(database()); 115 } 116 117 return resultSet.release(); 118 } 119 120 ExceptionCode SQLTransactionSync::begin() 121 { 122 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 123 if (!m_database->opened()) 124 return SQLException::UNKNOWN_ERR; 125 126 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); 127 128 // Set the maximum usage for this transaction if this transactions is not read-only. 129 if (!m_readOnly) 130 m_database->sqliteDatabase().setMaximumSize(m_database->maximumSize()); 131 132 ASSERT(!m_sqliteTransaction); 133 m_sqliteTransaction.set(new SQLiteTransaction(m_database->sqliteDatabase(), m_readOnly)); 134 135 m_database->resetDeletes(); 136 m_database->disableAuthorizer(); 137 m_sqliteTransaction->begin(); 138 m_database->enableAuthorizer(); 139 140 // Check if begin() succeeded. 141 if (!m_sqliteTransaction->inProgress()) { 142 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); 143 m_sqliteTransaction.clear(); 144 return SQLException::DATABASE_ERR; 145 } 146 68 147 return 0; 69 148 } 70 149 150 ExceptionCode SQLTransactionSync::execute() 151 { 152 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 153 if (!m_database->opened() || !m_callback || !m_callback->handleEvent(m_database->scriptExecutionContext(), this)) { 154 m_callback = 0; 155 return SQLException::UNKNOWN_ERR; 156 } 157 158 m_callback = 0; 159 return 0; 160 } 161 162 ExceptionCode SQLTransactionSync::commit() 163 { 164 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 165 if (!m_database->opened()) 166 return SQLException::UNKNOWN_ERR; 167 168 ASSERT(m_sqliteTransaction); 169 170 m_database->disableAuthorizer(); 171 m_sqliteTransaction->commit(); 172 m_database->enableAuthorizer(); 173 174 // If the commit failed, the transaction will still be marked as "in progress" 175 if (m_sqliteTransaction->inProgress()) 176 return SQLException::DATABASE_ERR; 177 178 m_sqliteTransaction.clear(); 179 180 // Vacuum the database if anything was deleted. 181 if (m_database->hadDeletes()) 182 m_database->incrementalVacuumIfNeeded(); 183 184 // The commit was successful. If the transaction modified this database, notify the delegates. 185 if (m_modifiedDatabase) 186 m_transactionClient->didCommitWriteTransaction(database()); 187 188 return 0; 189 } 190 191 void SQLTransactionSync::rollback() 192 { 193 ASSERT(m_database->scriptExecutionContext()->isContextThread()); 194 m_database->disableAuthorizer(); 195 if (m_sqliteTransaction) { 196 m_sqliteTransaction->rollback(); 197 m_sqliteTransaction.clear(); 198 } 199 m_database->enableAuthorizer(); 200 201 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); 202 } 203 71 204 } // namespace WebCore 72 205 -
trunk/WebCore/storage/SQLTransactionSync.h
r58437 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 30 28 31 #ifndef SQLTransactionSync_h 29 32 #define SQLTransactionSync_h … … 31 34 #if ENABLE(DATABASE) 32 35 36 #include "ExceptionCode.h" 33 37 #include <wtf/Forward.h> 34 38 #include <wtf/RefCounted.h> … … 37 41 namespace WebCore { 38 42 39 typedef int ExceptionCode;40 41 43 class DatabaseSync; 42 44 class SQLResultSet; 45 class SQLTransactionClient; 43 46 class SQLTransactionSyncCallback; 44 47 class SQLValue; 48 class SQLiteTransaction; 45 49 class String; 46 50 … … 57 61 bool isReadOnly() const { return m_readOnly; } 58 62 63 ExceptionCode begin(); 64 ExceptionCode execute(); 65 ExceptionCode commit(); 66 void rollback(); 67 59 68 private: 60 69 SQLTransactionSync(DatabaseSync*, PassRefPtr<SQLTransactionSyncCallback>, bool readOnly); … … 63 72 RefPtr<SQLTransactionSyncCallback> m_callback; 64 73 bool m_readOnly; 74 75 bool m_modifiedDatabase; 76 OwnPtr<SQLTransactionClient> m_transactionClient; 77 OwnPtr<SQLiteTransaction> m_sqliteTransaction; 65 78 }; 66 79 -
trunk/WebCore/storage/SQLTransactionSync.idl
r58989 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 -
trunk/WebCore/storage/SQLTransactionSyncCallback.h
r60289 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 *Transaction 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 5 * modification, are permitted provided that the following conditions are 6 * met: 16 7 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 … … 33 35 34 36 #include <wtf/RefCounted.h> 35 #include <wtf/Threading.h>36 37 37 38 namespace WebCore { -
trunk/WebCore/storage/SQLTransactionSyncCallback.idl
r58989 r63278 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * aremet:5 * modification, are permitted provided that the following conditions are 6 * met: 7 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 16 17 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 29 */ 28 30 -
trunk/WebCore/storage/chromium/SQLTransactionClientChromium.cpp
r53595 r63278 32 32 #include "SQLTransactionClient.h" 33 33 34 #include " Database.h"34 #include "AbstractDatabase.h" 35 35 #include "DatabaseObserver.h" 36 #include "DatabaseThread.h" 37 #include "Document.h" 38 #include "SQLTransaction.h" 39 #include <wtf/MainThread.h> 36 #include "ScriptExecutionContext.h" 40 37 41 38 namespace WebCore { … … 43 40 class NotifyDatabaseChangedTask : public ScriptExecutionContext::Task { 44 41 public: 45 static PassOwnPtr<NotifyDatabaseChangedTask> create( Database *database)42 static PassOwnPtr<NotifyDatabaseChangedTask> create(AbstractDatabase *database) 46 43 { 47 44 return new NotifyDatabaseChangedTask(database); … … 54 51 55 52 private: 56 NotifyDatabaseChangedTask(PassRefPtr< Database> database)53 NotifyDatabaseChangedTask(PassRefPtr<AbstractDatabase> database) 57 54 : m_database(database) 58 55 { 59 56 } 60 57 61 RefPtr< Database> m_database;58 RefPtr<AbstractDatabase> m_database; 62 59 }; 63 60 64 void SQLTransactionClient::didCommit Transaction(SQLTransaction* transaction)61 void SQLTransactionClient::didCommitWriteTransaction(AbstractDatabase* database) 65 62 { 66 ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID());67 if (!transaction->isReadOnly()) {68 transaction->database()->scriptExecutionContext()->postTask(NotifyDatabaseChangedTask::create(transaction->database()));63 if (!database->scriptExecutionContext()->isContextThread()) { 64 database->scriptExecutionContext()->postTask(NotifyDatabaseChangedTask::create(database)); 65 return; 69 66 } 67 68 WebCore::DatabaseObserver::databaseModified(database); 70 69 } 71 70 72 void SQLTransactionClient::didExecuteStatement( SQLTransaction* transaction)71 void SQLTransactionClient::didExecuteStatement(AbstractDatabase* database) 73 72 { 74 73 // This method is called after executing every statement that changes the DB. 75 74 // Chromium doesn't need to do anything at that point. 76 ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID());77 75 } 78 76 79 bool SQLTransactionClient::didExceedQuota( SQLTransaction* transaction)77 bool SQLTransactionClient::didExceedQuota(AbstractDatabase* database) 80 78 { 81 79 // Chromium does not allow users to manually change the quota for an origin (for now, at least). 82 80 // Don't do anything. 83 ASSERT( transaction->database()->scriptExecutionContext()->isContextThread());81 ASSERT(database->scriptExecutionContext()->isContextThread()); 84 82 return false; 85 83 }
Note: See TracChangeset
for help on using the changeset viewer.