Chromium Code Reviews| Index: chrome/browser/sync/syncable/syncable.cc |
| diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc |
| index 903b71d22709db7b1d3c76976e0ae5bfb48ab05d..9a6ced6ec3b86eecb9fcb93299fe25f56a2acc91 100644 |
| --- a/chrome/browser/sync/syncable/syncable.cc |
| +++ b/chrome/browser/sync/syncable/syncable.cc |
| @@ -179,6 +179,7 @@ Directory::PersistedKernelInfo::PersistedKernelInfo() |
| for (int i = 0; i < MODEL_TYPE_COUNT; ++i) { |
| last_download_timestamp[i] = 0; |
| } |
| + autofill_migration_state = NOT_DETERMINED; |
| } |
| Directory::PersistedKernelInfo::~PersistedKernelInfo() {} |
| @@ -720,6 +721,83 @@ bool Directory::initial_sync_ended_for_type(ModelType type) const { |
| return kernel_->persisted_info.initial_sync_ended[type]; |
| } |
| +AutofillMigrationState Directory::get_autofill_migration_state() const { |
| + ScopedKernelLock lock(this); |
| + return kernel_->persisted_info.autofill_migration_state; |
| +} |
| + |
| +AutofillMigrationDebugInfo |
| + Directory::get_autofill_migration_debug_info() const { |
| + ScopedKernelLock lock(this); |
| + return kernel_->persisted_info.autofill_migration_debug_info; |
| +} |
| + |
| +template <class T> void Directory::TestAndSet( |
| + T* kernel_data, const T* data_to_set) { |
| + if (*kernel_data != *data_to_set) { |
| + *kernel_data = *data_to_set; |
| + kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; |
| + } |
| +} |
| + |
| +void Directory::set_autofill_migration_state_debug_info( |
| + AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| + const AutofillMigrationDebugInfo& info) { |
| + |
| + ScopedKernelLock lock(this); |
| + switch (property_to_set) { |
| + case AutofillMigrationDebugInfo::MIGRATION_TIME: { |
| + syncable::AutofillMigrationDebugInfo& |
| + debug_info = kernel_->persisted_info.autofill_migration_debug_info; |
| + TestAndSet<int64>( |
| + &debug_info.autofill_migration_time, |
| + &info.autofill_migration_time); |
| + break; |
| + } |
| + case AutofillMigrationDebugInfo::BOOKMARK_ADDED: { |
| + AutofillMigrationDebugInfo& debug_info = |
| + kernel_->persisted_info.autofill_migration_debug_info; |
| + TestAndSet<int>( |
| + &debug_info.bookmarks_added_during_migration, |
| + &info.bookmarks_added_during_migration); |
| + break; |
| + } |
| + case AutofillMigrationDebugInfo::ENTRIES_ADDED: { |
| + AutofillMigrationDebugInfo& debug_info = |
| + kernel_->persisted_info.autofill_migration_debug_info; |
| + TestAndSet<int>( |
| + &debug_info.autofill_entries_added_during_migration, |
| + &info.autofill_entries_added_during_migration); |
| + break; |
| + } |
| + case AutofillMigrationDebugInfo::PROFILES_ADDED: { |
| + AutofillMigrationDebugInfo& debug_info = |
| + kernel_->persisted_info.autofill_migration_debug_info; |
| + TestAndSet<int>( |
| + &debug_info.autofill_profile_added_during_migration, |
| + &info.autofill_profile_added_during_migration); |
| + break; |
| + } |
| + default: |
| + NOTREACHED(); |
| + } |
| +} |
| + |
| +void Directory::set_autofill_migration_state(AutofillMigrationState state) { |
| + ScopedKernelLock lock(this); |
| + if (state == kernel_->persisted_info.autofill_migration_state) { |
| + return; |
| + } |
| + kernel_->persisted_info.autofill_migration_state = state; |
| + if (state == MIGRATED) { |
| + syncable::AutofillMigrationDebugInfo& debug_info = |
| + kernel_->persisted_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.
|
| + debug_info.autofill_migration_time = |
| + base::Time::Now().ToInternalValue(); |
|
tim (not reviewing)
2010/12/13 19:24:33
indent 4 spaces
lipalani
2010/12/14 21:05:57
Done.
|
| + } |
| + kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; |
| +} |
| + |
| void Directory::set_initial_sync_ended_for_type(ModelType type, bool x) { |
| ScopedKernelLock lock(this); |
| set_initial_sync_ended_for_type_unsafe(type, x); |