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 13 matching lines...) Expand all Loading... |
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 #include "config.h" | 28 #include "config.h" |
29 #include "modules/webdatabase/SQLStatementBackend.h" | 29 #include "modules/webdatabase/SQLStatementBackend.h" |
30 | 30 |
31 #include "platform/Logging.h" | 31 #include "platform/Logging.h" |
32 #include "modules/webdatabase/sqlite/SQLiteDatabase.h" | 32 #include "modules/webdatabase/sqlite/SQLiteDatabase.h" |
33 #include "modules/webdatabase/sqlite/SQLiteStatement.h" | 33 #include "modules/webdatabase/sqlite/SQLiteStatement.h" |
34 #include "modules/webdatabase/AbstractSQLStatement.h" | |
35 #include "modules/webdatabase/DatabaseBackend.h" | 34 #include "modules/webdatabase/DatabaseBackend.h" |
36 #include "modules/webdatabase/SQLError.h" | 35 #include "modules/webdatabase/SQLError.h" |
| 36 #include "modules/webdatabase/SQLStatement.h" |
37 #include "wtf/text/CString.h" | 37 #include "wtf/text/CString.h" |
38 | 38 |
39 | 39 |
40 // The Life-Cycle of a SQLStatement i.e. Who's keeping the SQLStatement alive? | 40 // The Life-Cycle of a SQLStatement i.e. Who's keeping the SQLStatement alive? |
41 // ========================================================================== | 41 // ========================================================================== |
42 // The RefPtr chain goes something like this: | 42 // The RefPtr chain goes something like this: |
43 // | 43 // |
44 // At birth (in SQLTransactionBackend::executeSQL()): | 44 // At birth (in SQLTransactionBackend::executeSQL()): |
45 // ================================================= | 45 // ================================================= |
46 // SQLTransactionBackend // Deque<RefPtr<SQLStatementBackend> > m_
statementQueue points to ... | 46 // SQLTransactionBackend // Deque<RefPtr<SQLStatementBackend> > m_
statementQueue points to ... |
(...skipping 17 matching lines...) Expand all Loading... |
64 // =========================================================================
============== | 64 // =========================================================================
============== |
65 // When we're done executing, we'll grab the next statement. But before we | 65 // When we're done executing, we'll grab the next statement. But before we |
66 // do that, getNextStatement() nullify SQLTransactionBackend::m_currentState
mentBackend. | 66 // do that, getNextStatement() nullify SQLTransactionBackend::m_currentState
mentBackend. |
67 // This will trigger the deletion of the SQLStatementBackend and SQLStatemen
t. | 67 // This will trigger the deletion of the SQLStatementBackend and SQLStatemen
t. |
68 // | 68 // |
69 // Note: unlike with SQLTransaction, there is no JS representation of SQLSta
tement. | 69 // Note: unlike with SQLTransaction, there is no JS representation of SQLSta
tement. |
70 // Hence, there is no GC dependency at play here. | 70 // Hence, there is no GC dependency at play here. |
71 | 71 |
72 namespace blink { | 72 namespace blink { |
73 | 73 |
74 PassRefPtrWillBeRawPtr<SQLStatementBackend> SQLStatementBackend::create(PassOwnP
trWillBeRawPtr<AbstractSQLStatement> frontend, | 74 PassRefPtrWillBeRawPtr<SQLStatementBackend> SQLStatementBackend::create(PassOwnP
trWillBeRawPtr<SQLStatement> frontend, |
75 const String& statement, const Vector<SQLValue>& arguments, int permissions) | 75 const String& statement, const Vector<SQLValue>& arguments, int permissions) |
76 { | 76 { |
77 return adoptRefWillBeNoop(new SQLStatementBackend(frontend, statement, argum
ents, permissions)); | 77 return adoptRefWillBeNoop(new SQLStatementBackend(frontend, statement, argum
ents, permissions)); |
78 } | 78 } |
79 | 79 |
80 SQLStatementBackend::SQLStatementBackend(PassOwnPtrWillBeRawPtr<AbstractSQLState
ment> frontend, | 80 SQLStatementBackend::SQLStatementBackend(PassOwnPtrWillBeRawPtr<SQLStatement> fr
ontend, |
81 const String& statement, const Vector<SQLValue>& arguments, int permissions) | 81 const String& statement, const Vector<SQLValue>& arguments, int permissions) |
82 : m_frontend(frontend) | 82 : m_frontend(frontend) |
83 , m_statement(statement.isolatedCopy()) | 83 , m_statement(statement.isolatedCopy()) |
84 , m_arguments(arguments) | 84 , m_arguments(arguments) |
85 , m_hasCallback(m_frontend->hasCallback()) | 85 , m_hasCallback(m_frontend->hasCallback()) |
86 , m_hasErrorCallback(m_frontend->hasErrorCallback()) | 86 , m_hasErrorCallback(m_frontend->hasErrorCallback()) |
87 , m_resultSet(SQLResultSet::create()) | 87 , m_resultSet(SQLResultSet::create()) |
88 , m_permissions(permissions) | 88 , m_permissions(permissions) |
89 { | 89 { |
90 m_frontend->setBackend(this); | 90 m_frontend->setBackend(this); |
91 } | 91 } |
92 | 92 |
93 void SQLStatementBackend::trace(Visitor* visitor) | 93 void SQLStatementBackend::trace(Visitor* visitor) |
94 { | 94 { |
95 visitor->trace(m_frontend); | 95 visitor->trace(m_frontend); |
96 visitor->trace(m_resultSet); | 96 visitor->trace(m_resultSet); |
97 AbstractSQLStatementBackend::trace(visitor); | |
98 } | 97 } |
99 | 98 |
100 AbstractSQLStatement* SQLStatementBackend::frontend() | 99 SQLStatement* SQLStatementBackend::frontend() |
101 { | 100 { |
102 return m_frontend.get(); | 101 return m_frontend.get(); |
103 } | 102 } |
104 | 103 |
105 SQLErrorData* SQLStatementBackend::sqlError() const | 104 SQLErrorData* SQLStatementBackend::sqlError() const |
106 { | 105 { |
107 return m_error.get(); | 106 return m_error.get(); |
108 } | 107 } |
109 | 108 |
110 SQLResultSet* SQLStatementBackend::sqlResultSet() const | 109 SQLResultSet* SQLStatementBackend::sqlResultSet() const |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (lastExecutionFailedDueToQuota()) | 231 if (lastExecutionFailedDueToQuota()) |
233 m_error = nullptr; | 232 m_error = nullptr; |
234 } | 233 } |
235 | 234 |
236 bool SQLStatementBackend::lastExecutionFailedDueToQuota() const | 235 bool SQLStatementBackend::lastExecutionFailedDueToQuota() const |
237 { | 236 { |
238 return m_error && m_error->code() == SQLError::QUOTA_ERR; | 237 return m_error && m_error->code() == SQLError::QUOTA_ERR; |
239 } | 238 } |
240 | 239 |
241 } // namespace blink | 240 } // namespace blink |
OLD | NEW |