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

Unified Diff: chrome/browser/webdata/web_database_win.cc

Issue 201099: Convert the sqlite cookie database and web database to use the new sqlite... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/webdata/web_database_unittest.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_database_win.cc
===================================================================
--- chrome/browser/webdata/web_database_win.cc (revision 26110)
+++ chrome/browser/webdata/web_database_win.cc (working copy)
@@ -1,29 +1,30 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/webdata/web_database.h"
+#include "app/sql/statement.h"
#include "base/logging.h"
+#include "base/string_util.h"
#include "base/time.h"
#include "chrome/browser/password_manager/ie7_password.h"
-#include "chrome/common/sqlite_utils.h"
bool WebDatabase::AddIE7Login(const IE7PasswordInfo& info) {
- SQLStatement s;
- if (s.prepare(db_,
- "INSERT OR REPLACE INTO ie7_logins "
- "(url_hash, password_value, date_created) "
- "VALUES (?, ?, ?)") != SQLITE_OK) {
- NOTREACHED() << "Statement prepare failed";
+ sql::Statement s(db_.GetUniqueStatement(
+ "INSERT OR REPLACE INTO ie7_logins "
+ "(url_hash, password_value, date_created) "
+ "VALUES (?,?,?)"));
+ if (!s) {
+ NOTREACHED() << db_.GetErrorMessage();
return false;
}
- s.bind_wstring(0, info.url_hash);
- s.bind_blob(1, &info.encrypted_data.front(),
- static_cast<int>(info.encrypted_data.size()));
- s.bind_int64(2, info.date_created.ToTimeT());
- if (s.step() != SQLITE_DONE) {
+ s.BindString(0, WideToUTF8(info.url_hash));
+ s.BindBlob(1, &info.encrypted_data.front(),
+ static_cast<int>(info.encrypted_data.size()));
+ s.BindInt64(2, info.date_created.ToTimeT());
+ if (!s.Run()) {
NOTREACHED();
return false;
}
@@ -31,17 +32,16 @@
}
bool WebDatabase::RemoveIE7Login(const IE7PasswordInfo& info) {
- SQLStatement s;
// Remove a login by UNIQUE-constrained fields.
- if (s.prepare(db_,
- "DELETE FROM ie7_logins WHERE "
- "url_hash = ?") != SQLITE_OK) {
- NOTREACHED() << "Statement prepare failed";
+ sql::Statement s(db_.GetUniqueStatement(
+ "DELETE FROM ie7_logins WHERE url_hash = ?"));
+ if (!s) {
+ NOTREACHED() << db_.GetErrorMessage();
return false;
}
- s.bind_wstring(0, info.url_hash);
+ s.BindString(0, WideToUTF8(info.url_hash));
- if (s.step() != SQLITE_DONE) {
+ if (!s.Run()) {
NOTREACHED();
return false;
}
@@ -51,22 +51,19 @@
bool WebDatabase::GetIE7Login(const IE7PasswordInfo& info,
IE7PasswordInfo* result) {
DCHECK(result);
- SQLStatement s;
- if (s.prepare(db_,
- "SELECT password_value, date_created FROM ie7_logins "
- "WHERE url_hash == ? ") != SQLITE_OK) {
- NOTREACHED() << "Statement prepare failed";
+ sql::Statement s(db_.GetUniqueStatement(
+ "SELECT password_value, date_created FROM ie7_logins "
+ "WHERE url_hash == ? "));
+ if (!s) {
+ NOTREACHED() << db_.GetErrorMessage();
return false;
}
- s.bind_wstring(0, info.url_hash);
-
- int64 query_result = s.step();
- if (query_result == SQLITE_ROW) {
- s.column_blob_as_vector(0, &result->encrypted_data);
- result->date_created = base::Time::FromTimeT(s.column_int64(1));
+ s.BindString(0, WideToUTF8(info.url_hash));
+ if (s.Step()) {
+ s.ColumnBlobAsVector(0, &result->encrypted_data);
+ result->date_created = base::Time::FromTimeT(s.ColumnInt64(1));
result->url_hash = info.url_hash;
- s.step();
}
- return query_result == SQLITE_DONE;
+ return s.Succeeded();
}
« no previous file with comments | « chrome/browser/webdata/web_database_unittest.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698