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

Side by Side Diff: chrome/common/sqlite_utils.cc

Issue 19610: Safe browsing cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/sqlite_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/sqlite_utils.h" 5 #include "chrome/common/sqlite_utils.h"
6 6
7 #include "base/file_path.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 9
10 int OpenSqliteDb(const FilePath& filepath, sqlite3** database) {
11 #if defined(OS_WIN)
12 return sqlite3_open16(filepath.value().c_str(), database);
13 #elif defined(OS_POSIX)
14 return sqlite3_open(filepath.value().c_str(), database);
15 #endif
16 }
17
9 bool DoesSqliteTableExist(sqlite3* db, 18 bool DoesSqliteTableExist(sqlite3* db,
10 const char* db_name, 19 const char* db_name,
11 const char* table_name) { 20 const char* table_name) {
12 // sqlite doesn't allow binding parameters as table names, so we have to 21 // sqlite doesn't allow binding parameters as table names, so we have to
13 // manually construct the sql 22 // manually construct the sql
14 std::string sql("SELECT name FROM "); 23 std::string sql("SELECT name FROM ");
15 if (db_name && db_name[0]) { 24 if (db_name && db_name[0]) {
16 sql.append(db_name); 25 sql.append(db_name);
17 sql.push_back('.'); 26 sql.push_back('.');
18 } 27 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 std::string b; 73 std::string b;
65 b.append("SELECT * FROM "); 74 b.append("SELECT * FROM ");
66 b.append(table_name); 75 b.append(table_name);
67 76
68 if (s.prepare(db, b.c_str()) != SQLITE_OK) 77 if (s.prepare(db, b.c_str()) != SQLITE_OK)
69 return false; 78 return false;
70 79
71 return s.step() == SQLITE_ROW; 80 return s.step() == SQLITE_ROW;
72 } 81 }
73 82
74
75 SQLTransaction::SQLTransaction(sqlite3* db) : db_(db), began_(false) { 83 SQLTransaction::SQLTransaction(sqlite3* db) : db_(db), began_(false) {
76 } 84 }
77 85
78 SQLTransaction::~SQLTransaction() { 86 SQLTransaction::~SQLTransaction() {
79 if (began_) { 87 if (began_) {
80 Rollback(); 88 Rollback();
81 } 89 }
82 } 90 }
83 91
84 int SQLTransaction::BeginCommand(const char* command) { 92 int SQLTransaction::BeginCommand(const char* command) {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 str->assign(s ? s : std::wstring(L"")); 408 str->assign(s ? s : std::wstring(L""));
401 return (s != NULL); 409 return (s != NULL);
402 } 410 }
403 411
404 std::wstring SQLStatement::column_string16(int index) { 412 std::wstring SQLStatement::column_string16(int index) {
405 std::wstring wstr; 413 std::wstring wstr;
406 column_string16(index, &wstr); 414 column_string16(index, &wstr);
407 return wstr; 415 return wstr;
408 } 416 }
409 417
OLDNEW
« no previous file with comments | « chrome/common/sqlite_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698