diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 00:14:44 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-30 00:14:44 +0000 |
commit | c91a523e35cbbf233f82ae17a340b92459da5103 (patch) | |
tree | b2250e24027c075b4939f0735e11d435a528ca93 /chrome/browser/history/archived_database.cc | |
parent | 6e9c8ffa0f3e084c2cdeac1bd4e0f506e04b5036 (diff) | |
download | chromium_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/browser/history/archived_database.cc')
-rw-r--r-- | chrome/browser/history/archived_database.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/chrome/browser/history/archived_database.cc b/chrome/browser/history/archived_database.cc index 68821f6..468376c 100644 --- a/chrome/browser/history/archived_database.cc +++ b/chrome/browser/history/archived_database.cc @@ -10,6 +10,7 @@ namespace history { namespace { static const int kCurrentVersionNumber = 2; +static const int kCompatibleVersionNumber = 2; } // namespace @@ -48,7 +49,8 @@ bool ArchivedDatabase::Init(const std::wstring& file_name) { BeginTransaction(); // Version check. - if (!meta_table_.Init(std::string(), kCurrentVersionNumber, db_)) + if (!meta_table_.Init(std::string(), kCurrentVersionNumber, + kCompatibleVersionNumber, db_)) return false; // Create the tables. @@ -98,8 +100,10 @@ SqliteStatementCache& ArchivedDatabase::GetStatementCache() { InitStatus ArchivedDatabase::EnsureCurrentVersion() { // We can't read databases newer than we were designed for. - if (meta_table_.GetCompatibleVersionNumber() > kCurrentVersionNumber) + if (meta_table_.GetCompatibleVersionNumber() > kCurrentVersionNumber) { + LOG(WARNING) << "Archived database is too new."; return INIT_TOO_NEW; + } // NOTICE: If you are changing structures for things shared with the archived // history file like URLs, visits, or downloads, that will need migration as @@ -107,20 +111,22 @@ InitStatus ArchivedDatabase::EnsureCurrentVersion() { // in the corresponding file (url_database.cc, etc.) and called from here and // from the archived_database.cc. - // 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. int cur_version = meta_table_.GetVersionNumber(); - - // Put migration code here - if (cur_version == 1) { - if (!DropStarredIDFromURLs()) + if (!DropStarredIDFromURLs()) { + LOG(WARNING) << "Unable to update archived database to version 2."; return INIT_FAILURE; - cur_version = 2; + } + ++cur_version; meta_table_.SetVersionNumber(cur_version); - meta_table_.SetCompatibleVersionNumber(cur_version); + meta_table_.SetCompatibleVersionNumber( + std::min(cur_version, kCompatibleVersionNumber)); } + // 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) << "Archived database version " << cur_version << " is too old to handle."; |