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

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

Issue 2688383003: Remove unnecessary SafePointScope (Closed)
Patch Set: temp Created 3 years, 10 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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 CString query = m_query.stripWhiteSpace().utf8(); 95 CString query = m_query.stripWhiteSpace().utf8();
96 96
97 // Need to pass non-stack |const char*| and |sqlite3_stmt*| to avoid race 97 // Need to pass non-stack |const char*| and |sqlite3_stmt*| to avoid race
98 // with Oilpan stack scanning. 98 // with Oilpan stack scanning.
99 std::unique_ptr<const char*> tail = WTF::wrapUnique(new const char*); 99 std::unique_ptr<const char*> tail = WTF::wrapUnique(new const char*);
100 std::unique_ptr<sqlite3_stmt*> statement = WTF::wrapUnique(new sqlite3_stmt*); 100 std::unique_ptr<sqlite3_stmt*> statement = WTF::wrapUnique(new sqlite3_stmt*);
101 *tail = nullptr; 101 *tail = nullptr;
102 *statement = nullptr; 102 *statement = nullptr;
103 int error; 103 int error;
104 { 104 {
105 SafePointScope scope(BlinkGC::HeapPointersOnStack);
106
107 SQL_DVLOG(1) << "SQL - prepare - " << query.data(); 105 SQL_DVLOG(1) << "SQL - prepare - " << query.data();
108 106
109 // Pass the length of the string including the null character to 107 // Pass the length of the string including the null character to
110 // sqlite3_prepare_v2; this lets SQLite avoid an extra string copy. 108 // sqlite3_prepare_v2; this lets SQLite avoid an extra string copy.
111 size_t lengthIncludingNullCharacter = query.length() + 1; 109 size_t lengthIncludingNullCharacter = query.length() + 1;
112 110
113 error = sqlite3_prepare_v2(m_database.sqlite3Handle(), query.data(), 111 error = sqlite3_prepare_v2(m_database.sqlite3Handle(), query.data(),
114 lengthIncludingNullCharacter, statement.get(), 112 lengthIncludingNullCharacter, statement.get(),
115 tail.get()); 113 tail.get());
116 } 114 }
117 m_statement = *statement; 115 m_statement = *statement;
118 116
119 if (error != SQLITE_OK) 117 if (error != SQLITE_OK)
120 SQL_DVLOG(1) << "sqlite3_prepare16 failed (" << error << ")\n" 118 SQL_DVLOG(1) << "sqlite3_prepare16 failed (" << error << ")\n"
121 << query.data() << "\n" 119 << query.data() << "\n"
122 << sqlite3_errmsg(m_database.sqlite3Handle()); 120 << sqlite3_errmsg(m_database.sqlite3Handle());
123 else if (*tail && **tail) 121 else if (*tail && **tail)
124 error = SQLITE_ERROR; 122 error = SQLITE_ERROR;
125 123
126 #if DCHECK_IS_ON() 124 #if DCHECK_IS_ON()
127 m_isPrepared = error == SQLITE_OK; 125 m_isPrepared = error == SQLITE_OK;
128 #endif 126 #endif
129 return restrictError(error); 127 return restrictError(error);
130 } 128 }
131 129
132 int SQLiteStatement::step() { 130 int SQLiteStatement::step() {
133 SafePointScope scope(BlinkGC::HeapPointersOnStack);
134 // ASSERT(m_isPrepared);
135
136 if (!m_statement) 131 if (!m_statement)
137 return SQLITE_OK; 132 return SQLITE_OK;
138 133
139 // The database needs to update its last changes count before each statement 134 // The database needs to update its last changes count before each statement
140 // in order to compute properly the lastChanges() return value. 135 // in order to compute properly the lastChanges() return value.
141 m_database.updateLastChangesCount(); 136 m_database.updateLastChangesCount();
142 137
143 SQL_DVLOG(1) << "SQL - step - " << m_query; 138 SQL_DVLOG(1) << "SQL - step - " << m_query;
144 int error = sqlite3_step(m_statement); 139 int error = sqlite3_step(m_statement);
145 if (error != SQLITE_DONE && error != SQLITE_ROW) { 140 if (error != SQLITE_DONE && error != SQLITE_ROW) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ASSERT(col >= 0); 297 ASSERT(col >= 0);
303 if (!m_statement) 298 if (!m_statement)
304 if (prepareAndStep() != SQLITE_ROW) 299 if (prepareAndStep() != SQLITE_ROW)
305 return 0; 300 return 0;
306 if (columnCount() <= col) 301 if (columnCount() <= col)
307 return 0; 302 return 0;
308 return sqlite3_column_int64(m_statement, col); 303 return sqlite3_column_int64(m_statement, col);
309 } 304 }
310 305
311 } // namespace blink 306 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698