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 = |
| 183 Directory::PersistedKernelInfo::NOT_DETERMINED; |
182 } | 184 } |
183 | 185 |
184 Directory::PersistedKernelInfo::~PersistedKernelInfo() {} | 186 Directory::PersistedKernelInfo::~PersistedKernelInfo() {} |
185 | 187 |
186 Directory::SaveChangesSnapshot::SaveChangesSnapshot() | 188 Directory::SaveChangesSnapshot::SaveChangesSnapshot() |
187 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { | 189 : kernel_info_status(KERNEL_SHARE_INFO_INVALID) { |
188 } | 190 } |
189 | 191 |
190 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {} | 192 Directory::SaveChangesSnapshot::~SaveChangesSnapshot() {} |
191 | 193 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 int64 timestamp) { | 715 int64 timestamp) { |
714 ScopedKernelLock lock(this); | 716 ScopedKernelLock lock(this); |
715 set_last_download_timestamp_unsafe(model_type, timestamp); | 717 set_last_download_timestamp_unsafe(model_type, timestamp); |
716 } | 718 } |
717 | 719 |
718 bool Directory::initial_sync_ended_for_type(ModelType type) const { | 720 bool Directory::initial_sync_ended_for_type(ModelType type) const { |
719 ScopedKernelLock lock(this); | 721 ScopedKernelLock lock(this); |
720 return kernel_->persisted_info.initial_sync_ended[type]; | 722 return kernel_->persisted_info.initial_sync_ended[type]; |
721 } | 723 } |
722 | 724 |
| 725 Directory::PersistedKernelInfo::AutofillMigrationState |
| 726 Directory::get_autofill_migration_state() const { |
| 727 ScopedKernelLock lock(this); |
| 728 return kernel_->persisted_info.autofill_migration_state; |
| 729 } |
| 730 |
| 731 AutofillMigrationDebugInfo |
| 732 Directory::get_autofill_migration_debug_info() const { |
| 733 ScopedKernelLock lock(this); |
| 734 return kernel_->persisted_info.autofill_migration_debug_info; |
| 735 } |
| 736 |
| 737 template <class T> void Directory::TestAndSet( |
| 738 T* kernel_data, const T* data_to_set) { |
| 739 if (*kernel_data != *data_to_set) { |
| 740 *kernel_data = *data_to_set; |
| 741 kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; |
| 742 } |
| 743 } |
| 744 |
| 745 void Directory::set_autofill_migration_state_debug_info( |
| 746 AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| 747 const AutofillMigrationDebugInfo& info) { |
| 748 |
| 749 ScopedKernelLock lock(this); |
| 750 switch (property_to_set) { |
| 751 case AutofillMigrationDebugInfo::MIGRATION_TIME: { |
| 752 TestAndSet<int64>( |
| 753 &kernel_->persisted_info.autofill_migration_debug_info.autofill_migrat
ion_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( |
| 787 Directory::PersistedKernelInfo::AutofillMigrationState state) { |
| 788 ScopedKernelLock lock(this); |
| 789 if (state == kernel_->persisted_info.autofill_migration_state) { |
| 790 return; |
| 791 } |
| 792 kernel_->persisted_info.autofill_migration_state = state; |
| 793 if (state == Directory::PersistedKernelInfo::MIGRATED) { |
| 794 base::Time time = base::Time::Now(); |
| 795 int64 k = 0;//time.ToTimeT(); |
| 796 kernel_->persisted_info.autofill_migration_debug_info.autofill_migration_tim
e = |
| 797 k; |
| 798 } |
| 799 kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; |
| 800 } |
| 801 |
723 void Directory::set_initial_sync_ended_for_type(ModelType type, bool x) { | 802 void Directory::set_initial_sync_ended_for_type(ModelType type, bool x) { |
724 ScopedKernelLock lock(this); | 803 ScopedKernelLock lock(this); |
725 set_initial_sync_ended_for_type_unsafe(type, x); | 804 set_initial_sync_ended_for_type_unsafe(type, x); |
726 } | 805 } |
727 | 806 |
728 void Directory::set_initial_sync_ended_for_type_unsafe(ModelType type, | 807 void Directory::set_initial_sync_ended_for_type_unsafe(ModelType type, |
729 bool x) { | 808 bool x) { |
730 if (kernel_->persisted_info.initial_sync_ended[type] == x) | 809 if (kernel_->persisted_info.initial_sync_ended[type] == x) |
731 return; | 810 return; |
732 kernel_->persisted_info.initial_sync_ended.set(type, x); | 811 kernel_->persisted_info.initial_sync_ended.set(type, x); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 | 1731 |
1653 FastDump& operator<<(FastDump& dump, const Blob& blob) { | 1732 FastDump& operator<<(FastDump& dump, const Blob& blob) { |
1654 if (blob.empty()) | 1733 if (blob.empty()) |
1655 return dump; | 1734 return dump; |
1656 string buffer(base::HexEncode(&blob[0], blob.size())); | 1735 string buffer(base::HexEncode(&blob[0], blob.size())); |
1657 dump.out_->sputn(buffer.c_str(), buffer.size()); | 1736 dump.out_->sputn(buffer.c_str(), buffer.size()); |
1658 return dump; | 1737 return dump; |
1659 } | 1738 } |
1660 | 1739 |
1661 } // namespace syncable | 1740 } // namespace syncable |
OLD | NEW |