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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "modules/webdatabase/sqlite/SQLiteStatement.h" 26 #include "modules/webdatabase/sqlite/SQLiteStatement.h"
27 27
28 #include "modules/webdatabase/sqlite/SQLValue.h" 28 #include "modules/webdatabase/sqlite/SQLValue.h"
29 #include "platform/Logging.h" 29 #include "platform/Logging.h"
30 #include "platform/heap/SafePoint.h" 30 #include "platform/heap/SafePoint.h"
31 #include "third_party/sqlite/sqlite3.h" 31 #include "third_party/sqlite/sqlite3.h"
32 #include "wtf/Assertions.h" 32 #include "wtf/Assertions.h"
33 #include "wtf/PtrUtil.h"
34 #include "wtf/text/CString.h" 33 #include "wtf/text/CString.h"
35 #include <memory>
36 34
37 // SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the stat ement 35 // SQLite 3.6.16 makes sqlite3_prepare_v2 automatically retry preparing the stat ement
38 // once if the database scheme has changed. We rely on this behavior. 36 // once if the database scheme has changed. We rely on this behavior.
39 #if SQLITE_VERSION_NUMBER < 3006016 37 #if SQLITE_VERSION_NUMBER < 3006016
40 #error SQLite version 3.6.16 or newer is required 38 #error SQLite version 3.6.16 or newer is required
41 #endif 39 #endif
42 40
43 namespace { 41 namespace {
44 42
45 // Only return error codes consistent with 3.7.6.3. 43 // Only return error codes consistent with 3.7.6.3.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 93 }
96 94
97 int SQLiteStatement::prepare() 95 int SQLiteStatement::prepare()
98 { 96 {
99 ASSERT(!m_isPrepared); 97 ASSERT(!m_isPrepared);
100 98
101 CString query = m_query.stripWhiteSpace().utf8(); 99 CString query = m_query.stripWhiteSpace().utf8();
102 100
103 // Need to pass non-stack |const char*| and |sqlite3_stmt*| to avoid race 101 // Need to pass non-stack |const char*| and |sqlite3_stmt*| to avoid race
104 // with Oilpan stack scanning. 102 // with Oilpan stack scanning.
105 std::unique_ptr<const char*> tail = wrapUnique(new const char*); 103 OwnPtr<const char*> tail = adoptPtr(new const char*);
106 std::unique_ptr<sqlite3_stmt*> statement = wrapUnique(new sqlite3_stmt*); 104 OwnPtr<sqlite3_stmt*> statement = adoptPtr(new sqlite3_stmt*);
107 *tail = nullptr; 105 *tail = nullptr;
108 *statement = nullptr; 106 *statement = nullptr;
109 int error; 107 int error;
110 { 108 {
111 SafePointScope scope(BlinkGC::HeapPointersOnStack); 109 SafePointScope scope(BlinkGC::HeapPointersOnStack);
112 110
113 WTF_LOG(SQLDatabase, "SQL - prepare - %s", query.data()); 111 WTF_LOG(SQLDatabase, "SQL - prepare - %s", query.data());
114 112
115 // Pass the length of the string including the null character to sqlite3 _prepare_v2; 113 // Pass the length of the string including the null character to sqlite3 _prepare_v2;
116 // this lets SQLite avoid an extra string copy. 114 // this lets SQLite avoid an extra string copy.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 ASSERT(col >= 0); 307 ASSERT(col >= 0);
310 if (!m_statement) 308 if (!m_statement)
311 if (prepareAndStep() != SQLITE_ROW) 309 if (prepareAndStep() != SQLITE_ROW)
312 return 0; 310 return 0;
313 if (columnCount() <= col) 311 if (columnCount() <= col)
314 return 0; 312 return 0;
315 return sqlite3_column_int64(m_statement, col); 313 return sqlite3_column_int64(m_statement, col);
316 } 314 }
317 315
318 } // namespace blink 316 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698