From 1ed78a31b405c4b85a3747d697e464508e7c4399 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Tue, 15 Sep 2009 20:24:17 +0000 Subject: Convert the sqlite cookie database and web database to use the new sqlite wrapper. This also moves and renamed the old cookie_monster_sqlite file to match the class name. BUG=none TEST=none Review URL: http://codereview.chromium.org/201099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26260 0039d316-1c4b-4281-b951-d872f2087c98 --- app/sql/connection.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'app/sql/connection.cc') diff --git a/app/sql/connection.cc b/app/sql/connection.cc index 4878e1b..53ab07d 100644 --- a/app/sql/connection.cc +++ b/app/sql/connection.cc @@ -224,8 +224,10 @@ scoped_refptr Connection::GetUniqueStatement( return new StatementRef(this, stmt); } -bool Connection::DoesTableExist(const char* table_name) { - Statement statement(GetUniqueStatement( +bool Connection::DoesTableExist(const char* table_name) const { + // GetUniqueStatement can't be const since statements may modify the + // database, but we know ours doesn't modify it, so the cast is safe. + Statement statement(const_cast(this)->GetUniqueStatement( "SELECT name FROM sqlite_master " "WHERE type='table' AND name=?")); if (!statement) @@ -235,12 +237,14 @@ bool Connection::DoesTableExist(const char* table_name) { } bool Connection::DoesColumnExist(const char* table_name, - const char* column_name) { + const char* column_name) const { std::string sql("PRAGMA TABLE_INFO("); sql.append(table_name); sql.append(")"); - Statement statement(GetUniqueStatement(sql.c_str())); + // Our SQL is non-mutating, so this cast is OK. + Statement statement(const_cast(this)->GetUniqueStatement( + sql.c_str())); if (!statement) return false; @@ -259,6 +263,14 @@ int64 Connection::GetLastInsertRowId() const { return sqlite3_last_insert_rowid(db_); } +int Connection::GetLastChangeCount() const { + if (!db_) { + NOTREACHED(); + return 0; + } + return sqlite3_changes(db_); +} + int Connection::GetErrorCode() const { if (!db_) return SQLITE_ERROR; -- cgit v1.1