Changeset 142213 in webkit


Ignore:
Timestamp:
Feb 7, 2013 5:23:45 PM (11 years ago)
Author:
mark.lam@apple.com
Message:

Add a comment about how the SQLTransaction state machine works.
https://bugs.webkit.org/show_bug.cgi?id=109243.

Rubber stamped by Anders Carlsson.

No new tests.

  • Modules/webdatabase/SQLTransactionBackend.cpp:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142212 r142213  
     12013-02-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Add a comment about how the SQLTransaction state machine works.
     4        https://bugs.webkit.org/show_bug.cgi?id=109243.
     5
     6        Rubber stamped by Anders Carlsson.
     7
     8        No new tests.
     9
     10        * Modules/webdatabase/SQLTransactionBackend.cpp:
     11
    1122013-02-06  Gavin Barraclough  <barraclough@apple.com>
    213
  • trunk/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp

    r142193 r142213  
    5656#include <wtf/text/WTFString.h>
    5757
     58
     59// How does a SQLTransaction work?
     60// ==============================
     61// The SQLTransaction is a state machine that executes a series of states / steps.
     62//
     63// ths State Transition Graph at a glance:
     64// ======================================
     65//
     66//    Backend (works with SQLiteDatabase)          .   Frontend (works with Script)
     67//    ===================================          .   ============================
     68//   ,--> State 0: [initial state]                 .
     69//   | ^     v                                     .
     70//   | |  State 1: [acquireLock]                   .
     71//   | |     v                                     .
     72//   | |  State 2: [openTransactionAndPreflight] ----------------------------------------------------.
     73//   | |     |                                     .                                                 |
     74//   | |     `---------------------------------------> State 3: [deliverTransactionCallback] -----.  |
     75//   | |                                           .      |                                       v  v
     76//   | |     ,--------------------------------------------'     State 10: [deliverTransactionErrorCallback] +
     77//   | |     |                                     .                                              ^  ^  ^   |
     78//   | |     v                                     .                                              |  |  |   |
     79//   | |  State 4: [runStatements] ---------------------------------------------------------------'  |  |   |
     80//   | |     |        ^  ^ |  ^ |                  .                                                 |  |   |
     81//   | |     |--------'  | |  | `--------------------> State 8: [deliverStatementCallback] +---------'  |   |
     82//   | |     |           | |  `------------------------------------------------------------'            |   |
     83//   | |     |           | `-------------------------> State 9: [deliverQuotaIncreaseCallback] +        |   |
     84//   | |     |            `--------------------------------------------------------------------'        |   |
     85//   | |     v                                     .                                                    |   |
     86//   | |  State 5: [postflightAndCommit] --+------------------------------------------------------------'   |
     87//   | |                                   |---------> State 6: [deliverSuccessCallback] +                  |
     88//   | |     ,-----------------------------'       .                                     |                  |
     89//   | |     v                                     .                                     |                  |
     90//   | |  State 7: [cleanupAfterSuccessCallback] <---------------------------------------'                  |
     91//   | `-----'                                     .                                                        |
     92//   `------------------------------------------------------------------------------------------------------'
     93//                                                 .
     94//
     95// the States and State Transitions:
     96// ================================
     97// Executed in the back-end:
     98//     State 0: [initial state]
     99//     - On scheduled transaction, goto [acquireLock].
     100//
     101//     State 1: [acquireLock]
     102//     - acquire lock.
     103//     - on "lock" acquisition, goto [openTransactionAndPreflight].
     104//
     105//     State 2: [openTransactionAndPreflight]
     106//     - Sets up an SQLiteTransaction.
     107//     - begin the SQLiteTransaction.
     108//     - call the SQLTransactionWrapper preflight if available.
     109//     - schedule script callback.
     110//     - on error (see handleTransactionError), goto [deliverTransactionErrorCallback].
     111//     - goto [deliverTransactionCallback].
     112//
     113// Executed in the front-end:
     114//     State 3: [deliverTransactionCallback]
     115//     - invoke the script function callback() if available.
     116//     - on error, goto [deliverTransactionErrorCallback].
     117//     - goto [runStatements].
     118//
     119// Executed in the back-end:
     120//     State 4: [runStatements]
     121//     - while there are statements {
     122//         - run a statement.
     123//         - if statementCallback is available, goto [deliverStatementCallback].
     124//         - on error,
     125//           goto [deliverQuotaIncreaseCallback], or
     126//           goto [deliverStatementCallback] (see handleCurrentStatementError), or
     127//           goto [deliverTransactionErrorCallback].
     128//       }
     129//     - goto [postflightAndCommit].
     130//
     131//     State 5: [postflightAndCommit]
     132//     - call the SQLTransactionWrapper postflight if available.
     133//     - commit the SQLiteTansaction.
     134//     - on error, goto [deliverTransactionErrorCallback] (see handleTransactionError).
     135//     - if successCallback is available, goto [deliverSuccessCallback].
     136//       else goto [cleanupAfterSuccessCallback].
     137//
     138// Executed in the front-end:
     139//     State 6: [deliverSuccessCallback]
     140//     - invoke the script function successCallback() if available.
     141//     - goto [cleanupAfterSuccessCallback].
     142//
     143// Executed in the back-end:
     144//     State 7: [cleanupAfterSuccessCallback]
     145//     - clean the SQLiteTransaction.
     146//     - release lock.
     147//     - goto [initial state].
     148//
     149// Other states:
     150// Executed in the front-end:
     151//     State 8: [deliverStatementCallback]
     152//     - invoke script statement callback (assume available).
     153//     - on error (see handleTransactionError),
     154//       goto [deliverTransactionErrorCallback].
     155//     - goto [runStatements].
     156//
     157//     State 9: [deliverQuotaIncreaseCallback]
     158//     - give client a chance to increase the quota.
     159//     - goto [runStatements].
     160//
     161//     State 10: [deliverTransactionErrorCallback]
     162//     - invoke the script function errorCallback if available.
     163//     - goto [cleanupAfterTransactionErrorCallback].
     164//
     165// Executed in the back-end:
     166//     State 11: [cleanupAfterTransactionErrorCallback]
     167//     - rollback and clear SQLiteTransaction.
     168//     - clear statements.
     169//     - release lock.
     170//     - goto [initial state].
     171
     172
    58173// There's no way of knowing exactly how much more space will be required when a statement hits the quota limit.
    59174// For now, we'll arbitrarily choose currentQuota + 1mb.
Note: See TracChangeset for help on using the changeset viewer.