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 ~SQLTransactionWrapper() { } | 53 virtual ~SQLTransactionWrapper() { } |
54 virtual bool performPreflight(SQLTransactionBackend*) = 0; | 54 virtual bool performPreflight(SQLTransactionBackend*) = 0; |
55 virtual bool performPostflight(SQLTransactionBackend*) = 0; | 55 virtual bool performPostflight(SQLTransactionBackend*) = 0; |
56 virtual SQLError* sqlError() const = 0; | 56 virtual SQLError* sqlError() const = 0; |
57 virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0; | 57 virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0; |
58 }; | 58 }; |
59 | 59 |
60 class SQLTransactionBackend FINAL : public SQLTransactionStateMachine<SQLTransac
tionBackend>, public AbstractSQLTransactionBackend { | 60 class SQLTransactionBackend FINAL : public SQLTransactionStateMachine<SQLTransac
tionBackend>, public AbstractSQLTransactionBackend { |
61 public: | 61 public: |
62 static PassRefPtr<SQLTransactionBackend> create(DatabaseBackend*, | 62 static PassRefPtr<SQLTransactionBackend> create(DatabaseBackend*, |
63 PassRefPtr<AbstractSQLTransaction>, PassRefPtr<SQLTransactionWrapper>, b
ool readOnly); | 63 PassRefPtrWillBeRawPtr<AbstractSQLTransaction>, PassRefPtr<SQLTransactio
nWrapper>, bool readOnly); |
64 | 64 |
65 virtual ~SQLTransactionBackend(); | 65 virtual ~SQLTransactionBackend(); |
66 | 66 |
67 void lockAcquired(); | 67 void lockAcquired(); |
68 void performNextStep(); | 68 void performNextStep(); |
69 | 69 |
70 DatabaseBackend* database() { return m_database.get(); } | 70 DatabaseBackend* database() { return m_database.get(); } |
71 bool isReadOnly() { return m_readOnly; } | 71 bool isReadOnly() { return m_readOnly; } |
72 void notifyDatabaseThreadIsShuttingDown(); | 72 void notifyDatabaseThreadIsShuttingDown(); |
73 | 73 |
74 private: | 74 private: |
75 SQLTransactionBackend(DatabaseBackend*, PassRefPtr<AbstractSQLTransaction>, | 75 SQLTransactionBackend(DatabaseBackend*, PassRefPtrWillBeRawPtr<AbstractSQLTr
ansaction>, |
76 PassRefPtr<SQLTransactionWrapper>, bool readOnly); | 76 PassRefPtr<SQLTransactionWrapper>, bool readOnly); |
77 | 77 |
78 // APIs called from the frontend published via AbstractSQLTransactionBackend
: | 78 // APIs called from the frontend published via AbstractSQLTransactionBackend
: |
79 virtual void requestTransitToState(SQLTransactionState) OVERRIDE; | 79 virtual void requestTransitToState(SQLTransactionState) OVERRIDE; |
80 virtual PassRefPtr<SQLError> transactionError() OVERRIDE; | 80 virtual PassRefPtr<SQLError> transactionError() OVERRIDE; |
81 virtual AbstractSQLStatement* currentStatement() OVERRIDE; | 81 virtual AbstractSQLStatement* currentStatement() OVERRIDE; |
82 virtual void setShouldRetryCurrentStatement(bool) OVERRIDE; | 82 virtual void setShouldRetryCurrentStatement(bool) OVERRIDE; |
83 virtual void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& stat
ement, | 83 virtual void executeSQL(PassOwnPtr<AbstractSQLStatement>, const String& stat
ement, |
84 const Vector<SQLValue>& arguments, int permissions) OVERRIDE; | 84 const Vector<SQLValue>& arguments, int permissions) OVERRIDE; |
85 | 85 |
(...skipping 15 matching lines...) Expand all Loading... |
101 | 101 |
102 SQLTransactionState unreachableState(); | 102 SQLTransactionState unreachableState(); |
103 SQLTransactionState sendToFrontendState(); | 103 SQLTransactionState sendToFrontendState(); |
104 | 104 |
105 SQLTransactionState nextStateForCurrentStatementError(); | 105 SQLTransactionState nextStateForCurrentStatementError(); |
106 SQLTransactionState nextStateForTransactionError(); | 106 SQLTransactionState nextStateForTransactionError(); |
107 SQLTransactionState runCurrentStatementAndGetNextState(); | 107 SQLTransactionState runCurrentStatementAndGetNextState(); |
108 | 108 |
109 void getNextStatement(); | 109 void getNextStatement(); |
110 | 110 |
111 RefPtr<AbstractSQLTransaction> m_frontend; // Has a reference cycle, and wil
l break in doCleanup(). | 111 RefPtrWillBeCrossThreadPersistent<AbstractSQLTransaction> m_frontend; // Has
a reference cycle, and will break in doCleanup(). |
112 RefPtr<SQLStatementBackend> m_currentStatementBackend; | 112 RefPtr<SQLStatementBackend> m_currentStatementBackend; |
113 | 113 |
114 RefPtrWillBeCrossThreadPersistent<DatabaseBackend> m_database; | 114 RefPtrWillBeCrossThreadPersistent<DatabaseBackend> m_database; |
115 RefPtr<SQLTransactionWrapper> m_wrapper; | 115 RefPtr<SQLTransactionWrapper> m_wrapper; |
116 RefPtr<SQLError> m_transactionError; | 116 RefPtr<SQLError> m_transactionError; |
117 | 117 |
118 bool m_hasCallback; | 118 bool m_hasCallback; |
119 bool m_hasSuccessCallback; | 119 bool m_hasSuccessCallback; |
120 bool m_hasErrorCallback; | 120 bool m_hasErrorCallback; |
121 bool m_shouldRetryCurrentStatement; | 121 bool m_shouldRetryCurrentStatement; |
122 bool m_modifiedDatabase; | 122 bool m_modifiedDatabase; |
123 bool m_lockAcquired; | 123 bool m_lockAcquired; |
124 bool m_readOnly; | 124 bool m_readOnly; |
125 bool m_hasVersionMismatch; | 125 bool m_hasVersionMismatch; |
126 | 126 |
127 Mutex m_statementMutex; | 127 Mutex m_statementMutex; |
128 Deque<RefPtr<SQLStatementBackend> > m_statementQueue; | 128 Deque<RefPtr<SQLStatementBackend> > m_statementQueue; |
129 | 129 |
130 OwnPtr<SQLiteTransaction> m_sqliteTransaction; | 130 OwnPtr<SQLiteTransaction> m_sqliteTransaction; |
131 }; | 131 }; |
132 | 132 |
133 } // namespace WebCore | 133 } // namespace WebCore |
134 | 134 |
135 #endif // SQLTransactionBackend_h | 135 #endif // SQLTransactionBackend_h |
OLD | NEW |