| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 virtual bool performPreflight(SQLTransactionBackend*) = 0; | 53 virtual bool performPreflight(SQLTransactionBackend*) = 0; |
| 54 virtual bool performPostflight(SQLTransactionBackend*) = 0; | 54 virtual bool performPostflight(SQLTransactionBackend*) = 0; |
| 55 virtual SQLErrorData* sqlError() const = 0; | 55 virtual SQLErrorData* sqlError() const = 0; |
| 56 virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0; | 56 virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class SQLTransactionBackend final : public GarbageCollectedFinalized<SQLTransact
ionBackend>, public SQLTransactionStateMachine<SQLTransactionBackend> { | 59 class SQLTransactionBackend final : public GarbageCollectedFinalized<SQLTransact
ionBackend>, public SQLTransactionStateMachine<SQLTransactionBackend> { |
| 60 public: | 60 public: |
| 61 static SQLTransactionBackend* create(Database*, SQLTransaction*, SQLTransact
ionWrapper*, bool readOnly); | 61 static SQLTransactionBackend* create(Database*, SQLTransaction*, SQLTransact
ionWrapper*, bool readOnly); |
| 62 | 62 |
| 63 virtual ~SQLTransactionBackend(); | 63 ~SQLTransactionBackend() override; |
| 64 DECLARE_TRACE(); | 64 DECLARE_TRACE(); |
| 65 | 65 |
| 66 void lockAcquired(); | 66 void lockAcquired(); |
| 67 void performNextStep(); | 67 void performNextStep(); |
| 68 | 68 |
| 69 Database* database() { return m_database.get(); } | 69 Database* database() { return m_database.get(); } |
| 70 bool isReadOnly() { return m_readOnly; } | 70 bool isReadOnly() { return m_readOnly; } |
| 71 void notifyDatabaseThreadIsShuttingDown(); | 71 void notifyDatabaseThreadIsShuttingDown(); |
| 72 | 72 |
| 73 // APIs called from the frontend published: | 73 // APIs called from the frontend published: |
| 74 void requestTransitToState(SQLTransactionState); | 74 void requestTransitToState(SQLTransactionState); |
| 75 SQLErrorData* transactionError(); | 75 SQLErrorData* transactionError(); |
| 76 SQLStatement* currentStatement(); | 76 SQLStatement* currentStatement(); |
| 77 void setShouldRetryCurrentStatement(bool); | 77 void setShouldRetryCurrentStatement(bool); |
| 78 void executeSQL(SQLStatement*, const String& statement, const Vector<SQLValu
e>& arguments, int permissions); | 78 void executeSQL(SQLStatement*, const String& statement, const Vector<SQLValu
e>& arguments, int permissions); |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 SQLTransactionBackend(Database*, SQLTransaction*, SQLTransactionWrapper*, bo
ol readOnly); | 81 SQLTransactionBackend(Database*, SQLTransaction*, SQLTransactionWrapper*, bo
ol readOnly); |
| 82 | 82 |
| 83 void doCleanup(); | 83 void doCleanup(); |
| 84 | 84 |
| 85 void enqueueStatementBackend(SQLStatementBackend*); | 85 void enqueueStatementBackend(SQLStatementBackend*); |
| 86 | 86 |
| 87 // State Machine functions: | 87 // State Machine functions: |
| 88 virtual StateFunction stateFunctionFor(SQLTransactionState) override; | 88 StateFunction stateFunctionFor(SQLTransactionState) override; |
| 89 void computeNextStateAndCleanupIfNeeded(); | 89 void computeNextStateAndCleanupIfNeeded(); |
| 90 | 90 |
| 91 // State functions: | 91 // State functions: |
| 92 SQLTransactionState acquireLock(); | 92 SQLTransactionState acquireLock(); |
| 93 SQLTransactionState openTransactionAndPreflight(); | 93 SQLTransactionState openTransactionAndPreflight(); |
| 94 SQLTransactionState runStatements(); | 94 SQLTransactionState runStatements(); |
| 95 SQLTransactionState postflightAndCommit(); | 95 SQLTransactionState postflightAndCommit(); |
| 96 SQLTransactionState cleanupAndTerminate(); | 96 SQLTransactionState cleanupAndTerminate(); |
| 97 SQLTransactionState cleanupAfterTransactionErrorCallback(); | 97 SQLTransactionState cleanupAfterTransactionErrorCallback(); |
| 98 | 98 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 123 | 123 |
| 124 Mutex m_statementMutex; | 124 Mutex m_statementMutex; |
| 125 HeapDeque<Member<SQLStatementBackend>> m_statementQueue; | 125 HeapDeque<Member<SQLStatementBackend>> m_statementQueue; |
| 126 | 126 |
| 127 OwnPtr<SQLiteTransaction> m_sqliteTransaction; | 127 OwnPtr<SQLiteTransaction> m_sqliteTransaction; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace blink | 130 } // namespace blink |
| 131 | 131 |
| 132 #endif // SQLTransactionBackend_h | 132 #endif // SQLTransactionBackend_h |
| OLD | NEW |