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

Side by Side Diff: chrome/browser/webdata/web_database.cc

Issue 10696127: Force WebDatabase version to max(version, compatible version) before migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix Created 8 years, 5 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 | « no previous file | chrome/browser/webdata/web_database_migration_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/webdata/web_database.h" 5 #include "chrome/browser/webdata/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
10 #include "chrome/browser/webdata/autofill_table.h" 10 #include "chrome/browser/webdata/autofill_table.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // If the migration fails we return an error to caller and do not commit 151 // If the migration fails we return an error to caller and do not commit
152 // the migration. 152 // the migration.
153 sql::InitStatus migration_status = MigrateOldVersionsAsNeeded(); 153 sql::InitStatus migration_status = MigrateOldVersionsAsNeeded();
154 if (migration_status != sql::INIT_OK) 154 if (migration_status != sql::INIT_OK)
155 return migration_status; 155 return migration_status;
156 156
157 return transaction.Commit() ? sql::INIT_OK : sql::INIT_FAILURE; 157 return transaction.Commit() ? sql::INIT_OK : sql::INIT_FAILURE;
158 } 158 }
159 159
160 sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() { 160 sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() {
161 // Some malware tries to force protector to re-sign things by lowering the
162 // version number, causing migration to fail. Ensure the version number is at
163 // least as high as the compatible version number.
164 int current_version = std::max(meta_table_.GetVersionNumber(),
165 meta_table_.GetCompatibleVersionNumber());
166 if (current_version < meta_table_.GetCompatibleVersionNumber())
dhollowa 2012/07/09 20:26:06 Shouldn't this be: if (meta_table_.GetVersionNum
Ivan Korotkov 2012/07/09 20:51:04 Ouch, you must be right. The test passed because t
Peter Kasting 2012/07/09 21:22:01 I'm sorry for suggesting this incorrect code to Iv
167 ChangeVersion(&meta_table_, current_version, false);
168
161 // Migrate if necessary. 169 // Migrate if necessary.
162 int current_version = meta_table_.GetVersionNumber();
163 switch (current_version) { 170 switch (current_version) {
164 // Versions 1 - 19 are unhandled. Version numbers greater than 171 // Versions 1 - 19 are unhandled. Version numbers greater than
165 // kCurrentVersionNumber should have already been weeded out by the caller. 172 // kCurrentVersionNumber should have already been weeded out by the caller.
166 default: 173 default:
167 // When the version is too old, we return failure error code. The schema 174 // When the version is too old, we return failure error code. The schema
168 // is too out of date to migrate. 175 // is too out of date to migrate.
169 // There should not be a released product that makes a database too old to 176 // There should not be a released product that makes a database too old to
170 // migrate. If we do encounter such a legacy database, we will need a 177 // migrate. If we do encounter such a legacy database, we will need a
171 // better solution to handle it (i.e., pop up a dialog to tell the user, 178 // better solution to handle it (i.e., pop up a dialog to tell the user,
172 // erase all their prefs and start over, etc.). 179 // erase all their prefs and start over, etc.).
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 345
339 // Add successive versions here. Each should set the version number and 346 // Add successive versions here. Each should set the version number and
340 // compatible version number as appropriate, then fall through to the next 347 // compatible version number as appropriate, then fall through to the next
341 // case. 348 // case.
342 349
343 case kCurrentVersionNumber: 350 case kCurrentVersionNumber:
344 // No migration needed. 351 // No migration needed.
345 return sql::INIT_OK; 352 return sql::INIT_OK;
346 } 353 }
347 } 354 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/webdata/web_database_migration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698