diff options
-rw-r--r-- | chrome/browser/webdata/autofill_table.cc | 4 | ||||
-rw-r--r-- | chrome/browser/webdata/autofill_table.h | 3 | ||||
-rw-r--r-- | chrome/browser/webdata/autofill_table_unittest.cc | 53 | ||||
-rw-r--r-- | chrome/browser/webdata/keyword_table_unittest.cc | 14 | ||||
-rw-r--r-- | chrome/browser/webdata/token_service_table_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/webdata/web_apps_table_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/webdata/web_data_service.cc | 11 | ||||
-rw-r--r-- | chrome/browser/webdata/web_data_service.h | 5 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database.cc | 11 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database.h | 9 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database_migration_unittest.cc | 56 | ||||
-rw-r--r-- | chrome/browser/webdata/web_intents_table_unittest.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/delete_chrome_history_test.cc | 2 |
13 files changed, 92 insertions, 87 deletions
diff --git a/chrome/browser/webdata/autofill_table.cc b/chrome/browser/webdata/autofill_table.cc index 32f2201..9906ee3 100644 --- a/chrome/browser/webdata/autofill_table.cc +++ b/chrome/browser/webdata/autofill_table.cc @@ -1866,7 +1866,8 @@ bool AutofillTable::MigrateToVersion33ProfilesBasedOnFirstName() { // we need a migration. It is possible that the new |autofill_profiles| // schema is in place because the table was newly created when migrating // from a pre-version-22 database. -bool AutofillTable::MigrateToVersion34ProfilesBasedOnCountryCode() { +bool AutofillTable::MigrateToVersion34ProfilesBasedOnCountryCode( + const std::string& app_locale) { if (!db_->DoesColumnExist("autofill_profiles", "country_code")) { if (!db_->Execute("ALTER TABLE autofill_profiles ADD COLUMN " "country_code VARCHAR")) { @@ -1883,7 +1884,6 @@ bool AutofillTable::MigrateToVersion34ProfilesBasedOnCountryCode() { "SET country_code=? WHERE guid=?")); string16 country = s.ColumnString16(1); - std::string app_locale = AutofillCountry::ApplicationLocale(); update_s.BindString(0, AutofillCountry::GetCountryCode(country, app_locale)); update_s.BindString(1, s.ColumnString(0)); diff --git a/chrome/browser/webdata/autofill_table.h b/chrome/browser/webdata/autofill_table.h index adac102..3c8af5c 100644 --- a/chrome/browser/webdata/autofill_table.h +++ b/chrome/browser/webdata/autofill_table.h @@ -289,7 +289,8 @@ class AutofillTable : public WebDatabaseTable { bool MigrateToVersion31AddGUIDToCreditCardsAndProfiles(); bool MigrateToVersion32UpdateProfilesAndCreditCards(); bool MigrateToVersion33ProfilesBasedOnFirstName(); - bool MigrateToVersion34ProfilesBasedOnCountryCode(); + bool MigrateToVersion34ProfilesBasedOnCountryCode( + const std::string& app_locale); bool MigrateToVersion35GreatBritainCountryCodes(); bool MigrateToVersion37MergeAndCullOlderProfiles(); diff --git a/chrome/browser/webdata/autofill_table_unittest.cc b/chrome/browser/webdata/autofill_table_unittest.cc index 7aa79c2..5f6835a 100644 --- a/chrome/browser/webdata/autofill_table_unittest.cc +++ b/chrome/browser/webdata/autofill_table_unittest.cc @@ -124,7 +124,7 @@ class AutofillTableTest : public testing::Test { TEST_F(AutofillTableTest, Autofill) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); Time t1 = Time::Now(); @@ -282,7 +282,7 @@ TEST_F(AutofillTableTest, Autofill) { TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); TimeDelta one_day(TimeDelta::FromDays(1)); Time t1 = Time::Now(); @@ -318,7 +318,7 @@ TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) { TEST_F(AutofillTableTest, Autofill_AddChanges) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); TimeDelta one_day(TimeDelta::FromDays(1)); Time t1 = Time::Now(); @@ -348,7 +348,7 @@ TEST_F(AutofillTableTest, Autofill_AddChanges) { TEST_F(AutofillTableTest, Autofill_UpdateOneWithOneTimestamp) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, -1)); std::vector<AutofillEntry> entries; @@ -373,7 +373,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateOneWithOneTimestamp) { TEST_F(AutofillTableTest, Autofill_UpdateOneWithTwoTimestamps) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, 2)); std::vector<AutofillEntry> entries; @@ -398,7 +398,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateOneWithTwoTimestamps) { TEST_F(AutofillTableTest, Autofill_GetAutofillTimestamps) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, 2)); std::vector<AutofillEntry> entries; @@ -416,7 +416,7 @@ TEST_F(AutofillTableTest, Autofill_GetAutofillTimestamps) { TEST_F(AutofillTableTest, Autofill_UpdateTwo) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillEntry entry0(MakeAutofillEntry("foo", "bar0", 1, -1)); AutofillEntry entry1(MakeAutofillEntry("foo", "bar1", 2, 3)); @@ -446,7 +446,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateTwo) { TEST_F(AutofillTableTest, Autofill_UpdateReplace) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillChangeList changes; // Add a form field. This will be replaced. @@ -468,7 +468,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateReplace) { TEST_F(AutofillTableTest, Autofill_UpdateDontReplace) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); Time t = Time::Now(); AutofillEntry existing( @@ -497,7 +497,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateDontReplace) { TEST_F(AutofillTableTest, Autofill_AddFormFieldValues) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); Time t = Time::Now(); @@ -541,7 +541,7 @@ TEST_F(AutofillTableTest, Autofill_AddFormFieldValues) { TEST_F(AutofillTableTest, AutofillProfile) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); // Add a 'Home' profile. AutofillProfile home_profile; @@ -635,8 +635,7 @@ TEST_F(AutofillTableTest, AutofillProfile) { billing_profile.SetRawInfo(ADDRESS_HOME_CITY, ASCIIToUTF16("NFA")); billing_profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("NY")); billing_profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("10011")); - billing_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, - ASCIIToUTF16("United States")); + billing_profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); billing_profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181230000")); Time pre_modification_time_2 = Time::Now(); @@ -667,7 +666,7 @@ TEST_F(AutofillTableTest, AutofillProfile) { TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillProfile p; const string16 kJohnDoe(ASCIIToUTF16("John Doe")); @@ -708,7 +707,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueNames) { TEST_F(AutofillTableTest, AutofillProfileSingleValue) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillProfile p; const string16 kJohnDoe(ASCIIToUTF16("John Doe")); @@ -744,7 +743,7 @@ TEST_F(AutofillTableTest, AutofillProfileSingleValue) { TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillProfile p; const string16 kJohnDoe(ASCIIToUTF16("john@doe.com")); @@ -785,7 +784,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValueEmails) { TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillProfile p; const string16 kJohnDoe(ASCIIToUTF16("4151112222")); @@ -827,7 +826,7 @@ TEST_F(AutofillTableTest, AutofillProfileMultiValuePhone) { TEST_F(AutofillTableTest, AutofillProfileTrash) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); std::vector<std::string> guids; db.GetAutofillTable()->GetAutofillProfilesInTrash(&guids); @@ -850,7 +849,7 @@ TEST_F(AutofillTableTest, AutofillProfileTrash) { TEST_F(AutofillTableTest, AutofillProfileTrashInteraction) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); std::vector<std::string> guids; db.GetAutofillTable()->GetAutofillProfilesInTrash(&guids); @@ -925,7 +924,7 @@ TEST_F(AutofillTableTest, AutofillProfileTrashInteraction) { TEST_F(AutofillTableTest, CreditCard) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); // Add a 'Work' credit card. CreditCard work_creditcard; @@ -1013,7 +1012,7 @@ TEST_F(AutofillTableTest, CreditCard) { TEST_F(AutofillTableTest, UpdateAutofillProfile) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); // Add a profile to the db. AutofillProfile profile; @@ -1097,7 +1096,7 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) { TEST_F(AutofillTableTest, UpdateCreditCard) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); // Add a credit card to the db. CreditCard credit_card; @@ -1173,7 +1172,7 @@ TEST_F(AutofillTableTest, UpdateCreditCard) { TEST_F(AutofillTableTest, RemoveAutofillProfilesAndCreditCardsModifiedBetween) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); // Populate the autofill_profiles and credit_cards tables. ASSERT_TRUE(db.GetSQLConnection()->Execute( @@ -1291,7 +1290,7 @@ TEST_F(AutofillTableTest, RemoveAutofillProfilesAndCreditCardsModifiedBetween) { TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_NoResults) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); std::vector<AutofillEntry> entries; ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&entries)); @@ -1302,7 +1301,7 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_NoResults) { TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_OneResult) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillChangeList changes; std::map<std::string, std::vector<Time> > name_value_times_map; @@ -1344,7 +1343,7 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_OneResult) { TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillChangeList changes; std::map<std::string, std::vector<Time> > name_value_times_map; @@ -1401,7 +1400,7 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoSame) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); AutofillChangeList changes; std::map<std::string, std::vector<Time> > name_value_times_map; diff --git a/chrome/browser/webdata/keyword_table_unittest.cc b/chrome/browser/webdata/keyword_table_unittest.cc index 9bec318..e78b19e 100644 --- a/chrome/browser/webdata/keyword_table_unittest.cc +++ b/chrome/browser/webdata/keyword_table_unittest.cc @@ -43,7 +43,7 @@ class KeywordTableTest : public testing::Test { TEST_F(KeywordTableTest, Keywords) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); TemplateURLData keyword; @@ -101,7 +101,7 @@ TEST_F(KeywordTableTest, Keywords) { TEST_F(KeywordTableTest, KeywordMisc) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); EXPECT_EQ(kInvalidTemplateURLID, keyword_table->GetDefaultSearchProviderID()); @@ -135,7 +135,7 @@ TEST_F(KeywordTableTest, KeywordMisc) { TEST_F(KeywordTableTest, GetTableContents) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); TemplateURLData keyword; @@ -179,7 +179,7 @@ TEST_F(KeywordTableTest, GetTableContents) { TEST_F(KeywordTableTest, GetTableContentsOrdering) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); TemplateURLData keyword; @@ -224,7 +224,7 @@ TEST_F(KeywordTableTest, GetTableContentsOrdering) { TEST_F(KeywordTableTest, UpdateKeyword) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); TemplateURLData keyword; @@ -267,7 +267,7 @@ TEST_F(KeywordTableTest, UpdateKeyword) { TEST_F(KeywordTableTest, KeywordWithNoFavicon) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); TemplateURLData keyword; @@ -293,7 +293,7 @@ TEST_F(KeywordTableTest, KeywordWithNoFavicon) { TEST_F(KeywordTableTest, SanitizeURLs) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); KeywordTable* keyword_table = db.GetKeywordTable(); TemplateURLData keyword; diff --git a/chrome/browser/webdata/token_service_table_unittest.cc b/chrome/browser/webdata/token_service_table_unittest.cc index c712261..0b1e3ec 100644 --- a/chrome/browser/webdata/token_service_table_unittest.cc +++ b/chrome/browser/webdata/token_service_table_unittest.cc @@ -34,7 +34,7 @@ class TokenServiceTableTest : public testing::Test { TEST_F(TokenServiceTableTest, TokenServiceGetAllRemoveAll) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); std::map<std::string, std::string> out_map; std::string service; @@ -67,7 +67,7 @@ TEST_F(TokenServiceTableTest, TokenServiceGetAllRemoveAll) { TEST_F(TokenServiceTableTest, TokenServiceGetSet) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); std::map<std::string, std::string> out_map; std::string service; diff --git a/chrome/browser/webdata/web_apps_table_unittest.cc b/chrome/browser/webdata/web_apps_table_unittest.cc index 8db136a..837c488 100644 --- a/chrome/browser/webdata/web_apps_table_unittest.cc +++ b/chrome/browser/webdata/web_apps_table_unittest.cc @@ -38,7 +38,7 @@ class WebAppsTableTest : public testing::Test { TEST_F(WebAppsTableTest, WebAppHasAllImages) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); GURL url("http://google.com/"); // Initial value for unknown web app should be false. @@ -56,7 +56,7 @@ TEST_F(WebAppsTableTest, WebAppHasAllImages) { TEST_F(WebAppsTableTest, WebAppImages) { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(file_)); + ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string())); GURL url("http://google.com/"); // Web app should initially have no images. diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index 685b5f3..7428bfa 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -80,6 +80,7 @@ WDKeywordsResult::~WDKeywordsResult() {} WebDataService::WebDataService() : is_running_(false), db_(NULL), + app_locale_(AutofillCountry::ApplicationLocale()), autocomplete_syncable_service_(NULL), autofill_profile_syncable_service_(NULL), failed_init_(false), @@ -527,14 +528,6 @@ bool WebDataService::InitWithPath(const FilePath& path) { path_ = path; is_running_ = true; - // TODO(isherman): For now, to avoid a data race on shutdown - // [ http://crbug.com/100745 ], call |AutofillCountry::ApplicationLocale()| to - // cache the application locale before we try to access it on the DB thread. - // This should be safe to remove once [ http://crbug.com/100845 ] is fixed. - // Do not do it if the thread is not UI (can happen only in some tests). - if (BrowserThread::CurrentlyOn(BrowserThread::UI)) - AutofillCountry::ApplicationLocale(); - ScheduleTask(FROM_HERE, Bind(&WebDataService::InitializeDatabaseIfNecessary, this)); ScheduleTask(FROM_HERE, @@ -567,7 +560,7 @@ void WebDataService::InitializeDatabaseIfNecessary() { // we only set db_ to the created database if creation is successful. That // way other methods won't do anything as db_ is still NULL. WebDatabase* db = new WebDatabase(); - sql::InitStatus init_status = db->Init(path_); + sql::InitStatus init_status = db->Init(path_, app_locale_); if (init_status != sql::INIT_OK) { LOG(ERROR) << "Cannot initialize the web database: " << init_status; failed_init_ = true; diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index f50d204..2d1c841 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -478,6 +478,11 @@ class WebDataService // Keeps track of all pending requests made to the db. WebDataRequestManager request_manager_; + // The application locale. The locale is needed for some database migrations, + // and must be read on the UI thread. It's cached here so that we can pass it + // to the migration code on the DB thread. + const std::string app_locale_; + // Syncable services for the database data. We own the services, but don't // use |scoped_ptr|s because the lifetimes must be managed on the database // thread. diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc index 38f898d..48316da 100644 --- a/chrome/browser/webdata/web_database.cc +++ b/chrome/browser/webdata/web_database.cc @@ -89,7 +89,8 @@ sql::Connection* WebDatabase::GetSQLConnection() { return &db_; } -sql::InitStatus WebDatabase::Init(const FilePath& db_name) { +sql::InitStatus WebDatabase::Init(const FilePath& db_name, + const std::string& app_locale) { // When running in unit tests, there is already a NotificationService object. // Since only one can exist at a time per thread, check first. if (!content::NotificationService::current()) @@ -148,14 +149,15 @@ sql::InitStatus WebDatabase::Init(const FilePath& db_name) { // If the file on disk is an older database version, bring it up to date. // If the migration fails we return an error to caller and do not commit // the migration. - sql::InitStatus migration_status = MigrateOldVersionsAsNeeded(); + sql::InitStatus migration_status = MigrateOldVersionsAsNeeded(app_locale); if (migration_status != sql::INIT_OK) return migration_status; return transaction.Commit() ? sql::INIT_OK : sql::INIT_FAILURE; } -sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() { +sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded( + const std::string& app_locale) { // Some malware used to lower the version number, causing migration to // fail. Ensure the version number is at least as high as the compatible // version number. @@ -272,7 +274,8 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() { // FALL THROUGH case 33: - if (!autofill_table_->MigrateToVersion34ProfilesBasedOnCountryCode()) + if (!autofill_table_->MigrateToVersion34ProfilesBasedOnCountryCode( + app_locale)) return FailedMigrationTo(34); ChangeVersion(&meta_table_, 34, true); diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h index 250f1c4..d384e65 100644 --- a/chrome/browser/webdata/web_database.h +++ b/chrome/browser/webdata/web_database.h @@ -33,7 +33,9 @@ class WebDatabase { // Initialize the database given a name. The name defines where the SQLite // file is. If this returns an error code, no other method should be called. - sql::InitStatus Init(const FilePath& db_name); + // Requires the |app_locale| to be passed as a parameter as the locale can + // only safely be queried on the UI thread. + sql::InitStatus Init(const FilePath& db_name, const std::string& app_locale); // Transactions management void BeginTransaction(); @@ -51,8 +53,9 @@ class WebDatabase { private: // Used by |Init()| to migration database schema from older versions to - // current version. - sql::InitStatus MigrateOldVersionsAsNeeded(); + // current version. Requires the |app_locale| to be passed as a parameter as + // the locale can only safely be queried on the UI thread. + sql::InitStatus MigrateOldVersionsAsNeeded(const std::string& app_locale); sql::Connection db_; sql::MetaTable meta_table_; diff --git a/chrome/browser/webdata/web_database_migration_unittest.cc b/chrome/browser/webdata/web_database_migration_unittest.cc index 57170c0..054aa93 100644 --- a/chrome/browser/webdata/web_database_migration_unittest.cc +++ b/chrome/browser/webdata/web_database_migration_unittest.cc @@ -230,7 +230,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -282,7 +282,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion22ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -330,7 +330,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion22CorruptedToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -370,7 +370,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion25ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -433,7 +433,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringLabels) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -503,7 +503,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion26ToCurrentStringIDs) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -552,7 +552,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion27ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -626,7 +626,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion29ToCurrent) { Time pre_creation_time = Time::Now(); { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } Time post_creation_time = Time::Now(); @@ -688,7 +688,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion30ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -790,7 +790,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -913,7 +913,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion32ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1198,7 +1198,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion33ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1254,7 +1254,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion34ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1311,7 +1311,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion35ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1395,7 +1395,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion37ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1435,7 +1435,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion38ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1480,7 +1480,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion39ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1531,7 +1531,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion40ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1582,7 +1582,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion41ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1635,7 +1635,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion42ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1691,7 +1691,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion43ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1743,7 +1743,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion44ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1799,7 +1799,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1880,7 +1880,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45InvalidToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1945,7 +1945,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45CompatibleToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -1986,7 +1986,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion46ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -2031,7 +2031,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion47ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the @@ -2081,7 +2081,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion48ToCurrent) { // the current version. { WebDatabase db; - ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath())); + ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath(), std::string())); } // Verify post-conditions. These are expectations for current version of the diff --git a/chrome/browser/webdata/web_intents_table_unittest.cc b/chrome/browser/webdata/web_intents_table_unittest.cc index cb77066..65f5191 100644 --- a/chrome/browser/webdata/web_intents_table_unittest.cc +++ b/chrome/browser/webdata/web_intents_table_unittest.cc @@ -65,7 +65,8 @@ class WebIntentsTableTest : public testing::Test { virtual void SetUp() { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_EQ(sql::INIT_OK, - db_.Init(temp_dir_.path().AppendASCII("TestWebDatabase.db"))); + db_.Init(temp_dir_.path().AppendASCII("TestWebDatabase.db"), + std::string())); } WebIntentsTable* IntentsTable() { diff --git a/chrome_frame/test/delete_chrome_history_test.cc b/chrome_frame/test/delete_chrome_history_test.cc index ee4cfcf..a0fc92d 100644 --- a/chrome_frame/test/delete_chrome_history_test.cc +++ b/chrome_frame/test/delete_chrome_history_test.cc @@ -103,7 +103,7 @@ ACTION_P2(ExpectFormValuesForElementNameMatch, element_name, matcher) { root_path.Append(L"Default").Append(chrome::kWebDataFilename)); WebDatabase web_database; - sql::InitStatus init_status = web_database.Init(profile_path); + sql::InitStatus init_status = web_database.Init(profile_path, std::string()); EXPECT_EQ(sql::INIT_OK, init_status); if (init_status == sql::INIT_OK) { |