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