summaryrefslogtreecommitdiffstats
path: root/chrome/browser/webdata
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 23:15:42 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 23:15:42 +0000
commitcea467f6e990d9990209a97ce3e896cb5ff72212 (patch)
tree569477d0332900bd572f73e369470d13df1b2f15 /chrome/browser/webdata
parent81a476540d6f2e30441ce623a3ee146894c88bfd (diff)
downloadchromium_src-cea467f6e990d9990209a97ce3e896cb5ff72212.zip
chromium_src-cea467f6e990d9990209a97ce3e896cb5ff72212.tar.gz
chromium_src-cea467f6e990d9990209a97ce3e896cb5ff72212.tar.bz2
Chrome crashes on migration of Autofill data with country "UK" round 2
Migrates bad country code "UK" to good country code "GB". These bad country codes were introduced in build 686. BUG=74511 TEST=WebDatabaseMigrationTest.MigrateVersion34ToCurrent TBR=isherman@chromium.org Review URL: http://codereview.chromium.org/6606021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
-rw-r--r--chrome/browser/webdata/web_database.cc26
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc61
2 files changed, 84 insertions, 3 deletions
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index fffa704..e38b7ca 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -192,8 +192,8 @@ typedef std::vector<Tuple3<int64, string16, string16> > AutofillElementList;
// Current version number. Note: when changing the current version number,
// corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
-const int kCurrentVersionNumber = 34;
-const int kCompatibleVersionNumber = 34;
+const int kCurrentVersionNumber = 35;
+const int kCompatibleVersionNumber = 35;
// ID of the url column in keywords.
const int kUrlIdPosition = 16;
@@ -3070,6 +3070,28 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded(){
// FALL THROUGH
+ case 34:
+ // Correct all country codes with value "UK" to be "GB". This data
+ // was mistakenly introduced in build 686.0. This migration is to clean
+ // it up. See http://crbug.com/74511 for details.
+ {
+ sql::Statement s(db_.GetUniqueStatement(
+ "UPDATE autofill_profiles SET country_code=\"GB\" "
+ "WHERE country_code=\"UK\""));
+
+ if (!s.Run()) {
+ LOG(WARNING) << "Unable to update web database to version 35.";
+ NOTREACHED();
+ return sql::INIT_FAILURE;
+ }
+ }
+
+ meta_table_.SetVersionNumber(35);
+ meta_table_.SetCompatibleVersionNumber(
+ std::min(35, kCompatibleVersionNumber));
+
+ // FALL THROUGH
+
// Add successive versions here. Each should set the version number and
// compatible version number as appropriate, then fall through to the next
// case.
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index 2adae26..d9d19ae 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -2104,7 +2104,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 34;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 35;
void WebDatabaseMigrationTest::LoadDatabase(const FilePath::StringType& file) {
std::string contents;
@@ -3172,3 +3172,62 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion33ToCurrent) {
EXPECT_EQ("US", country_code);
}
}
+
+// Cleans up bad country code "UK" in favor of good country code "GB".
+TEST_F(WebDatabaseMigrationTest, MigrateVersion34ToCurrent) {
+ // Initialize the database.
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_34.sql")));
+
+ // Verify pre-conditions. These are expectations for version 34 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+
+ EXPECT_TRUE(connection.DoesColumnExist("autofill_profiles",
+ "country_code"));
+
+ // Check that the country_code value is the one we expect.
+ sql::Statement s(
+ connection.GetUniqueStatement("SELECT country_code "
+ "FROM autofill_profiles"));
+
+ ASSERT_TRUE(s.Step());
+ std::string country_code = s.ColumnString(0);
+ EXPECT_EQ("UK", country_code);
+
+ // Should have only one.
+ ASSERT_FALSE(s.Step());
+ }
+
+ // Load the database via the WebDatabase class and migrate the database to
+ // the current version.
+ {
+ WebDatabase db;
+ ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
+ }
+
+ // Verify post-conditions. These are expectations for current version of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ ASSERT_TRUE(connection.DoesColumnExist("autofill_profiles",
+ "country_code"));
+
+ // Check that the country_code code is properly converted.
+ sql::Statement s(connection.GetUniqueStatement(
+ "SELECT country_code FROM autofill_profiles"));
+
+ ASSERT_TRUE(s.Step());
+ std::string country_code = s.ColumnString(0);
+ EXPECT_EQ("GB", country_code);
+
+ // Should have only one.
+ ASSERT_FALSE(s.Step());
+ }
+}