summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorcaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 17:49:46 +0000
committercaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 17:49:46 +0000
commite5bb75a821db601870d8d84dec485100bd46c940 (patch)
tree9fc91ff9296980e034d532912831da75b81068df /components
parent7cf113760da68cd626661b648f27314db7ba3f5b (diff)
downloadchromium_src-e5bb75a821db601870d8d84dec485100bd46c940.zip
chromium_src-e5bb75a821db601870d8d84dec485100bd46c940.tar.gz
chromium_src-e5bb75a821db601870d8d84dec485100bd46c940.tar.bz2
Remove unused SQLLite tables from WebData
WebApp code was deleted here: https://codereview.chromium.org/19746 WebIntents code was deleted here: https://codereview.chromium.org/22407016/ https://codereview.chromium.org/12225076/ BUG=241909 Review URL: https://codereview.chromium.org/382703002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/test/data/web_database/version_57.sql30
-rw-r--r--components/webdata/DEPS2
-rw-r--r--components/webdata/common/web_database.cc36
-rw-r--r--components/webdata/common/web_database.h12
-rw-r--r--components/webdata/common/web_database_migration_unittest.cc126
5 files changed, 132 insertions, 74 deletions
diff --git a/components/test/data/web_database/version_57.sql b/components/test/data/web_database/version_57.sql
new file mode 100644
index 0000000..081bca5
--- /dev/null
+++ b/components/test/data/web_database/version_57.sql
@@ -0,0 +1,30 @@
+PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR);
+INSERT INTO "meta" VALUES('version','57');
+INSERT INTO "meta" VALUES('last_compatible_version','57');
+INSERT INTO "meta" VALUES('Builtin Keyword Version','70');
+INSERT INTO "meta" VALUES('Default Search Provider ID','2');
+CREATE TABLE web_intents ( service_url LONGVARCHAR, action VARCHAR, type VARCHAR, title LONGVARCHAR, disposition VARCHAR, scheme VARCHAR, UNIQUE (service_url, action, scheme, type));
+CREATE TABLE web_intents_defaults ( action VARCHAR, type VARCHAR, url_pattern LONGVARCHAR, user_date INTEGER, suppression INTEGER, service_url LONGVARCHAR, scheme VARCHAR, UNIQUE (action, scheme, type, url_pattern));
+CREATE TABLE keywords (id INTEGER PRIMARY KEY,short_name VARCHAR NOT NULL,keyword VARCHAR NOT NULL,favicon_url VARCHAR NOT NULL,url VARCHAR NOT NULL,safe_for_autoreplace INTEGER,originating_url VARCHAR,date_created INTEGER DEFAULT 0,usage_count INTEGER DEFAULT 0,input_encodings VARCHAR,show_in_default_list INTEGER,suggest_url VARCHAR,prepopulate_id INTEGER DEFAULT 0,created_by_policy INTEGER DEFAULT 0,instant_url VARCHAR,last_modified INTEGER DEFAULT 0,sync_guid VARCHAR,alternate_urls VARCHAR,search_terms_replacement_key VARCHAR,image_url VARCHAR,search_url_post_params VARCHAR,suggest_url_post_params VARCHAR,instant_url_post_params VARCHAR,image_url_post_params VARCHAR,new_tab_url VARCHAR);
+CREATE TABLE web_app_icons (url LONGVARCHAR,width int,height int,image BLOB, UNIQUE (url, width, height));
+CREATE TABLE web_apps (url LONGVARCHAR UNIQUE,has_all_images INTEGER NOT NULL);
+CREATE TABLE autofill (name VARCHAR, value VARCHAR, value_lower VARCHAR, date_created INTEGER DEFAULT 0, date_last_used INTEGER DEFAULT 0, count INTEGER DEFAULT 1, PRIMARY KEY (name, value));
+CREATE TABLE credit_cards ( guid VARCHAR PRIMARY KEY, name_on_card VARCHAR, expiration_month INTEGER, expiration_year INTEGER, card_number_encrypted BLOB, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '');
+CREATE TABLE autofill_profiles ( guid VARCHAR PRIMARY KEY, company_name VARCHAR, street_address VARCHAR, dependent_locality VARCHAR, city VARCHAR, state VARCHAR, zipcode VARCHAR, sorting_code VARCHAR, country_code VARCHAR, date_modified INTEGER NOT NULL DEFAULT 0, origin VARCHAR DEFAULT '', language_code VARCHAR);
+INSERT INTO "autofill_profiles" VALUES('00000000-0000-0000-0000-000000000001','Google Inc','340 Main St','','Los Angeles','CA','90291','','US',1395948829,'Chrome settings', 'en-US');
+CREATE TABLE autofill_profile_names ( guid VARCHAR, first_name VARCHAR, middle_name VARCHAR, last_name VARCHAR, full_name VARCHAR);
+INSERT INTO "autofill_profile_names" VALUES('B41FE6E0-B13E-2A2A-BF0B-29FCE2C3ADBD','Jon','','Smith', 'Jon Smith');
+CREATE TABLE autofill_profile_emails ( guid VARCHAR, email VARCHAR);
+INSERT INTO "autofill_profile_emails" VALUES('B41FE6E0-B13E-2A2A-BF0B-29FCE2C3ADBD','');
+CREATE TABLE autofill_profile_phones ( guid VARCHAR, number VARCHAR);
+INSERT INTO "autofill_profile_phones" VALUES('B41FE6E0-B13E-2A2A-BF0B-29FCE2C3ADBD','');
+CREATE TABLE autofill_profiles_trash ( guid VARCHAR);
+CREATE TABLE token_service (service VARCHAR PRIMARY KEY NOT NULL,encrypted_token BLOB);
+CREATE INDEX web_intents_index ON web_intents (action);
+CREATE INDEX web_intents_default_index ON web_intents_defaults (action);
+CREATE INDEX web_apps_url_index ON web_apps (url);
+CREATE INDEX autofill_name ON autofill (name);
+CREATE INDEX autofill_name_value_lower ON autofill (name, value_lower);
+COMMIT;
diff --git a/components/webdata/DEPS b/components/webdata/DEPS
index 1a60d96..d443cb4 100644
--- a/components/webdata/DEPS
+++ b/components/webdata/DEPS
@@ -10,10 +10,8 @@ specific_include_rules = {
"+chrome/browser/webdata/logins_table.h",
"+chrome/browser/webdata/token_service_table.h",
"+chrome/browser/webdata/token_web_data.h",
- "+chrome/browser/webdata/web_apps_table.h",
"+chrome/browser/webdata/web_data_service.h",
"+chrome/browser/webdata/web_data_service_factory.h",
- "+chrome/browser/webdata/web_intents_table.h",
"+components/autofill/core",
"+components/password_manager/core/browser/webdata",
"+components/search_engines/keyword_table.h",
diff --git a/components/webdata/common/web_database.cc b/components/webdata/common/web_database.cc
index 2028290..3b5d9d2 100644
--- a/components/webdata/common/web_database.cc
+++ b/components/webdata/common/web_database.cc
@@ -14,11 +14,11 @@
// corresponding changes must happen in the unit tests, and new migration test
// added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|.
// static
-const int WebDatabase::kCurrentVersionNumber = 57;
+const int WebDatabase::kCurrentVersionNumber = 58;
namespace {
-const int kCompatibleVersionNumber = 57;
+const int kCompatibleVersionNumber = 58;
// Change the version number and possibly the compatibility version of
// |meta_table_|.
@@ -155,10 +155,18 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() {
for (int next_version = current_version + 1;
next_version <= kCurrentVersionNumber;
++next_version) {
+
+ // Do any database-wide migrations.
+ bool update_compatible_version = false;
+ if (!MigrateToVersion(next_version, &update_compatible_version))
+ return FailedMigrationTo(next_version);
+
+ ChangeVersion(&meta_table_, next_version, update_compatible_version);
+
// Give each table a chance to migrate to this version.
for (TableMap::iterator it = tables_.begin(); it != tables_.end(); ++it) {
// Any of the tables may set this to true, but by default it is false.
- bool update_compatible_version = false;
+ update_compatible_version = false;
if (!it->second->MigrateToVersion(next_version,
&update_compatible_version)) {
return FailedMigrationTo(next_version);
@@ -169,3 +177,25 @@ sql::InitStatus WebDatabase::MigrateOldVersionsAsNeeded() {
}
return sql::INIT_OK;
}
+
+bool WebDatabase::MigrateToVersion(int version,
+ bool* update_compatible_version) {
+ // Migrate if necessary.
+ switch (version) {
+ case 58:
+ *update_compatible_version = true;
+ return MigrateToVersion58DropWebAppsAndIntents();
+ }
+
+ return true;
+}
+
+bool WebDatabase::MigrateToVersion58DropWebAppsAndIntents() {
+ sql::Transaction transaction(&db_);
+ return transaction.Begin() &&
+ db_.Execute("DROP TABLE IF EXISTS web_apps") &&
+ db_.Execute("DROP TABLE IF EXISTS web_app_icons") &&
+ db_.Execute("DROP TABLE IF EXISTS web_intents") &&
+ db_.Execute("DROP TABLE IF EXISTS web_intents_defaults") &&
+ transaction.Commit();
+}
diff --git a/components/webdata/common/web_database.h b/components/webdata/common/web_database.h
index e7fedf0..22730fe 100644
--- a/components/webdata/common/web_database.h
+++ b/components/webdata/common/web_database.h
@@ -59,6 +59,18 @@ class WEBDATA_EXPORT WebDatabase {
// current version.
sql::InitStatus MigrateOldVersionsAsNeeded();
+ // Migrates this database to |version|. Returns false if there was
+ // migration work to do and it failed, true otherwise.
+ //
+ // Implementations may set |*update_compatible_version| to true if
+ // the compatible version should be changed to |version|.
+ // Implementations should otherwise not modify this parameter.
+ bool MigrateToVersion(int version,
+ bool* update_compatible_version);
+
+ // Migration method for version 58.
+ bool MigrateToVersion58DropWebAppsAndIntents();
+
sql::Connection db_;
sql::MetaTable meta_table_;
diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc
index fe8a32c..5d9fad1 100644
--- a/components/webdata/common/web_database_migration_unittest.cc
+++ b/components/webdata/common/web_database_migration_unittest.cc
@@ -16,8 +16,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
-#include "chrome/browser/webdata/web_apps_table.h"
-#include "chrome/browser/webdata/web_intents_table.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_type.h"
@@ -189,16 +187,12 @@ class WebDatabaseMigrationTest : public testing::Test {
KeywordTable keyword_table;
LoginsTable logins_table;
TokenServiceTable token_service_table;
- WebAppsTable web_apps_table;
- WebIntentsTable web_intents_table;
WebDatabase db;
db.AddTable(&autofill_table);
db.AddTable(&keyword_table);
db.AddTable(&logins_table);
db.AddTable(&token_service_table);
- db.AddTable(&web_apps_table);
- db.AddTable(&web_intents_table);
// This causes the migration to occur.
ASSERT_EQ(sql::INIT_OK, db.Init(GetDatabasePath()));
@@ -256,7 +250,7 @@ class WebDatabaseMigrationTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(WebDatabaseMigrationTest);
};
-const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 57;
+const int WebDatabaseMigrationTest::kCurrentTestedVersionNumber = 58;
void WebDatabaseMigrationTest::LoadDatabase(
const base::FilePath::StringType& file) {
@@ -312,10 +306,13 @@ TEST_F(WebDatabaseMigrationTest, MigrateEmptyToCurrent) {
EXPECT_FALSE(connection.DoesTableExist("logins"));
EXPECT_TRUE(connection.DoesTableExist("meta"));
EXPECT_TRUE(connection.DoesTableExist("token_service"));
- EXPECT_TRUE(connection.DoesTableExist("web_app_icons"));
- EXPECT_TRUE(connection.DoesTableExist("web_apps"));
- EXPECT_TRUE(connection.DoesTableExist("web_intents"));
- EXPECT_TRUE(connection.DoesTableExist("web_intents_defaults"));
+ // The web_apps and web_apps_icons tables are obsolete as of version 58.
+ EXPECT_FALSE(connection.DoesTableExist("web_apps"));
+ EXPECT_FALSE(connection.DoesTableExist("web_app_icons"));
+ // The web_intents and web_intents_defaults tables are obsolete as of
+ // version 58.
+ EXPECT_FALSE(connection.DoesTableExist("web_intents"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents_defaults"));
}
}
@@ -1877,8 +1874,10 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion44ToCurrent) {
}
}
-// Tests that the web_intents and web_intents_defaults tables are
-// modified to include "scheme" columns.
+// Previously, this tested that the web_intents and web_intents_defaults tables
+// were modified to include "scheme" columns. Since the web_intents and
+// web_intents_defaults tables are now obsolete, this test checks to ensure that
+// they are properly removed.
TEST_F(WebDatabaseMigrationTest, MigrateVersion45ToCurrent) {
ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_45.sql")));
@@ -1915,45 +1914,16 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45ToCurrent) {
kCurrentTestedVersionNumber,
kCurrentTestedVersionNumber));
- // A new "scheme" column should have been added to each web_intents table.
- EXPECT_TRUE(connection.DoesColumnExist("web_intents", "scheme"));
- EXPECT_TRUE(connection.DoesColumnExist("web_intents_defaults", "scheme"));
-
- // Verify existing user data was copied.
- sql::Statement s1(
- connection.GetUniqueStatement("SELECT * FROM web_intents"));
-
- ASSERT_TRUE(s1.Step());
- EXPECT_EQ("http://poodles.com/fuzzer", s1.ColumnString(0));
- EXPECT_EQ(ASCIIToUTF16("fuzz"), s1.ColumnString16(1));
- EXPECT_EQ(ASCIIToUTF16("poodle/*"), s1.ColumnString16(2));
- EXPECT_EQ(ASCIIToUTF16("Poodle Fuzzer"), s1.ColumnString16(3));
- EXPECT_EQ(ASCIIToUTF16("window"), s1.ColumnString16(4));
- EXPECT_EQ(ASCIIToUTF16(""), s1.ColumnString16(5));
- ASSERT_FALSE(s1.Step());
-
- // Now we want to verify existing user data was copied
- sql::Statement s2(
- connection.GetUniqueStatement("SELECT * FROM web_intents_defaults"));
-
- ASSERT_TRUE(s2.Step());
- EXPECT_EQ("fuzz", s2.ColumnString(0));
- EXPECT_EQ(ASCIIToUTF16("poodle/*"), s2.ColumnString16(1));
- EXPECT_EQ(ASCIIToUTF16(""), s2.ColumnString16(2));
- EXPECT_EQ(0, s2.ColumnInt(3));
- EXPECT_EQ(0, s2.ColumnInt(4));
- EXPECT_EQ(ASCIIToUTF16("http://poodles.com/fuzzer"), s2.ColumnString16(5));
- EXPECT_EQ(ASCIIToUTF16(""), s2.ColumnString16(6));
- ASSERT_FALSE(s2.Step());
-
// finally ensure the migration code cleaned up after itself
- EXPECT_FALSE(connection.DoesTableExist("old_web_intents"));
- EXPECT_FALSE(connection.DoesTableExist("old_web_intents_defaults"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents_defaults"));
}
}
-// Tests that the web_intents and web_intents_defaults tables are
-// modified to include "scheme" columns.
+// Previously, this tested that the web_intents and web_intents_defaults tables
+// were modified to include "scheme" columns. Since the web_intents and
+// web_intents_defaults tables are now obsolete, this test checks to ensure that
+// they are properly removed.
TEST_F(WebDatabaseMigrationTest, MigrateVersion45InvalidToCurrent) {
ASSERT_NO_FATAL_FAILURE(
LoadDatabase(FILE_PATH_LITERAL("version_45_invalid.sql")));
@@ -1991,27 +1961,8 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion45InvalidToCurrent) {
kCurrentTestedVersionNumber,
kCurrentTestedVersionNumber));
- // A new "scheme" column should have been added to each web_intents table.
- EXPECT_TRUE(connection.DoesColumnExist("web_intents", "scheme"));
- EXPECT_TRUE(connection.DoesColumnExist("web_intents_defaults", "scheme"));
-
- // Verify existing user data was copied.
- sql::Statement s1(
- connection.GetUniqueStatement("SELECT * FROM web_intents"));
-
- ASSERT_FALSE(s1.Step()); // Basically should be empty at this point.
-
- // Now we want to verify existing user data was copied
- sql::Statement s2(
- connection.GetUniqueStatement("SELECT * FROM web_intents_defaults"));
-
- // We were able to create the new tables, but unable to copy any data
- // Given the initial bad state of the tables.
- ASSERT_FALSE(s2.Step());
-
- // Finally ensure the migration code cleaned up after itself.
- EXPECT_FALSE(connection.DoesTableExist("old_web_intents"));
- EXPECT_FALSE(connection.DoesTableExist("old_web_intents_defaults"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents_defaults"));
}
}
@@ -2733,3 +2684,40 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion56ToCurrent) {
ASSERT_FALSE(s_names.Step());
}
}
+
+// Tests that migrating from version 57 to version 58 drops the web_intents and
+// web_apps tables.
+TEST_F(WebDatabaseMigrationTest, MigrateVersion57ToCurrent) {
+ ASSERT_NO_FATAL_FAILURE(LoadDatabase(FILE_PATH_LITERAL("version_57.sql")));
+
+ // Verify pre-conditions. These are expectations for version 57 of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ EXPECT_TRUE(connection.DoesTableExist("web_apps"));
+ EXPECT_TRUE(connection.DoesTableExist("web_app_icons"));
+ EXPECT_TRUE(connection.DoesTableExist("web_intents"));
+ EXPECT_TRUE(connection.DoesTableExist("web_intents_defaults"));
+ }
+
+ DoMigration();
+
+ // Verify post-conditions. These are expectations for current version of the
+ // database.
+ {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.Open(GetDatabasePath()));
+ ASSERT_TRUE(sql::MetaTable::DoesTableExist(&connection));
+
+ // Check version.
+ EXPECT_EQ(kCurrentTestedVersionNumber, VersionFromConnection(&connection));
+
+ EXPECT_FALSE(connection.DoesTableExist("web_apps"));
+ EXPECT_FALSE(connection.DoesTableExist("web_app_icons"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents"));
+ EXPECT_FALSE(connection.DoesTableExist("web_intents_defaults"));
+ }
+}