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