summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-30 00:14:44 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-30 00:14:44 +0000
commitc91a523e35cbbf233f82ae17a340b92459da5103 (patch)
treeb2250e24027c075b4939f0735e11d435a528ca93 /chrome/common
parent6e9c8ffa0f3e084c2cdeac1bd4e0f506e04b5036 (diff)
downloadchromium_src-c91a523e35cbbf233f82ae17a340b92459da5103.zip
chromium_src-c91a523e35cbbf233f82ae17a340b92459da5103.tar.gz
chromium_src-c91a523e35cbbf233f82ae17a340b92459da5103.tar.bz2
Add compatible version support since it was only halfway in place, and try and make our database versioning code and logging more similar across various consumers.
The compatible version support isn't really used yet. It was going to be used for my cookie change until we decided that the old code was too busted to be forward-compatible. It seems worthwhile to put this in but maybe I am wrong. The logging similarity stuff is fairly useful. In a couple consumers in the old code, we DLOGed instead of LOGing, which meant that most people would get nothing in the log at all. I think it's a little weird that in a lot of these consumers, logging is all we do; for example, if you use a too-new cookie DB, you get output in the log, but no actual dialog box while the browser is running -- your cookies just silently don't get saved to disk. Seems bad, but I'm not prepared to try and do major surgery to address that (and add translated strings, etc.). At least now we'll actually get log messages in release builds instead of nothing at all. Because my last-access change touches this code, I'm considering asking that this change be merged back to the branch. Review URL: http://codereview.chromium.org/8712 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/net/cookie_monster_sqlite.cc19
-rw-r--r--chrome/common/net/cookie_monster_sqlite.h1
2 files changed, 15 insertions, 5 deletions
diff --git a/chrome/common/net/cookie_monster_sqlite.cc b/chrome/common/net/cookie_monster_sqlite.cc
index 8b9c430..e4e4a79 100644
--- a/chrome/common/net/cookie_monster_sqlite.cc
+++ b/chrome/common/net/cookie_monster_sqlite.cc
@@ -156,6 +156,7 @@ void SQLitePersistentCookieStore::Backend::Commit() {
NOTREACHED();
return;
}
+
SQLITE_UNIQUE_STATEMENT(del_smt, *cache_,
"DELETE FROM cookies WHERE creation_utc=?");
if (!del_smt.is_valid()) {
@@ -241,6 +242,7 @@ SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
// Version number of the database.
static const int kCurrentVersionNumber = 2;
+static const int kCompatibleVersionNumber = 2;
namespace {
@@ -338,15 +340,24 @@ bool SQLitePersistentCookieStore::Load(
bool SQLitePersistentCookieStore::EnsureDatabaseVersion(sqlite3* db) {
// Version check.
- if (!meta_table_.Init(std::string(), kCurrentVersionNumber, db))
+ if (!meta_table_.Init(std::string(), kCurrentVersionNumber,
+ kCompatibleVersionNumber, db))
return false;
- int compat_version = meta_table_.GetCompatibleVersionNumber();
- if (compat_version > kCurrentVersionNumber) {
- DLOG(WARNING) << "Cookie DB version from the future: " << compat_version;
+ if (meta_table_.GetCompatibleVersionNumber() > kCurrentVersionNumber) {
+ LOG(WARNING) << "Cookie database is too new.";
return false;
}
+ int cur_version = meta_table_.GetVersionNumber();
+
+ // Put future migration cases here.
+
+ // When the version is too old, we just try to continue anyway, there should
+ // not be a released product that makes a database too old for us to handle.
+ LOG_IF(WARNING, cur_version < kCurrentVersionNumber) <<
+ "Cookie database version " << cur_version << " is too old to handle.";
+
return true;
}
diff --git a/chrome/common/net/cookie_monster_sqlite.h b/chrome/common/net/cookie_monster_sqlite.h
index a67197a..7607915 100644
--- a/chrome/common/net/cookie_monster_sqlite.h
+++ b/chrome/common/net/cookie_monster_sqlite.h
@@ -35,7 +35,6 @@ class SQLitePersistentCookieStore
// Database upgrade statements.
bool EnsureDatabaseVersion(sqlite3* db);
- bool UpdateSchemaToVersion2(sqlite3* db);
std::wstring path_;
scoped_refptr<Backend> backend_;