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

Unified Diff: chrome/browser/sync/syncable/directory_backing_store.cc

Issue 5159001: Rest of the autofill work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Couple of lint errors sneaked into my previous patch. This is clean of lint errors. Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/syncable/directory_backing_store.cc
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc
index c0036d3081c7a086235cb275c4e0a97187878ff0..68adc202aae317864be253f24f72628d24e02169 100644
--- a/chrome/browser/sync/syncable/directory_backing_store.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store.cc
@@ -44,7 +44,7 @@ static const string::size_type kUpdateStatementBufferSize = 2048;
// Increment this version whenever updating DB tables.
extern const int32 kCurrentDBVersion; // Global visibility for our unittest.
-const int32 kCurrentDBVersion = 73;
+const int32 kCurrentDBVersion = 74;
namespace {
@@ -379,11 +379,28 @@ bool DirectoryBackingStore::SaveChanges(
update.prepare(dbhandle, "UPDATE share_info "
"SET store_birthday = ?, "
"next_id = ?, "
- "notification_state = ?");
+ "notification_state = ?, "
+ "autofill_migration_state = ?, "
+ "bookmarks_added_during_autofill_migration = ?, "
+ "autofill_migration_time = ?, "
+ "autofill_entries_added_during_migration = ?, "
+ "autofill_profiles_added_during_migration = ? ");
+
+ syncable::AutofillMigrationDebugInfo& debug_info =
+ info.autofill_migration_debug_info;
tim (not reviewing) 2010/12/13 19:24:33 indent 4 spaces
lipalani 2010/12/14 21:05:57 Done.
update.bind_string(0, info.store_birthday);
update.bind_int64(1, info.next_id);
update.bind_blob(2, info.notification_state.data(),
info.notification_state.size());
+ update.bind_int(3, info.autofill_migration_state);
+ update.bind_int(4,
+ debug_info.bookmarks_added_during_migration);
+ update.bind_int64(5,
+ debug_info.autofill_migration_time);
+ update.bind_int(6,
+ debug_info.autofill_entries_added_during_migration);
+ update.bind_int(7,
+ debug_info.autofill_profile_added_during_migration);
if (!(SQLITE_DONE == update.step() &&
SQLITE_OK == update.reset() &&
@@ -456,6 +473,11 @@ DirOpenResult DirectoryBackingStore::InitializeTables() {
version_on_disk = 73;
}
+ if (version_on_disk == 73) {
+ if (MigrateVersion73To74())
+ version_on_disk = 74;
+ }
+
// If one of the migrations requested it, drop columns that aren't current.
// It's only safe to do this after migrating all the way to the current
// version.
@@ -556,13 +578,30 @@ bool DirectoryBackingStore::LoadInfo(Directory::KernelLoadInfo* info) {
SQLStatement query;
query.prepare(load_dbhandle_,
"SELECT store_birthday, next_id, cache_guid, "
- "notification_state FROM share_info");
+ "notification_state, autofill_migration_state, "
+ "bookmarks_added_during_autofill_migration, "
+ "autofill_migration_time, "
+ "autofill_entries_added_during_migration, "
+ "autofill_profiles_added_during_migration "
+ "FROM share_info");
if (SQLITE_ROW != query.step())
return false;
info->kernel_info.store_birthday = query.column_string(0);
info->kernel_info.next_id = query.column_int64(1);
info->cache_guid = query.column_string(2);
query.column_blob_as_string(3, &info->kernel_info.notification_state);
+ info->kernel_info.autofill_migration_state =
+ static_cast<AutofillMigrationState> (query.column_int(4));
tim (not reviewing) 2010/12/13 19:24:33 indent 4 spaces. would be nice to have dchecks on
lipalani 2010/12/15 09:08:33 Not sure how dchecks can be added. fixed the inden
+ syncable::AutofillMigrationDebugInfo& debug_info =
+ info->kernel_info.autofill_migration_debug_info;
+ debug_info.bookmarks_added_during_migration =
+ query.column_int(5);
+ debug_info.autofill_migration_time =
+ query.column_int64(6);
+ debug_info.autofill_entries_added_during_migration =
+ query.column_int(7);
+ debug_info.autofill_profile_added_during_migration =
+ query.column_int(8);
}
{
SQLStatement query;
@@ -926,6 +965,54 @@ bool DirectoryBackingStore::MigrateVersion72To73() {
return true;
}
+bool DirectoryBackingStore::MigrateVersion73To74() {
+ int result =
+ ExecQuery(load_dbhandle_,
+ "ALTER TABLE share_info ADD COLUMN autofill_migration_state "
+ "INT default 0");
+ if (result != SQLITE_DONE)
+ return false;
+
+ result =
+ ExecQuery(load_dbhandle_,
tim (not reviewing) 2010/12/13 19:24:33 prev line
lipalani 2010/12/14 21:05:57 Done.
+ "ALTER TABLE share_info ADD COLUMN "
+ "bookmarks_added_during_autofill_migration "
+ "INT default 0");
+
+ if (result != SQLITE_DONE)
+ return false;
+
+ result =
+ ExecQuery(load_dbhandle_,
tim (not reviewing) 2010/12/13 19:24:33 prev line
lipalani 2010/12/14 21:05:57 Done.
+ "ALTER TABLE share_info ADD COLUMN autofill_migration_time "
+ "INT default 0");
+
+ if (result != SQLITE_DONE)
+ return false;
+
+ result =
+ ExecQuery(load_dbhandle_,
tim (not reviewing) 2010/12/13 19:24:33 prev line
lipalani 2010/12/14 21:05:57 Done.
+ "ALTER TABLE share_info ADD COLUMN "
+ "autofill_entries_added_during_migration "
+ "INT default 0");
+
+ if (result != SQLITE_DONE)
+ return false;
+
+ result =
+ ExecQuery(load_dbhandle_,
tim (not reviewing) 2010/12/13 19:24:33 prev line
lipalani 2010/12/14 21:05:57 Done.
+ "ALTER TABLE share_info ADD COLUMN "
+ "autofill_profiles_added_during_migration "
+ "INT default 0");
+
+ if (result != SQLITE_DONE)
+ return false;
+
+ SetVersion(74);
+ return true;
+}
+
+
int DirectoryBackingStore::CreateTables() {
VLOG(1) << "First run, creating tables";
// Create two little tables share_version and share_info
@@ -960,6 +1047,14 @@ int DirectoryBackingStore::CreateTables() {
"?, " // db_create_time
"-2, " // next_id
"?, " // cache_guid
+ "?, " // autofill_migration_state
+ "?, " // bookmarks_added
+ // _during_autofill_migration
+ "?, " // autofill_migration_time
+ "?, " // autofill_entries
+ // _added_during_migration
+ "?, " // autofill_profiles_added
+ // _during_migration
"?);"); // notification_state
statement.bind_string(0, dir_name_); // id
statement.bind_string(1, dir_name_); // name
@@ -967,7 +1062,12 @@ int DirectoryBackingStore::CreateTables() {
statement.bind_string(3, SYNC_ENGINE_VERSION_STRING); // db_create_version
statement.bind_int(4, static_cast<int32>(time(0))); // db_create_time
statement.bind_string(5, GenerateCacheGUID()); // cache_guid
- statement.bind_blob(6, NULL, 0); // notification_state
+ statement.bind_int(6, 0); // autofill_migration_state
+ statement.bind_int(7, 0); // autofill_migration_time
+ statement.bind_int(8, 0); // bookmarks_added_during_autofill_migration
+ statement.bind_int(9, 0); // autofill_entries_added_during_migration
+ statement.bind_int(10, 0); // autofill_profiles_added_during_migration
+ statement.bind_blob(11, NULL, 0); // notification_state
result = statement.step();
}
if (result != SQLITE_DONE)
@@ -1040,7 +1140,12 @@ int DirectoryBackingStore::CreateShareInfoTable(
"db_create_version TEXT, "
"db_create_time INT, "
"next_id INT default -2, "
- "cache_guid TEXT");
+ "cache_guid TEXT, "
+ "autofill_migration_state INT default 0, "
+ "bookmarks_added_during_autofill_migration INT default 0, "
+ "autofill_migration_time INT default 0, "
+ "autofill_entries_added_during_migration INT default 0, "
+ "autofill_profiles_added_during_migration INT default 0 ");
if (with_notification_state) {
query.append(", notification_state BLOB");
}

Powered by Google App Engine
This is Rietveld 408576698