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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/SQLStatementBackend.cpp

Issue 2229213002: Web SQL: Replace WTF_LOG() with STORAGE_DVLOG() or SQL_DVLOG(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using LAZY_STREAM Created 4 years, 4 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
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 13 matching lines...) Expand all
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 #include "modules/webdatabase/SQLStatementBackend.h" 29 #include "modules/webdatabase/SQLStatementBackend.h"
30 30
31 #include "modules/webdatabase/Database.h" 31 #include "modules/webdatabase/Database.h"
32 #include "modules/webdatabase/SQLError.h" 32 #include "modules/webdatabase/SQLError.h"
33 #include "modules/webdatabase/SQLStatement.h" 33 #include "modules/webdatabase/SQLStatement.h"
34 #include "modules/webdatabase/StorageLog.h"
34 #include "modules/webdatabase/sqlite/SQLiteDatabase.h" 35 #include "modules/webdatabase/sqlite/SQLiteDatabase.h"
35 #include "modules/webdatabase/sqlite/SQLiteStatement.h" 36 #include "modules/webdatabase/sqlite/SQLiteStatement.h"
36 #include "platform/Logging.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 // HeapDeque<Member<SQLStatementBackend>> m_statementQueue points to ... 46 // SQLTransactionBackend // HeapDeque<Member<SQLStatementBackend>> m_statementQueue points to ...
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return false; 126 return false;
127 127
128 db->setAuthorizerPermissions(m_permissions); 128 db->setAuthorizerPermissions(m_permissions);
129 129
130 SQLiteDatabase* database = &db->sqliteDatabase(); 130 SQLiteDatabase* database = &db->sqliteDatabase();
131 131
132 SQLiteStatement statement(*database, m_statement); 132 SQLiteStatement statement(*database, m_statement);
133 int result = statement.prepare(); 133 int result = statement.prepare();
134 134
135 if (result != SQLResultOk) { 135 if (result != SQLResultOk) {
136 WTF_LOG(StorageAPI, "Unable to verify correctness of statement %s - erro r %i (%s)", m_statement.ascii().data(), result, database->lastErrorMsg()); 136 STORAGE_DVLOG(1) << "Unable to verify correctness of statement " << m_st atement << " - error " << result << " (" << database->lastErrorMsg() << ")";
137 if (result == SQLResultInterrupt) 137 if (result == SQLResultInterrupt)
138 m_error = SQLErrorData::create(SQLError::kDatabaseErr, "could not pr epare statement", result, "interrupted"); 138 m_error = SQLErrorData::create(SQLError::kDatabaseErr, "could not pr epare statement", result, "interrupted");
139 else 139 else
140 m_error = SQLErrorData::create(SQLError::kSyntaxErr, "could not prep are statement", result, database->lastErrorMsg()); 140 m_error = SQLErrorData::create(SQLError::kSyntaxErr, "could not prep are statement", result, database->lastErrorMsg());
141 db->reportExecuteStatementResult(1, m_error->code(), result); 141 db->reportExecuteStatementResult(1, m_error->code(), result);
142 return false; 142 return false;
143 } 143 }
144 144
145 // FIXME: If the statement uses the ?### syntax supported by sqlite, the bin d parameter count is very likely off from the number of question marks. 145 // FIXME: If the statement uses the ?### syntax supported by sqlite, the bin d parameter count is very likely off from the number of question marks.
146 // If this is the case, they might be trying to do something fishy or malici ous 146 // If this is the case, they might be trying to do something fishy or malici ous
147 if (statement.bindParameterCount() != m_arguments.size()) { 147 if (statement.bindParameterCount() != m_arguments.size()) {
148 WTF_LOG(StorageAPI, "Bind parameter count doesn't match number of questi on marks"); 148 STORAGE_DVLOG(1) << "Bind parameter count doesn't match number of questi on marks";
149 m_error = SQLErrorData::create(SQLError::kSyntaxErr, "number of '?'s in statement string does not match argument count"); 149 m_error = SQLErrorData::create(SQLError::kSyntaxErr, "number of '?'s in statement string does not match argument count");
150 db->reportExecuteStatementResult(2, m_error->code(), 0); 150 db->reportExecuteStatementResult(2, m_error->code(), 0);
151 return false; 151 return false;
152 } 152 }
153 153
154 for (unsigned i = 0; i < m_arguments.size(); ++i) { 154 for (unsigned i = 0; i < m_arguments.size(); ++i) {
155 result = statement.bindValue(i + 1, m_arguments[i]); 155 result = statement.bindValue(i + 1, m_arguments[i]);
156 if (result == SQLResultFull) { 156 if (result == SQLResultFull) {
157 setFailureDueToQuota(db); 157 setFailureDueToQuota(db);
158 return false; 158 return false;
159 } 159 }
160 160
161 if (result != SQLResultOk) { 161 if (result != SQLResultOk) {
162 WTF_LOG(StorageAPI, "Failed to bind value index %i to statement for query '%s'", i + 1, m_statement.ascii().data()); 162 STORAGE_DVLOG(1) << "Failed to bind value index " << (i + 1) << " to statement for query " << m_statement;
163 db->reportExecuteStatementResult(3, SQLError::kDatabaseErr, result); 163 db->reportExecuteStatementResult(3, SQLError::kDatabaseErr, result);
164 m_error = SQLErrorData::create(SQLError::kDatabaseErr, "could not bi nd value", result, database->lastErrorMsg()); 164 m_error = SQLErrorData::create(SQLError::kDatabaseErr, "could not bi nd value", result, database->lastErrorMsg());
165 return false; 165 return false;
166 } 166 }
167 } 167 }
168 168
169 // Step so we can fetch the column names. 169 // Step so we can fetch the column names.
170 result = statement.step(); 170 result = statement.step();
171 if (result == SQLResultRow) { 171 if (result == SQLResultRow) {
172 int columnCount = statement.columnCount(); 172 int columnCount = statement.columnCount();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (lastExecutionFailedDueToQuota()) 233 if (lastExecutionFailedDueToQuota())
234 m_error = nullptr; 234 m_error = nullptr;
235 } 235 }
236 236
237 bool SQLStatementBackend::lastExecutionFailedDueToQuota() const 237 bool SQLStatementBackend::lastExecutionFailedDueToQuota() const
238 { 238 {
239 return m_error && m_error->code() == SQLError::kQuotaErr; 239 return m_error && m_error->code() == SQLError::kQuotaErr;
240 } 240 }
241 241
242 } // namespace blink 242 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698