andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | 7398598 | 2015-08-18 19:31:28 +0000 | [diff] [blame] | 2 | * Copyright (C) 2007, 2013, 2015 Apple Inc. All rights reserved. |
andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 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. |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 13 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of |
andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 14 | * its contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 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. |
| 27 | */ |
commit-queue@webkit.org | 553e8d3 | 2016-11-12 08:57:21 +0000 | [diff] [blame] | 28 | |
| 29 | #pragma once |
andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 30 | |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 31 | #include "SQLTransactionStateMachine.h" |
zandobersek@gmail.com | 0483643 | 2014-02-03 19:07:29 +0000 | [diff] [blame] | 32 | #include <memory> |
beidson@apple.com | effd1c7 | 2007-11-14 00:26:48 +0000 | [diff] [blame] | 33 | #include <wtf/Forward.h> |
mark.lam@apple.com | f9b77d6 | 2013-02-16 03:03:50 +0000 | [diff] [blame] | 34 | #include <wtf/text/WTFString.h> |
beidson@apple.com | effd1c7 | 2007-11-14 00:26:48 +0000 | [diff] [blame] | 35 | |
andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 36 | namespace WebCore { |
| 37 | |
andersca@apple.com | 88fedf1 | 2015-01-12 21:58:08 +0000 | [diff] [blame] | 38 | class Database; |
mark.lam@apple.com | f009ae4 | 2013-03-05 15:54:13 +0000 | [diff] [blame] | 39 | class OriginLock; |
beidson@apple.com | effd1c7 | 2007-11-14 00:26:48 +0000 | [diff] [blame] | 40 | class SQLError; |
dumi@chromium.org | 5d072b8 | 2010-06-01 21:39:11 +0000 | [diff] [blame] | 41 | class SQLiteTransaction; |
andersca@apple.com | 61fc0d5 | 2015-08-06 23:35:12 +0000 | [diff] [blame] | 42 | class SQLStatement; |
andersca@apple.com | 2cf28b6 | 2015-01-08 22:11:44 +0000 | [diff] [blame] | 43 | class SQLTransaction; |
andersca@apple.com | 471b81f | 2016-08-10 16:47:12 +0000 | [diff] [blame] | 44 | class SQLTransactionWrapper; |
beidson@apple.com | effd1c7 | 2007-11-14 00:26:48 +0000 | [diff] [blame] | 45 | |
andersca@apple.com | 5304277 | 2016-08-10 18:41:33 +0000 | [diff] [blame] | 46 | class SQLTransactionBackend : public SQLTransactionStateMachine<SQLTransactionBackend> { |
beidson@apple.com | effd1c7 | 2007-11-14 00:26:48 +0000 | [diff] [blame] | 47 | public: |
andersca@apple.com | abcc69a | 2016-08-10 20:30:14 +0000 | [diff] [blame] | 48 | explicit SQLTransactionBackend(SQLTransaction&); |
andersca@apple.com | 5304277 | 2016-08-10 18:41:33 +0000 | [diff] [blame] | 49 | ~SQLTransactionBackend(); |
abarth@webkit.org | 56314f2 | 2009-08-27 05:22:54 +0000 | [diff] [blame] | 50 | |
dumi@chromium.org | 5cfa18f | 2010-02-01 23:32:44 +0000 | [diff] [blame] | 51 | void notifyDatabaseThreadIsShuttingDown(); |
ap@webkit.org | 6498471 | 2008-02-12 19:37:03 +0000 | [diff] [blame] | 52 | |
andersca@apple.com | 3393599 | 2016-08-10 21:31:07 +0000 | [diff] [blame] | 53 | // API called from the frontend published via SQLTransactionBackend: |
andersca@apple.com | 668e912 | 2015-01-08 21:13:41 +0000 | [diff] [blame] | 54 | void requestTransitToState(SQLTransactionState); |
andersca@apple.com | 3393599 | 2016-08-10 21:31:07 +0000 | [diff] [blame] | 55 | |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 56 | private: |
andersca@apple.com | 3393599 | 2016-08-10 21:31:07 +0000 | [diff] [blame] | 57 | friend class SQLTransaction; |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 58 | |
| 59 | void doCleanup(); |
abarth@webkit.org | 56314f2 | 2009-08-27 05:22:54 +0000 | [diff] [blame] | 60 | |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 61 | // State Machine functions: |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 62 | StateFunction stateFunctionFor(SQLTransactionState) override; |
mark.lam@apple.com | a9ac1a4 | 2013-02-20 21:10:18 +0000 | [diff] [blame] | 63 | void computeNextStateAndCleanupIfNeeded(); |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 64 | |
| 65 | // State functions: |
andersca@apple.com | cf21601 | 2015-08-24 17:16:47 +0000 | [diff] [blame] | 66 | void acquireLock(); |
| 67 | void openTransactionAndPreflight(); |
| 68 | void runStatements(); |
| 69 | void cleanupAndTerminate(); |
| 70 | void cleanupAfterTransactionErrorCallback(); |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 71 | |
andersca@apple.com | cf21601 | 2015-08-24 17:16:47 +0000 | [diff] [blame] | 72 | NO_RETURN_DUE_TO_ASSERT void unreachableState(); |
mark.lam@apple.com | ad8bdf6 | 2013-02-14 22:31:20 +0000 | [diff] [blame] | 73 | |
andersca@apple.com | 5304277 | 2016-08-10 18:41:33 +0000 | [diff] [blame] | 74 | SQLTransaction& m_frontend; |
andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 75 | }; |
abarth@webkit.org | 56314f2 | 2009-08-27 05:22:54 +0000 | [diff] [blame] | 76 | |
andersca | 4912acec | 2007-11-01 01:16:23 +0000 | [diff] [blame] | 77 | } // namespace WebCore |