Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: Source/modules/webdatabase/SQLTransaction.h

Issue 561143002: Web SQL: Remove unnecessary abstraction. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 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 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 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. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef SQLTransaction_h 29 #ifndef SQLTransaction_h
30 #define SQLTransaction_h 30 #define SQLTransaction_h
31 31
32 #include "bindings/core/v8/ScriptWrappable.h" 32 #include "bindings/core/v8/ScriptWrappable.h"
33 #include "modules/webdatabase/AbstractSQLTransaction.h"
34 #include "modules/webdatabase/SQLCallbackWrapper.h" 33 #include "modules/webdatabase/SQLCallbackWrapper.h"
35 #include "modules/webdatabase/SQLStatement.h" 34 #include "modules/webdatabase/SQLStatement.h"
36 #include "modules/webdatabase/SQLTransactionStateMachine.h" 35 #include "modules/webdatabase/SQLTransactionStateMachine.h"
37 #include "platform/heap/Handle.h" 36 #include "platform/heap/Handle.h"
38 #include "wtf/PassRefPtr.h" 37 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefPtr.h" 38 #include "wtf/RefPtr.h"
40 39
41 namespace blink { 40 namespace blink {
42 41
43 class AbstractSQLTransactionBackend;
44 class Database; 42 class Database;
45 class ExceptionState; 43 class ExceptionState;
46 class SQLErrorData; 44 class SQLErrorData;
47 class SQLStatementCallback; 45 class SQLStatementCallback;
48 class SQLStatementErrorCallback; 46 class SQLStatementErrorCallback;
47 class SQLTransactionBackend;
49 class SQLTransactionCallback; 48 class SQLTransactionCallback;
50 class SQLTransactionErrorCallback; 49 class SQLTransactionErrorCallback;
51 class SQLValue; 50 class SQLValue;
52 class VoidCallback; 51 class VoidCallback;
53 52
54 class SQLTransaction FINAL : public AbstractSQLTransaction, public SQLTransactio nStateMachine<SQLTransaction>, public ScriptWrappable { 53 class SQLTransaction FINAL
54 : public ThreadSafeRefCountedWillBeGarbageCollectedFinalized<SQLTransaction>
55 , public SQLTransactionStateMachine<SQLTransaction>
56 , public ScriptWrappable {
55 DEFINE_WRAPPERTYPEINFO(); 57 DEFINE_WRAPPERTYPEINFO();
56 public: 58 public:
57 static PassRefPtrWillBeRawPtr<SQLTransaction> create(Database*, PassOwnPtrWi llBeRawPtr<SQLTransactionCallback>, 59 static PassRefPtrWillBeRawPtr<SQLTransaction> create(Database*, PassOwnPtrWi llBeRawPtr<SQLTransactionCallback>,
58 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRa wPtr<SQLTransactionErrorCallback>, 60 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRa wPtr<SQLTransactionErrorCallback>,
59 bool readOnly); 61 bool readOnly);
60 virtual void trace(Visitor*) OVERRIDE; 62 ~SQLTransaction();
63 void trace(Visitor*);
61 64
62 void performPendingCallback(); 65 void performPendingCallback();
63 66
64 void executeSQL(const String& sqlStatement, const Vector<SQLValue>& argument s, 67 void executeSQL(const String& sqlStatement, const Vector<SQLValue>& argument s,
65 PassOwnPtrWillBeRawPtr<SQLStatementCallback>, PassOwnPtrWillBeRawPtr<SQL StatementErrorCallback>, ExceptionState&); 68 PassOwnPtrWillBeRawPtr<SQLStatementCallback>, PassOwnPtrWillBeRawPtr<SQL StatementErrorCallback>, ExceptionState&);
66 69
67 Database* database() { return m_database.get(); } 70 Database* database() { return m_database.get(); }
68 71
69 PassOwnPtrWillBeRawPtr<SQLTransactionErrorCallback> releaseErrorCallback(); 72 PassOwnPtrWillBeRawPtr<SQLTransactionErrorCallback> releaseErrorCallback();
70 73
74 // APIs called from the backend published:
75 void requestTransitToState(SQLTransactionState);
76 bool hasCallback() const;
77 bool hasSuccessCallback() const;
78 bool hasErrorCallback() const;
79 void setBackend(SQLTransactionBackend*);
80
71 private: 81 private:
72 SQLTransaction(Database*, PassOwnPtrWillBeRawPtr<SQLTransactionCallback>, 82 SQLTransaction(Database*, PassOwnPtrWillBeRawPtr<SQLTransactionCallback>,
73 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRa wPtr<SQLTransactionErrorCallback>, 83 PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRa wPtr<SQLTransactionErrorCallback>,
74 bool readOnly); 84 bool readOnly);
75 85
76 void clearCallbackWrappers(); 86 void clearCallbackWrappers();
77 87
78 // APIs called from the backend published via AbstractSQLTransaction:
79 virtual void requestTransitToState(SQLTransactionState) OVERRIDE;
80 virtual bool hasCallback() const OVERRIDE;
81 virtual bool hasSuccessCallback() const OVERRIDE;
82 virtual bool hasErrorCallback() const OVERRIDE;
83 virtual void setBackend(AbstractSQLTransactionBackend*) OVERRIDE;
84
85 // State Machine functions: 88 // State Machine functions:
86 virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE; 89 virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
87 bool computeNextStateAndCleanupIfNeeded(); 90 bool computeNextStateAndCleanupIfNeeded();
88 91
89 // State functions: 92 // State functions:
90 SQLTransactionState deliverTransactionCallback(); 93 SQLTransactionState deliverTransactionCallback();
91 SQLTransactionState deliverTransactionErrorCallback(); 94 SQLTransactionState deliverTransactionErrorCallback();
92 SQLTransactionState deliverStatementCallback(); 95 SQLTransactionState deliverStatementCallback();
93 SQLTransactionState deliverQuotaIncreaseCallback(); 96 SQLTransactionState deliverQuotaIncreaseCallback();
94 SQLTransactionState deliverSuccessCallback(); 97 SQLTransactionState deliverSuccessCallback();
95 98
96 SQLTransactionState unreachableState(); 99 SQLTransactionState unreachableState();
97 SQLTransactionState sendToBackendState(); 100 SQLTransactionState sendToBackendState();
98 101
99 SQLTransactionState nextStateForTransactionError(); 102 SQLTransactionState nextStateForTransactionError();
100 103
101 RefPtrWillBeMember<Database> m_database; 104 RefPtrWillBeMember<Database> m_database;
102 RefPtrWillBeMember<AbstractSQLTransactionBackend> m_backend; 105 RefPtrWillBeMember<SQLTransactionBackend> m_backend;
103 SQLCallbackWrapper<SQLTransactionCallback> m_callbackWrapper; 106 SQLCallbackWrapper<SQLTransactionCallback> m_callbackWrapper;
104 SQLCallbackWrapper<VoidCallback> m_successCallbackWrapper; 107 SQLCallbackWrapper<VoidCallback> m_successCallbackWrapper;
105 SQLCallbackWrapper<SQLTransactionErrorCallback> m_errorCallbackWrapper; 108 SQLCallbackWrapper<SQLTransactionErrorCallback> m_errorCallbackWrapper;
106 109
107 bool m_executeSqlAllowed; 110 bool m_executeSqlAllowed;
108 OwnPtr<SQLErrorData> m_transactionError; 111 OwnPtr<SQLErrorData> m_transactionError;
109 112
110 bool m_readOnly; 113 bool m_readOnly;
111 }; 114 };
112 115
113 } // namespace blink 116 } // namespace blink
114 117
115 #endif // SQLTransaction_h 118 #endif // SQLTransaction_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698