Changeset 63278 in webkit


Ignore:
Timestamp:
Jul 13, 2010 9:46:52 PM (14 years ago)
Author:
dumi@chromium.org
Message:

WebCore: Implementing DatabaseSync::transaction() and DatabaseSync::changeVersion().
https://bugs.webkit.org/show_bug.cgi?id=40607

Reviewed by Darin Fisher

Tests: fast/workers/storage/change-version-handle-reuse-sync.html

fast/workers/storage/change-version-sync.html
fast/workers/storage/empty-statement-sync.html
fast/workers/storage/execute-sql-args-sync.html
fast/workers/storage/executesql-accepts-only-one-statement-sync.html
fast/workers/storage/multiple-transactions-on-different-handles-sync.html
fast/workers/storage/open-database-creation-callback-sync.html
fast/workers/storage/open-database-empty-version-sync.html
fast/workers/storage/open-database-inputs-sync.html
fast/workers/storage/open-database-set-empty-version-sync.html
fast/workers/storage/open-database-while-transaction-in-progress-sync.html
fast/workers/storage/sql-data-types-sync.html
fast/workers/storage/sql-exception-codes-sync.html
fast/workers/storage/test-authorizer-sync.html
fast/workers/storage/transaction-in-transaction-sync.html

  • CMakeLists.txt:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • storage/AbstractDatabase.cpp:

(WebCore::AbstractDatabase::maximumSize):
(WebCore::AbstractDatabase::incrementalVacuumIfNeeded):

  • storage/AbstractDatabase.h:

(WebCore::AbstractDatabase::sqliteDatabase):

  • storage/ChangeVersionWrapper.cpp:

(WebCore::ChangeVersionWrapper::performPreflight):
(WebCore::ChangeVersionWrapper::performPostflight):

  • storage/Database.cpp:

(WebCore::Database::performGetTableNames):

  • storage/Database.h:
  • storage/DatabaseAuthorizer.cpp:

(WebCore::DatabaseAuthorizer::createVTable):
(WebCore::DatabaseAuthorizer::dropVTable):

  • storage/DatabaseCallback.h:
  • storage/DatabaseSync.cpp:

(WebCore::ChangeVersionPreflightStep::create):
(WebCore::ChangeVersionPreflightStep::performStep):
(WebCore::ChangeVersionPreflightStep::ChangeVersionPreflightStep):
(WebCore::ChangeVersionPostflightStep::create):
(WebCore::ChangeVersionPostflightStep::performStep):
(WebCore::ChangeVersionPostflightStep::ChangeVersionPostflightStep):
(WebCore::DatabaseSync::changeVersion):
(WebCore::DatabaseSync::transaction):
(WebCore::DatabaseSync::runTransaction):

  • storage/DatabaseSync.h:
  • storage/DatabaseTracker.cpp:

(WebCore::DatabaseTracker::getMaxSizeForDatabase):

  • storage/SQLError.h:
  • storage/SQLResultSet.cpp:
  • storage/SQLResultSet.h:
  • storage/SQLStatementCallback.h:
  • storage/SQLStatementErrorCallback.h:
  • storage/SQLStatementSync.cpp: Copied from WebCore/storage/SQLStatement.cpp.

(WebCore::SQLStatementSync::SQLStatementSync):
(WebCore::SQLStatementSync::execute):

  • storage/SQLStatementSync.h: Added.
  • storage/SQLTransaction.cpp:

(WebCore::SQLTransaction::runCurrentStatement):
(WebCore::SQLTransaction::deliverQuotaIncreaseCallback):
(WebCore::SQLTransaction::postflightAndCommit):

  • storage/SQLTransaction.h:
  • storage/SQLTransactionCallback.h:
  • storage/SQLTransactionClient.cpp:

(WebCore::SQLTransactionClient::didCommitWriteTransaction):
(WebCore::SQLTransactionClient::didExecuteStatement):
(WebCore::SQLTransactionClient::didExceedQuota):

  • storage/SQLTransactionClient.h:
  • storage/SQLTransactionErrorCallback.h:
  • storage/SQLTransactionSync.cpp:

(WebCore::transactionClient):
(WebCore::SQLTransactionSync::create):
(WebCore::SQLTransactionSync::SQLTransactionSync):
(WebCore::SQLTransactionSync::~SQLTransactionSync):
(WebCore::SQLTransactionSync::executeSQL):
(WebCore::SQLTransactionSync::begin):
(WebCore::SQLTransactionSync::execute):
(WebCore::SQLTransactionSync::commit):
(WebCore::SQLTransactionSync::rollback):

  • storage/SQLTransactionSync.h:

(WebCore::SQLTransactionSync::SQLTransactionSyncOptionalStep::~SQLTransactionSyncOptionalStep):

  • storage/SQLTransactionSyncCallback.h:
  • storage/chromium/SQLTransactionClientChromium.cpp:

(WebCore::SQLTransactionClient::didCommitWriteTransaction):
(WebCore::SQLTransactionClient::didExecuteStatement):
(WebCore::SQLTransactionClient::didExceedQuota):

LayoutTests: Porting as many async DB tests as possible to sync DBs.
https://bugs.webkit.org/show_bug.cgi?id=40607

Reviewed by Darin Fisher.

  • fast/workers/storage/change-version-handle-reuse-sync-expected.txt: Added.
  • fast/workers/storage/change-version-handle-reuse-sync.html: Added.
  • fast/workers/storage/change-version-sync-expected.txt: Added.
  • fast/workers/storage/change-version-sync.html: Added.
  • fast/workers/storage/empty-statement-sync-expected.txt: Added.
  • fast/workers/storage/empty-statement-sync.html: Added.
  • fast/workers/storage/execute-sql-args-sync-expected.txt: Added.
  • fast/workers/storage/execute-sql-args-sync.html: Added.
  • fast/workers/storage/executesql-accepts-only-one-statement-sync-expected.txt: Added.
  • fast/workers/storage/executesql-accepts-only-one-statement-sync.html: Added.
  • fast/workers/storage/multiple-transactions-on-different-handles-sync-expected.txt: Added.
  • fast/workers/storage/multiple-transactions-on-different-handles-sync.html: Added.
  • fast/workers/storage/open-database-creation-callback-sync-expected.txt: Added.
  • fast/workers/storage/open-database-creation-callback-sync.html: Added.
  • fast/workers/storage/open-database-empty-version-sync-expected.txt: Added.
  • fast/workers/storage/open-database-empty-version-sync.html: Added.
  • fast/workers/storage/open-database-inputs-sync-expected.txt: Copied from LayoutTests/fast/workers/storage/open-database-sync-inputs-expected.txt.
  • fast/workers/storage/open-database-inputs-sync.html: Copied from LayoutTests/fast/workers/storage/open-database-sync-inputs.html.
  • fast/workers/storage/open-database-set-empty-version-sync-expected.txt: Added.
  • fast/workers/storage/open-database-set-empty-version-sync.html: Added.
  • fast/workers/storage/open-database-sync-inputs-expected.txt: Removed.
  • fast/workers/storage/open-database-sync-inputs.html: Removed.
  • fast/workers/storage/open-database-while-transaction-in-progress-sync-expected.txt: Added.
  • fast/workers/storage/open-database-while-transaction-in-progress-sync.html: Added.
  • fast/workers/storage/resources/change-version-handle-reuse-sync.js: Added.

(catch):

  • fast/workers/storage/resources/change-version-sync-1.js: Added.

():
(try):

  • fast/workers/storage/resources/change-version-sync-2.js: Added.
  • fast/workers/storage/resources/empty-statement-sync.js: Added.
  • fast/workers/storage/resources/execute-sql-args-sync.js: Added.

(throwOnToStringObject.toString):
(var):
():
(runTransactionTest):
(runTransactionTests):

  • fast/workers/storage/resources/executesql-accepts-only-one-statement-sync.js: Added.

(executeStatement):

  • fast/workers/storage/resources/multiple-transactions-on-different-handles-sync.js: Added.

(runTransaction):
(var):

  • fast/workers/storage/resources/multiple-transactions-sync.js: Added.

(checkCompletion):
(runTest.db):
(runTest):

  • fast/workers/storage/resources/open-database-creation-callback-sync.js: Added.
  • fast/workers/storage/resources/open-database-empty-version-sync.js: Added.
  • fast/workers/storage/resources/open-database-inputs-sync.js: Copied from LayoutTests/fast/workers/storage/resources/open-database-sync-inputs.js.
  • fast/workers/storage/resources/open-database-set-empty-version-sync.js: Added.
  • fast/workers/storage/resources/open-database-sync-inputs.js: Removed.
  • fast/workers/storage/resources/open-database-while-transaction-in-progress-sync.js: Added.

(openTestDatabase):

  • fast/workers/storage/resources/sql-data-types-sync.js: Added.

():
(testDBValues):

  • fast/workers/storage/resources/sql-exception-codes-sync.js: Added.

(testTransaction):
():
(testInvalidStatement):
(testIncorrectNumberOfBindParameters):
(testBindParameterOfWrongType.badString.toString):
(testBindParameterOfWrongType):
(testVersionMismatch.testTransaction):
(testVersionMismatch):

  • fast/workers/storage/resources/test-authorizer-sync.js: Added.

(cleanup):
(executeStatement):
(createTableCallback):
(createStatementsCallback):
(otherStatementsCallback):
(dropStatementsCallback):
(testReadWriteMode):
(testReadOnlyMode):

  • fast/workers/storage/resources/transaction-in-transaction-sync.js: Added.
  • fast/workers/storage/sql-data-types-sync-expected.txt: Added.
  • fast/workers/storage/sql-data-types-sync.html: Added.
  • fast/workers/storage/sql-exception-codes-sync-expected.txt: Added.
  • fast/workers/storage/sql-exception-codes-sync.html: Added.
  • fast/workers/storage/test-authorizer-sync-expected.txt: Added.
  • fast/workers/storage/test-authorizer-sync.html: Added.
  • fast/workers/storage/transaction-in-transaction-sync-expected.txt: Added.
  • fast/workers/storage/transaction-in-transaction-sync.html: Added.
Location:
trunk
Files:
45 added
36 edited
1 copied
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r63276 r63278  
     12010-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
    1922010-07-13  Maciej Stachowiak  <mjs@apple.com>
    293
  • trunk/LayoutTests/fast/workers/storage/open-database-inputs-sync.html

    r62230 r63278  
    55</head>
    66
    7 <body onload="runTest('resources/open-database-sync-inputs.js')">
     7<body onload="runTest('resources/open-database-inputs-sync.js')">
    88This test makes sure that openDatabaseSync() accepts only valid parameters.
    99<pre id="console">
  • trunk/WebCore/CMakeLists.txt

    r63198 r63278  
    14291429    storage/SQLResultSetRowList.cpp
    14301430    storage/SQLStatement.cpp
     1431    storage/SQLStatementSync.cpp
    14311432    storage/SQLTransaction.cpp
    14321433    storage/SQLTransactionClient.cpp
  • trunk/WebCore/ChangeLog

    r63275 r63278  
     12010-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
    1972010-07-13  Sheriff Bot  <webkit.review.bot@gmail.com>
    298
  • trunk/WebCore/GNUmakefile.am

    r63230 r63278  
    25282528        WebCore/storage/SQLStatementCallback.h \
    25292529        WebCore/storage/SQLStatementErrorCallback.h \
     2530        WebCore/storage/SQLStatementSync.cpp \
     2531        WebCore/storage/SQLStatementSync.h \
    25302532        WebCore/storage/SQLTransaction.cpp \
    25312533        WebCore/storage/SQLTransaction.h \
  • trunk/WebCore/WebCore.gypi

    r63230 r63278  
    35103510            'storage/SQLStatementCallback.h',
    35113511            'storage/SQLStatementErrorCallback.h',
     3512            'storage/SQLStatementSync.cpp',
     3513            'storage/SQLStatementSync.h',
    35123514            'storage/SQLTransaction.cpp',
    35133515            'storage/SQLTransaction.h',
  • trunk/WebCore/WebCore.pro

    r63230 r63278  
    23802380        storage/SQLResultSetRowList.cpp \
    23812381        storage/SQLStatement.cpp \
     2382        storage/SQLStatementSync.cpp \
    23822383        storage/SQLTransaction.cpp \
    23832384        storage/SQLTransactionClient.cpp \
     
    24582459        storage/SQLResultSetRowList.h \
    24592460        storage/SQLStatement.h \
     2461        storage/SQLStatementSync.h \
    24602462        storage/SQLTransaction.h \
    24612463        storage/SQLTransactionClient.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r63230 r63278  
    5008250082                        </File>
    5008350083                        <File
     50084                                RelativePath="..\storage\SQLStatementSync.cpp"
     50085                                >
     50086                        </File>
     50087                        <File
     50088                                RelativePath="..\storage\SQLStatementSync.h"
     50089                                >
     50090                        </File>
     50091                        <File
    5008450092                                RelativePath="..\storage\SQLTransaction.cpp"
    5008550093                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r63230 r63278  
    43004300                B525A96511CA2340003A23A8 /* JSSQLException.h in Headers */ = {isa = PBXBuildFile; fileRef = B525A96311CA2340003A23A8 /* JSSQLException.h */; };
    43014301                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 */; };
    43024304                B55D5AA4119131FC00BCC315 /* JSSQLTransactionSyncCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B55D5AA2119131FC00BCC315 /* JSSQLTransactionSyncCallback.h */; };
    43034305                B55D5AA5119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55D5AA3119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp */; };
     
    98929894                B525A96311CA2340003A23A8 /* JSSQLException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLException.h; sourceTree = "<group>"; };
    98939895                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>"; };
    98949898                B55D5AA2119131FC00BCC315 /* JSSQLTransactionSyncCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSQLTransactionSyncCallback.h; sourceTree = "<group>"; };
    98959899                B55D5AA3119131FC00BCC315 /* JSSQLTransactionSyncCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionSyncCallback.cpp; sourceTree = "<group>"; };
     
    1135211356                                1A7CCB160CD9469A00B7B64E /* SQLStatementErrorCallback.h */,
    1135311357                                B59DD68F1190298E007E9684 /* SQLStatementErrorCallback.idl */,
     11358                                B550B52111DC68A800923885 /* SQLStatementSync.cpp */,
     11359                                B550B52211DC68A800923885 /* SQLStatementSync.h */,
    1135411360                                1ABFE7520CD968D000FE4834 /* SQLTransaction.cpp */,
    1135511361                                1A7CCB220CD946FD00B7B64E /* SQLTransaction.h */,
     
    1929219298                                1A7CCB190CD9469A00B7B64E /* SQLStatementCallback.h in Headers */,
    1929319299                                1A7CCB1A0CD9469A00B7B64E /* SQLStatementErrorCallback.h in Headers */,
     19300                                B550B52611DC68A800923885 /* SQLStatementSync.h in Headers */,
    1929419301                                1A7CCB240CD946FD00B7B64E /* SQLTransaction.h in Headers */,
    1929519302                                1A7CCB1B0CD9469A00B7B64E /* SQLTransactionCallback.h in Headers */,
     
    2174621753                                1AFE117D0CBFFB36003017FA /* SQLResultSetRowList.cpp in Sources */,
    2174721754                                515B039A0CD1642A00B7EA9C /* SQLStatement.cpp in Sources */,
     21755                                B550B52511DC68A800923885 /* SQLStatementSync.cpp in Sources */,
    2174821756                                1ABFE7530CD968D000FE4834 /* SQLTransaction.cpp in Sources */,
    2174921757                                B51BF6F0102C9E590002C15A /* SQLTransactionClient.cpp in Sources */,
  • trunk/WebCore/storage/AbstractDatabase.cpp

    r62153 r63278  
    3333#include "DatabaseAuthorizer.h"
    3434#include "DatabaseTracker.h"
    35 #include "ExceptionCode.h"
    3635#include "Logging.h"
    3736#include "SQLiteStatement.h"
     
    463462}
    464463
     464unsigned long long AbstractDatabase::maximumSize() const
     465{
     466    return DatabaseTracker::tracker().getMaxSizeForDatabase(this);
     467}
     468
     469void 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
    465477} // namespace WebCore
    466478
  • trunk/WebCore/storage/AbstractDatabase.h

    r62153 r63278  
    3232#if ENABLE(DATABASE)
    3333
     34#include "ExceptionCode.h"
    3435#include "PlatformString.h"
    3536#include "SQLiteDatabase.h"
     
    4546class ScriptExecutionContext;
    4647class SecurityOrigin;
    47 
    48 typedef int ExceptionCode;
    4948
    5049class AbstractDatabase : public ThreadSafeShared<AbstractDatabase> {
     
    6665    virtual unsigned long estimatedSize() const;
    6766    virtual String fileName() const;
     67    SQLiteDatabase& sqliteDatabase() { return m_sqliteDatabase; }
     68
     69    unsigned long long maximumSize() const;
     70    void incrementalVacuumIfNeeded();
    6871
    6972    // FIXME: move all version-related methods to a DatabaseVersionTracker class
     
    104107    String m_filename;
    105108
    106     SQLiteDatabase m_sqliteDatabase;
    107 
    108109#ifndef NDEBUG
    109110    String databaseDebugName() const { return m_contextThreadSecurityOrigin->toString() + "::" + m_name; }
     
    117118    bool m_new;
    118119
     120    SQLiteDatabase m_sqliteDatabase;
     121
    119122    RefPtr<DatabaseAuthorizer> m_databaseAuthorizer;
    120123};
  • trunk/WebCore/storage/ChangeVersionWrapper.cpp

    r60508 r63278  
    5151    if (!transaction->database()->getVersionFromDatabase(actualVersion)) {
    5252        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");
    5454        return false;
    5555    }
     
    5757    if (actualVersion != m_oldVersion) {
    5858        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");
    6060        return false;
    6161    }
     
    7070    if (!transaction->database()->setVersionInDatabase(m_newVersion)) {
    7171        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");
    7373        return false;
    7474    }
  • trunk/WebCore/storage/Database.cpp

    r62411 r63278  
    3737#include "DatabaseTracker.h"
    3838#include "Document.h"
    39 #include "ExceptionCode.h"
    4039#include "InspectorController.h"
    4140#include "Logging.h"
     
    337336    disableAuthorizer();
    338337
    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';");
    340339    if (statement.prepare() != SQLResultOk) {
    341340        LOG_ERROR("Unable to retrieve list of tables for database %s", databaseDebugName().ascii().data());
     
    398397}
    399398
    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 
    408399} // namespace WebCore
    409400
  • trunk/WebCore/storage/Database.h

    r62411 r63278  
    3232#if ENABLE(DATABASE)
    3333#include "AbstractDatabase.h"
     34#include "ExceptionCode.h"
    3435#include "PlatformString.h"
    35 #include "SQLiteDatabase.h"
    3636
    3737#include <wtf/Deque.h>
     
    6767
    6868    virtual SecurityOrigin* securityOrigin() const;
    69     SQLiteDatabase& sqliteDatabase() { return m_sqliteDatabase; }
    7069
    7170    virtual void markAsDeletedAndClose();
     
    8382    SQLTransactionClient* transactionClient() const;
    8483    SQLTransactionCoordinator* transactionCoordinator() const;
    85 
    86     void incrementalVacuumIfNeeded();
    8784
    8885private:
  • trunk/WebCore/storage/DatabaseAuthorizer.cpp

    r62153 r63278  
    291291
    292292    // Allow only the FTS3 extension
    293     if (moduleName != "fts3")
     293    if (!equalIgnoringCase(moduleName, "fts3"))
    294294        return SQLAuthDeny;
    295295
     
    304304
    305305    // Allow only the FTS3 extension
    306     if (moduleName != "fts3")
     306    if (!equalIgnoringCase(moduleName, "fts3"))
    307307        return SQLAuthDeny;
    308308
  • trunk/WebCore/storage/DatabaseCallback.h

    r58989 r63278  
    3434#if ENABLE(DATABASE)
    3535
    36 #include <wtf/Threading.h>
     36#include <wtf/ThreadSafeShared.h>
    3737
    3838namespace WebCore {
  • trunk/WebCore/storage/DatabaseSync.cpp

    r62153 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
    2830
     
    3335#include "DatabaseCallback.h"
    3436#include "DatabaseTracker.h"
    35 #include "ExceptionCode.h"
    3637#include "Logging.h"
     38#include "SQLException.h"
     39#include "SQLTransactionSync.h"
    3740#include "SQLTransactionSyncCallback.h"
    3841#include "ScriptExecutionContext.h"
     
    8891}
    8992
    90 void DatabaseSync::changeVersion(const String&, const String&, PassRefPtr<SQLTransactionSyncCallback>, ExceptionCode&)
     93void DatabaseSync::changeVersion(const String& oldVersion, const String& newVersion, PassRefPtr<SQLTransactionSyncCallback> changeVersionCallback, ExceptionCode& ec)
    9194{
    9295    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);
    93129}
    94130
    95 void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback>, bool, ExceptionCode&)
     131void DatabaseSync::transaction(PassRefPtr<SQLTransactionSyncCallback> callback, bool readOnly, ExceptionCode& ec)
    96132{
    97133    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();
    98143}
    99144
  • trunk/WebCore/storage/DatabaseSync.h

    r62153 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
    2830
     
    3234#if ENABLE(DATABASE)
    3335#include "AbstractDatabase.h"
     36#include "ExceptionCode.h"
    3437#include "PlatformString.h"
    3538#include <wtf/Forward.h>
     
    4144
    4245class DatabaseCallback;
     46class SQLTransactionSync;
    4347class SQLTransactionSyncCallback;
    4448class ScriptExecutionContext;
  • trunk/WebCore/storage/DatabaseSync.idl

    r58989 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
    2830
  • trunk/WebCore/storage/DatabaseTracker.cpp

    r62411 r63278  
    222222unsigned long long DatabaseTracker::getMaxSizeForDatabase(const AbstractDatabase* database)
    223223{
    224     ASSERT(currentThread() == database->scriptExecutionContext()->databaseThread()->getThreadID());
    225224    // The maximum size for a database is the full quota for its origin, minus the current usage within the origin,
    226225    // plus the current usage of the given database
  • trunk/WebCore/storage/SQLError.h

    r61352 r63278  
    3333
    3434#include "PlatformString.h"
    35 #include <wtf/Threading.h>
     35#include <wtf/ThreadSafeShared.h>
    3636
    3737namespace WebCore {
  • trunk/WebCore/storage/SQLResultSet.cpp

    r43699 r63278  
    3131
    3232#if ENABLE(DATABASE)
    33 
    34 #include "ExceptionCode.h"
    35 #include "SQLValue.h"
    3633
    3734namespace WebCore {
  • trunk/WebCore/storage/SQLResultSet.h

    r43699 r63278  
    3232#if ENABLE(DATABASE)
    3333
     34#include "ExceptionCode.h"
    3435#include "SQLResultSetRowList.h"
    35 #include <wtf/Threading.h>
     36#include <wtf/ThreadSafeShared.h>
    3637
    3738namespace WebCore {
    38 
    39 typedef int ExceptionCode;
    4039
    4140class SQLResultSet : public ThreadSafeShared<SQLResultSet> {
  • trunk/WebCore/storage/SQLStatementCallback.h

    r58801 r63278  
    3131#if ENABLE(DATABASE)
    3232
    33 #include <wtf/Threading.h>
     33#include <wtf/ThreadSafeShared.h>
    3434
    3535namespace WebCore {
  • trunk/WebCore/storage/SQLStatementErrorCallback.h

    r57530 r63278  
    3232#if ENABLE(DATABASE)
    3333
    34 #include <wtf/Threading.h>
     34#include <wtf/ThreadSafeShared.h>
    3535
    3636namespace WebCore {
  • trunk/WebCore/storage/SQLStatementSync.cpp

    r62424 r63278  
    11/*
    22 * Copyright (C) 2007 Apple Inc. All rights reserved.
     3 * Copyright (C) 2010 Google Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2627 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2728 */
     29
    2830#include "config.h"
    29 #include "SQLStatement.h"
     31#include "SQLStatementSync.h"
    3032
    3133#if ENABLE(DATABASE)
    3234
    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"
    3639#include "SQLiteDatabase.h"
    3740#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>
    4243
    4344namespace WebCore {
    4445
    45 PassRefPtr<SQLStatement> SQLStatement::create(const String& statement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> errorCallback, bool readOnly)
     46SQLStatementSync::SQLStatementSync(const String& statement, const Vector<SQLValue>& arguments, bool readOnly)
     47    : m_statement(statement)
     48    , m_arguments(arguments)
     49    , m_readOnly(readOnly)
    4650{
    47     return adoptRef(new SQLStatement(statement, arguments, callback, errorCallback, readOnly));
     51    ASSERT(!m_statement.isEmpty());
    4852}
    4953
    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)
     54PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionCode& ec)
    5655{
    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 now
    64     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 
    7156    if (m_readOnly)
    7257        db->setAuthorizerReadOnly();
     
    7661    SQLiteStatement statement(*database, m_statement);
    7762    int result = statement.prepare();
    78 
    7963    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;
    8366    }
    8467
    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 malicious
    8768    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;
    9171    }
    9272
     
    9474        result = statement.bindValue(i + 1, m_arguments[i]);
    9575        if (result == SQLResultFull) {
    96             setFailureDueToQuota();
    97             return false;
     76            ec = SQLException::QUOTA_ERR;
     77            return 0;
    9878        }
    9979
    10080        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;
    10483        }
    10584    }
     
    124103
    125104        if (result != SQLResultDone) {
    126             m_error = SQLError::create(SQLError::DATABASE_ERR, database->lastErrorMsg());
    127             return false;
     105            ec = SQLException::DATABASE_ERR;
     106            return 0;
    128107        }
    129108    } else if (result == SQLResultDone) {
    130         // Didn't find anything, or was an insert
     109        // Didn't find anything, or was an insert.
    131110        if (db->lastActionWasInsert())
    132111            resultSet->setInsertId(database->lastInsertRowID());
    133112    } else if (result == SQLResultFull) {
    134         // Return the Quota error - the delegate will be asked for more space and this statement might be re-run
    135         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;
    137116    } else {
    138         m_error = SQLError::create(SQLError::DATABASE_ERR, database->lastErrorMsg());
    139         return false;
     117        ec = SQLException::DATABASE_ERR;
     118        return 0;
    140119    }
    141120
    142     // FIXME: If the spec allows triggers, and we want to be "accurate" in a different way, we'd use
    143     // sqlite3_total_changes() here instead of sqlite3_changed, because that includes rows modified from within a trigger
    144     // For now, this seems sufficient
    145121    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();
    199123}
    200124
  • trunk/WebCore/storage/SQLTransaction.cpp

    r62411 r63278  
    3434#include "Database.h"
    3535#include "DatabaseThread.h"
    36 #include "ExceptionCode.h"
    3736#include "Logging.h"
    3837#include "PlatformString.h"
     
    371370            m_modifiedDatabase = true;
    372371            // Also dirty the size of this database file for calculating quota usage
    373             m_database->transactionClient()->didExecuteStatement(this);
     372            m_database->transactionClient()->didExecuteStatement(database());
    374373        }
    375374
     
    433432    ASSERT(!m_shouldRetryCurrentStatement);
    434433
    435     m_shouldRetryCurrentStatement = m_database->transactionClient()->didExceedQuota(this);
     434    m_shouldRetryCurrentStatement = m_database->transactionClient()->didExceedQuota(database());
    436435
    437436    m_nextStep = &SQLTransaction::runStatements;
     
    473472    // The commit was successful. If the transaction modified this database, notify the delegates.
    474473    if (m_modifiedDatabase)
    475         m_database->transactionClient()->didCommitTransaction(this);
     474        m_database->transactionClient()->didCommitWriteTransaction(database());
    476475
    477476    // Now release our unneeded callbacks, to break reference cycles.
  • trunk/WebCore/storage/SQLTransaction.h

    r60508 r63278  
    3131#if ENABLE(DATABASE)
    3232
    33 #include <wtf/Threading.h>
    34 
     33#include "ExceptionCode.h"
    3534#include "SQLStatement.h"
    3635#include <wtf/Deque.h>
    3736#include <wtf/Forward.h>
     37#include <wtf/ThreadSafeShared.h>
    3838#include <wtf/Vector.h>
    3939
    4040namespace WebCore {
    41 
    42 typedef int ExceptionCode;
    4341
    4442class Database;
  • trunk/WebCore/storage/SQLTransactionCallback.h

    r58801 r63278  
    3232#if ENABLE(DATABASE)
    3333
    34 #include <wtf/Threading.h>
     34#include <wtf/ThreadSafeShared.h>
    3535
    3636namespace WebCore {
  • trunk/WebCore/storage/SQLTransactionClient.cpp

    r57668 r63278  
    3434#if ENABLE(DATABASE)
    3535
    36 #include "Chrome.h"
    37 #include "ChromeClient.h"
    38 #include "Database.h"
    39 #include "DatabaseThread.h"
     36#include "AbstractDatabase.h"
    4037#include "DatabaseTracker.h"
    41 #include "Document.h"
    42 #include "Page.h"
    43 #include "SQLTransaction.h"
     38#include "ScriptExecutionContext.h"
     39#include "SecurityOrigin.h"
    4440
    4541namespace WebCore {
    4642
    47 void SQLTransactionClient::didCommitTransaction(SQLTransaction* transaction)
     43void SQLTransactionClient::didCommitWriteTransaction(AbstractDatabase* database)
    4844{
    49     ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID());
    50     Database* database = transaction->database();
    5145    DatabaseTracker::tracker().scheduleNotifyDatabaseChanged(
    5246        database->securityOrigin(), database->stringIdentifier());
    5347}
    5448
    55 void SQLTransactionClient::didExecuteStatement(SQLTransaction* transaction)
     49void SQLTransactionClient::didExecuteStatement(AbstractDatabase* database)
    5650{
    57     ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID());
    58     DatabaseTracker::tracker().databaseChanged(transaction->database());
     51    DatabaseTracker::tracker().databaseChanged(database);
    5952}
    6053
    61 bool SQLTransactionClient::didExceedQuota(SQLTransaction* transaction)
     54bool SQLTransactionClient::didExceedQuota(AbstractDatabase* database)
    6255{
    63     ASSERT(transaction->database()->scriptExecutionContext()->isContextThread());
    64     Database* database = transaction->database();
    65 
     56    ASSERT(database->scriptExecutionContext()->isContextThread());
    6657    unsigned long long currentQuota = DatabaseTracker::tracker().quotaForOrigin(database->securityOrigin());
    6758    database->scriptExecutionContext()->databaseExceededQuota(database->stringIdentifier());
  • trunk/WebCore/storage/SQLTransactionClient.h

    r52060 r63278  
    3838namespace WebCore {
    3939
    40     class SQLTransaction;
     40class AbstractDatabase;
    4141
    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.
     44class SQLTransactionClient : public Noncopyable {
     45public:
     46    void didCommitWriteTransaction(AbstractDatabase*);
     47    void didExecuteStatement(AbstractDatabase*);
     48    bool didExceedQuota(AbstractDatabase*);
     49};
     50
    5051}
    5152
  • trunk/WebCore/storage/SQLTransactionErrorCallback.h

    r58801 r63278  
    3232#if ENABLE(DATABASE)
    3333
    34 #include <wtf/Threading.h>
     34#include <wtf/ThreadSafeShared.h>
    3535
    3636namespace WebCore {
  • trunk/WebCore/storage/SQLTransactionSync.cpp

    r58437 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
    2830
     
    3335
    3436#include "DatabaseSync.h"
    35 #include "ExceptionCode.h"
    3637#include "PlatformString.h"
     38#include "SQLException.h"
    3739#include "SQLResultSet.h"
     40#include "SQLStatementSync.h"
     41#include "SQLTransactionClient.h"
    3842#include "SQLTransactionSyncCallback.h"
    3943#include "SQLValue.h"
     44#include "SQLiteTransaction.h"
    4045#include "ScriptExecutionContext.h"
    4146#include <wtf/PassRefPtr.h>
     
    5358    , m_callback(callback)
    5459    , 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());
    5864}
    5965
     
    6167{
    6268    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
     73PassRefPtr<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
     120ExceptionCode 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
    68147    return 0;
    69148}
    70149
     150ExceptionCode 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
     162ExceptionCode 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
     191void 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
    71204} // namespace WebCore
    72205
  • trunk/WebCore/storage/SQLTransactionSync.h

    r58437 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
     30
    2831#ifndef SQLTransactionSync_h
    2932#define SQLTransactionSync_h
     
    3134#if ENABLE(DATABASE)
    3235
     36#include "ExceptionCode.h"
    3337#include <wtf/Forward.h>
    3438#include <wtf/RefCounted.h>
     
    3741namespace WebCore {
    3842
    39 typedef int ExceptionCode;
    40 
    4143class DatabaseSync;
    4244class SQLResultSet;
     45class SQLTransactionClient;
    4346class SQLTransactionSyncCallback;
    4447class SQLValue;
     48class SQLiteTransaction;
    4549class String;
    4650
     
    5761    bool isReadOnly() const { return m_readOnly; }
    5862
     63    ExceptionCode begin();
     64    ExceptionCode execute();
     65    ExceptionCode commit();
     66    void rollback();
     67
    5968private:
    6069    SQLTransactionSync(DatabaseSync*, PassRefPtr<SQLTransactionSyncCallback>, bool readOnly);
     
    6372    RefPtr<SQLTransactionSyncCallback> m_callback;
    6473    bool m_readOnly;
     74
     75    bool m_modifiedDatabase;
     76    OwnPtr<SQLTransactionClient> m_transactionClient;
     77    OwnPtr<SQLiteTransaction> m_sqliteTransaction;
    6578};
    6679
  • trunk/WebCore/storage/SQLTransactionSync.idl

    r58989 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
    2830
  • trunk/WebCore/storage/SQLTransactionSyncCallback.h

    r60289 r63278  
    33 *
    44 * 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:
    167 *
    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.
    2729 */
    2830
     
    3335
    3436#include <wtf/RefCounted.h>
    35 #include <wtf/Threading.h>
    3637
    3738namespace WebCore {
  • trunk/WebCore/storage/SQLTransactionSyncCallback.idl

    r58989 r63278  
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
     5 * modification, are permitted provided that the following conditions are
     6 * met:
    77 *
    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.
    1617 *
    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.
    2729 */
    2830
  • trunk/WebCore/storage/chromium/SQLTransactionClientChromium.cpp

    r53595 r63278  
    3232#include "SQLTransactionClient.h"
    3333
    34 #include "Database.h"
     34#include "AbstractDatabase.h"
    3535#include "DatabaseObserver.h"
    36 #include "DatabaseThread.h"
    37 #include "Document.h"
    38 #include "SQLTransaction.h"
    39 #include <wtf/MainThread.h>
     36#include "ScriptExecutionContext.h"
    4037
    4138namespace WebCore {
     
    4340class NotifyDatabaseChangedTask : public ScriptExecutionContext::Task {
    4441public:
    45     static PassOwnPtr<NotifyDatabaseChangedTask> create(Database *database)
     42    static PassOwnPtr<NotifyDatabaseChangedTask> create(AbstractDatabase *database)
    4643    {
    4744        return new NotifyDatabaseChangedTask(database);
     
    5451
    5552private:
    56     NotifyDatabaseChangedTask(PassRefPtr<Database> database)
     53    NotifyDatabaseChangedTask(PassRefPtr<AbstractDatabase> database)
    5754        : m_database(database)
    5855    {
    5956    }
    6057
    61     RefPtr<Database> m_database;
     58    RefPtr<AbstractDatabase> m_database;
    6259};
    6360
    64 void SQLTransactionClient::didCommitTransaction(SQLTransaction* transaction)
     61void SQLTransactionClient::didCommitWriteTransaction(AbstractDatabase* database)
    6562{
    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;
    6966    }
     67
     68    WebCore::DatabaseObserver::databaseModified(database);
    7069}
    7170
    72 void SQLTransactionClient::didExecuteStatement(SQLTransaction* transaction)
     71void SQLTransactionClient::didExecuteStatement(AbstractDatabase* database)
    7372{
    7473    // This method is called after executing every statement that changes the DB.
    7574    // Chromium doesn't need to do anything at that point.
    76     ASSERT(currentThread() == transaction->database()->scriptExecutionContext()->databaseThread()->getThreadID());
    7775}
    7876
    79 bool SQLTransactionClient::didExceedQuota(SQLTransaction* transaction)
     77bool SQLTransactionClient::didExceedQuota(AbstractDatabase* database)
    8078{
    8179    // Chromium does not allow users to manually change the quota for an origin (for now, at least).
    8280    // Don't do anything.
    83     ASSERT(transaction->database()->scriptExecutionContext()->isContextThread());
     81    ASSERT(database->scriptExecutionContext()->isContextThread());
    8482    return false;
    8583}
Note: See TracChangeset for help on using the changeset viewer.