OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync/syncable/syncable.h" | 5 #include "chrome/browser/sync/syncable/syncable.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 void Directory::init_kernel(const std::string& name) { | 172 void Directory::init_kernel(const std::string& name) { |
173 DCHECK(kernel_ == NULL); | 173 DCHECK(kernel_ == NULL); |
174 kernel_ = new Kernel(FilePath(), name, KernelLoadInfo()); | 174 kernel_ = new Kernel(FilePath(), name, KernelLoadInfo()); |
175 } | 175 } |
176 | 176 |
177 Directory::PersistedKernelInfo::PersistedKernelInfo() | 177 Directory::PersistedKernelInfo::PersistedKernelInfo() |
178 : next_id(0) { | 178 : next_id(0) { |
179 for (int i = 0; i < MODEL_TYPE_COUNT; ++i) { | 179 for (int i = 0; i < MODEL_TYPE_COUNT; ++i) { |
180 last_download_timestamp[i] = 0; | 180 last_download_timestamp[i] = 0; |
181 } | 181 } |
| 182 autofill_migration_state = NOT_DETERMINED; |
182 } | 183 } |
183 | 184 |
184 Directory::PersistedKernelInfo::~PersistedKernelInfo() {} | 185 Directory::PersistedKernelInfo::~PersistedKernelInfo() {} |
185 | 186 |
186 Directory::SaveChangesSnapshot::SaveChangesSnapshot() | 187 Directory::SaveChangesSnapshot::SaveChangesSnapshot() |
187 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { | 188 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { |
188 } | 189 } |
189 | 190 |
190 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {} | 191 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {} |
191 | 192 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 int64 timestamp) { | 714 int64 timestamp) { |
714 ScopedKernelLock lock(this); | 715 ScopedKernelLock lock(this); |
715 set_last_download_timestamp_unsafe(model_type, timestamp); | 716 set_last_download_timestamp_unsafe(model_type, timestamp); |
716 } | 717 } |
717 | 718 |
718 bool Directory::initial_sync_ended_for_type(ModelType type) const { | 719 bool Directory::initial_sync_ended_for_type(ModelType type) const { |
719 ScopedKernelLock lock(this); | 720 ScopedKernelLock lock(this); |
720 return kernel_->persisted_info.initial_sync_ended[type]; | 721 return kernel_->persisted_info.initial_sync_ended[type]; |
721 } | 722 } |
722 | 723 |
| 724 AutofillMigrationState Directory::get_autofill_migration_state() const { |
| 725 ScopedKernelLock lock(this); |
| 726 return kernel_->persisted_info.autofill_migration_state; |
| 727 } |
| 728 |
| 729 AutofillMigrationDebugInfo |
| 730 Directory::get_autofill_migration_debug_info() const { |
| 731 ScopedKernelLock lock(this); |
| 732 return kernel_->persisted_info.autofill_migration_debug_info; |
| 733 } |
| 734 |
| 735 template <class T> void Directory::TestAndSet( |
| 736 T* kernel_data, const T* data_to_set) { |
| 737 if (*kernel_data != *data_to_set) { |
| 738 *kernel_data = *data_to_set; |
| 739 kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; |
| 740 } |
| 741 } |
| 742 |
| 743 void Directory::set_autofill_migration_state_debug_info( |
| 744 AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| 745 const AutofillMigrationDebugInfo& info) { |
| 746 |
| 747 ScopedKernelLock lock(this); |
| 748 switch (property_to_set) { |
| 749 case AutofillMigrationDebugInfo::MIGRATION_TIME: { |
| 750 syncable::AutofillMigrationDebugInfo& |
| 751 debug_info = kernel_->persisted_info.autofill_migration_debug_info; |
| 752 TestAndSet<int64>( |
| 753 &debug_info.autofill_migration_time, |
| 754 &info.autofill_migration_time); |
| 755 break; |
| 756 } |
| 757 case AutofillMigrationDebugInfo::BOOKMARK_ADDED: { |
| 758 AutofillMigrationDebugInfo& debug_info = |
| 759 kernel_->persisted_info.autofill_migration_debug_info; |
| 760 TestAndSet<int>( |
| 761 &debug_info.bookmarks_added_during_migration, |
| 762 &info.bookmarks_added_during_migration); |
| 763 break; |
| 764 } |
| 765 case AutofillMigrationDebugInfo::ENTRIES_ADDED: { |
| 766 AutofillMigrationDebugInfo& debug_info = |
| 767 kernel_->persisted_info.autofill_migration_debug_info; |
| 768 TestAndSet<int>( |
| 769 &debug_info.autofill_entries_added_during_migration, |
| 770 &info.autofill_entries_added_during_migration); |
| 771 break; |
| 772 } |
| 773 case AutofillMigrationDebugInfo::PROFILES_ADDED: { |
| 774 AutofillMigrationDebugInfo& debug_info = |
| 775 kernel_->persisted_info.autofill_migration_debug_info; |
| 776 TestAndSet<int>( |
| 777 &debug_info.autofill_profile_added_during_migration, |
| 778 &info.autofill_profile_added_during_migration); |
| 779 break; |
| 780 } |
| 781 default: |
| 782 NOTREACHED(); |
| 783 } |
| 784 } |
| 785 |
| 786 void Directory::set_autofill_migration_state(AutofillMigrationState state) { |
| 787 ScopedKernelLock lock(this); |
| 788 if (state == kernel_->persisted_info.autofill_migration_state) { |
| 789 return; |
| 790 } |
| 791 kernel_->persisted_info.autofill_migration_state = state; |
| 792 if (state == MIGRATED) { |
| 793 syncable::AutofillMigrationDebugInfo& debug_info = |
| 794 kernel_->persisted_info.autofill_migration_debug_info; |
| 795 debug_info.autofill_migration_time = |
| 796 base::Time::Now().ToInternalValue(); |
| 797 } |
| 798 kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; |
| 799 } |
| 800 |
723 void Directory::set_initial_sync_ended_for_type(ModelType type, bool x) { | 801 void Directory::set_initial_sync_ended_for_type(ModelType type, bool x) { |
724 ScopedKernelLock lock(this); | 802 ScopedKernelLock lock(this); |
725 set_initial_sync_ended_for_type_unsafe(type, x); | 803 set_initial_sync_ended_for_type_unsafe(type, x); |
726 } | 804 } |
727 | 805 |
728 void Directory::set_initial_sync_ended_for_type_unsafe(ModelType type, | 806 void Directory::set_initial_sync_ended_for_type_unsafe(ModelType type, |
729 bool x) { | 807 bool x) { |
730 if (kernel_->persisted_info.initial_sync_ended[type] == x) | 808 if (kernel_->persisted_info.initial_sync_ended[type] == x) |
731 return; | 809 return; |
732 kernel_->persisted_info.initial_sync_ended.set(type, x); | 810 kernel_->persisted_info.initial_sync_ended.set(type, x); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 | 1730 |
1653 FastDump& operator<<(FastDump& dump, const Blob& blob) { | 1731 FastDump& operator<<(FastDump& dump, const Blob& blob) { |
1654 if (blob.empty()) | 1732 if (blob.empty()) |
1655 return dump; | 1733 return dump; |
1656 string buffer(base::HexEncode(&blob[0], blob.size())); | 1734 string buffer(base::HexEncode(&blob[0], blob.size())); |
1657 dump.out_->sputn(buffer.c_str(), buffer.size()); | 1735 dump.out_->sputn(buffer.c_str(), buffer.size()); |
1658 return dump; | 1736 return dump; |
1659 } | 1737 } |
1660 | 1738 |
1661 } // namespace syncable | 1739 } // namespace syncable |
OLD | NEW |