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

Side by Side Diff: components/sync/core_impl/sync_manager_impl.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Fix tools and iOS. Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/sync/core_impl/sync_manager_impl.h" 5 #include "components/sync/core_impl/sync_manager_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "components/sync/syncable/in_memory_directory_backing_store.h" 50 #include "components/sync/syncable/in_memory_directory_backing_store.h"
51 #include "components/sync/syncable/on_disk_directory_backing_store.h" 51 #include "components/sync/syncable/on_disk_directory_backing_store.h"
52 52
53 using base::TimeDelta; 53 using base::TimeDelta;
54 using sync_pb::GetUpdatesCallerInfo; 54 using sync_pb::GetUpdatesCallerInfo;
55 55
56 class GURL; 56 class GURL;
57 57
58 namespace syncer { 58 namespace syncer {
59 59
60 using syncable::ImmutableWriteTransactionInfo; 60 using syncer::syncable::ImmutableWriteTransactionInfo;
61 using syncable::SPECIFICS; 61 using syncer::syncable::SPECIFICS;
62 using syncable::UNIQUE_POSITION; 62 using syncer::syncable::UNIQUE_POSITION;
63 63
64 namespace { 64 namespace {
65 65
66 GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason( 66 GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason(
67 ConfigureReason reason) { 67 ConfigureReason reason) {
68 switch (reason) { 68 switch (reason) {
69 case CONFIGURE_REASON_RECONFIGURATION: 69 case CONFIGURE_REASON_RECONFIGURATION:
70 return GetUpdatesCallerInfo::RECONFIGURATION; 70 return GetUpdatesCallerInfo::RECONFIGURATION;
71 case CONFIGURE_REASON_MIGRATION: 71 case CONFIGURE_REASON_MIGRATION:
72 return GetUpdatesCallerInfo::MIGRATION; 72 return GetUpdatesCallerInfo::MIGRATION;
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 } 782 }
783 783
784 void SyncManagerImpl::RequestNudgeForDataTypes( 784 void SyncManagerImpl::RequestNudgeForDataTypes(
785 const tracked_objects::Location& nudge_location, 785 const tracked_objects::Location& nudge_location,
786 ModelTypeSet types) { 786 ModelTypeSet types) {
787 debug_info_event_listener_.OnNudgeFromDatatype(types.First().Get()); 787 debug_info_event_listener_.OnNudgeFromDatatype(types.First().Get());
788 788
789 scheduler_->ScheduleLocalNudge(types, nudge_location); 789 scheduler_->ScheduleLocalNudge(types, nudge_location);
790 } 790 }
791 791
792 void SyncManagerImpl::NudgeForInitialDownload(syncer::ModelType type) { 792 void SyncManagerImpl::NudgeForInitialDownload(ModelType type) {
793 DCHECK(thread_checker_.CalledOnValidThread()); 793 DCHECK(thread_checker_.CalledOnValidThread());
794 scheduler_->ScheduleInitialSyncNudge(type); 794 scheduler_->ScheduleInitialSyncNudge(type);
795 } 795 }
796 796
797 void SyncManagerImpl::NudgeForCommit(syncer::ModelType type) { 797 void SyncManagerImpl::NudgeForCommit(ModelType type) {
798 DCHECK(thread_checker_.CalledOnValidThread()); 798 DCHECK(thread_checker_.CalledOnValidThread());
799 RequestNudgeForDataTypes(FROM_HERE, ModelTypeSet(type)); 799 RequestNudgeForDataTypes(FROM_HERE, ModelTypeSet(type));
800 } 800 }
801 801
802 void SyncManagerImpl::NudgeForRefresh(syncer::ModelType type) { 802 void SyncManagerImpl::NudgeForRefresh(ModelType type) {
803 DCHECK(thread_checker_.CalledOnValidThread()); 803 DCHECK(thread_checker_.CalledOnValidThread());
804 RefreshTypes(ModelTypeSet(type)); 804 RefreshTypes(ModelTypeSet(type));
805 } 805 }
806 806
807 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) { 807 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) {
808 DCHECK(thread_checker_.CalledOnValidThread()); 808 DCHECK(thread_checker_.CalledOnValidThread());
809 // Only send an event if this is due to a cycle ending and this cycle 809 // Only send an event if this is due to a cycle ending and this cycle
810 // concludes a canonical "sync" process; that is, based on what is known 810 // concludes a canonical "sync" process; that is, based on what is known
811 // locally we are "all happy" and up to date. There may be new changes on 811 // locally we are "all happy" and up to date. There may be new changes on
812 // the server, but we'll get them on a subsequent sync. 812 // the server, but we'll get them on a subsequent sync.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 854
855 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) { 855 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) {
856 DCHECK(thread_checker_.CalledOnValidThread()); 856 DCHECK(thread_checker_.CalledOnValidThread());
857 857
858 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled; 858 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled;
859 allstatus_.SetNotificationsEnabled(invalidator_enabled); 859 allstatus_.SetNotificationsEnabled(invalidator_enabled);
860 scheduler_->SetNotificationsEnabled(invalidator_enabled); 860 scheduler_->SetNotificationsEnabled(invalidator_enabled);
861 } 861 }
862 862
863 void SyncManagerImpl::OnIncomingInvalidation( 863 void SyncManagerImpl::OnIncomingInvalidation(
864 syncer::ModelType type, 864 ModelType type,
865 std::unique_ptr<InvalidationInterface> invalidation) { 865 std::unique_ptr<InvalidationInterface> invalidation) {
866 DCHECK(thread_checker_.CalledOnValidThread()); 866 DCHECK(thread_checker_.CalledOnValidThread());
867 867
868 allstatus_.IncrementNotificationsReceived(); 868 allstatus_.IncrementNotificationsReceived();
869 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), 869 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation),
870 FROM_HERE); 870 FROM_HERE);
871 } 871 }
872 872
873 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { 873 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) {
874 DCHECK(thread_checker_.CalledOnValidThread()); 874 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 10 matching lines...) Expand all
885 885
886 void SyncManagerImpl::SaveChanges() { 886 void SyncManagerImpl::SaveChanges() {
887 directory()->SaveChanges(); 887 directory()->SaveChanges();
888 } 888 }
889 889
890 UserShare* SyncManagerImpl::GetUserShare() { 890 UserShare* SyncManagerImpl::GetUserShare() {
891 DCHECK(initialized_); 891 DCHECK(initialized_);
892 return &share_; 892 return &share_;
893 } 893 }
894 894
895 std::unique_ptr<syncer_v2::ModelTypeConnector> 895 std::unique_ptr<ModelTypeConnector>
896 SyncManagerImpl::GetModelTypeConnectorProxy() { 896 SyncManagerImpl::GetModelTypeConnectorProxy() {
897 DCHECK(initialized_); 897 DCHECK(initialized_);
898 return base::MakeUnique<syncer_v2::ModelTypeConnectorProxy>( 898 return base::MakeUnique<ModelTypeConnectorProxy>(
899 base::ThreadTaskRunnerHandle::Get(), model_type_registry_->AsWeakPtr()); 899 base::ThreadTaskRunnerHandle::Get(), model_type_registry_->AsWeakPtr());
900 } 900 }
901 901
902 const std::string SyncManagerImpl::cache_guid() { 902 const std::string SyncManagerImpl::cache_guid() {
903 DCHECK(initialized_); 903 DCHECK(initialized_);
904 return directory()->cache_guid(); 904 return directory()->cache_guid();
905 } 905 }
906 906
907 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) { 907 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) {
908 ReadTransaction trans(FROM_HERE, GetUserShare()); 908 ReadTransaction trans(FROM_HERE, GetUserShare());
909 ReadNode nigori_node(&trans); 909 ReadNode nigori_node(&trans);
910 if (nigori_node.InitTypeRoot(NIGORI) != BaseNode::INIT_OK) { 910 if (nigori_node.InitTypeRoot(NIGORI) != BaseNode::INIT_OK) {
911 DVLOG(1) << "Couldn't find Nigori node."; 911 DVLOG(1) << "Couldn't find Nigori node.";
912 return false; 912 return false;
913 } 913 }
914 bool found_experiment = false; 914 bool found_experiment = false;
915 915
916 ReadNode favicon_sync_node(&trans); 916 ReadNode favicon_sync_node(&trans);
917 if (favicon_sync_node.InitByClientTagLookup( 917 if (favicon_sync_node.InitByClientTagLookup(EXPERIMENTS, kFaviconSyncTag) ==
918 syncer::EXPERIMENTS, syncer::kFaviconSyncTag) == BaseNode::INIT_OK) { 918 BaseNode::INIT_OK) {
919 experiments->favicon_sync_limit = 919 experiments->favicon_sync_limit =
920 favicon_sync_node.GetExperimentsSpecifics() 920 favicon_sync_node.GetExperimentsSpecifics()
921 .favicon_sync() 921 .favicon_sync()
922 .favicon_sync_limit(); 922 .favicon_sync_limit();
923 found_experiment = true; 923 found_experiment = true;
924 } 924 }
925 925
926 ReadNode pre_commit_update_avoidance_node(&trans); 926 ReadNode pre_commit_update_avoidance_node(&trans);
927 if (pre_commit_update_avoidance_node.InitByClientTagLookup( 927 if (pre_commit_update_avoidance_node.InitByClientTagLookup(
928 syncer::EXPERIMENTS, syncer::kPreCommitUpdateAvoidanceTag) == 928 EXPERIMENTS, kPreCommitUpdateAvoidanceTag) == BaseNode::INIT_OK) {
929 BaseNode::INIT_OK) {
930 cycle_context_->set_server_enabled_pre_commit_update_avoidance( 929 cycle_context_->set_server_enabled_pre_commit_update_avoidance(
931 pre_commit_update_avoidance_node.GetExperimentsSpecifics() 930 pre_commit_update_avoidance_node.GetExperimentsSpecifics()
932 .pre_commit_update_avoidance() 931 .pre_commit_update_avoidance()
933 .enabled()); 932 .enabled());
934 // We don't bother setting found_experiment. The frontend doesn't need to 933 // We don't bother setting found_experiment. The frontend doesn't need to
935 // know about this. 934 // know about this.
936 } 935 }
937 936
938 ReadNode gcm_invalidations_node(&trans); 937 ReadNode gcm_invalidations_node(&trans);
939 if (gcm_invalidations_node.InitByClientTagLookup( 938 if (gcm_invalidations_node.InitByClientTagLookup(
940 syncer::EXPERIMENTS, syncer::kGCMInvalidationsTag) == 939 EXPERIMENTS, kGCMInvalidationsTag) == BaseNode::INIT_OK) {
941 BaseNode::INIT_OK) {
942 const sync_pb::GcmInvalidationsFlags& gcm_invalidations = 940 const sync_pb::GcmInvalidationsFlags& gcm_invalidations =
943 gcm_invalidations_node.GetExperimentsSpecifics().gcm_invalidations(); 941 gcm_invalidations_node.GetExperimentsSpecifics().gcm_invalidations();
944 if (gcm_invalidations.has_enabled()) { 942 if (gcm_invalidations.has_enabled()) {
945 experiments->gcm_invalidations_enabled = gcm_invalidations.enabled(); 943 experiments->gcm_invalidations_enabled = gcm_invalidations.enabled();
946 found_experiment = true; 944 found_experiment = true;
947 } 945 }
948 } 946 }
949 947
950 return found_experiment; 948 return found_experiment;
951 } 949 }
952 950
953 bool SyncManagerImpl::HasUnsyncedItems() { 951 bool SyncManagerImpl::HasUnsyncedItems() {
954 ReadTransaction trans(FROM_HERE, GetUserShare()); 952 ReadTransaction trans(FROM_HERE, GetUserShare());
955 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 953 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
956 } 954 }
957 955
958 SyncEncryptionHandler* SyncManagerImpl::GetEncryptionHandler() { 956 SyncEncryptionHandler* SyncManagerImpl::GetEncryptionHandler() {
959 return sync_encryption_handler_.get(); 957 return sync_encryption_handler_.get();
960 } 958 }
961 959
962 std::vector<std::unique_ptr<ProtocolEvent>> 960 std::vector<std::unique_ptr<ProtocolEvent>>
963 SyncManagerImpl::GetBufferedProtocolEvents() { 961 SyncManagerImpl::GetBufferedProtocolEvents() {
964 return protocol_event_buffer_.GetBufferedProtocolEvents(); 962 return protocol_event_buffer_.GetBufferedProtocolEvents();
965 } 963 }
966 964
967 void SyncManagerImpl::RegisterDirectoryTypeDebugInfoObserver( 965 void SyncManagerImpl::RegisterDirectoryTypeDebugInfoObserver(
968 syncer::TypeDebugInfoObserver* observer) { 966 TypeDebugInfoObserver* observer) {
969 model_type_registry_->RegisterDirectoryTypeDebugInfoObserver(observer); 967 model_type_registry_->RegisterDirectoryTypeDebugInfoObserver(observer);
970 } 968 }
971 969
972 void SyncManagerImpl::UnregisterDirectoryTypeDebugInfoObserver( 970 void SyncManagerImpl::UnregisterDirectoryTypeDebugInfoObserver(
973 syncer::TypeDebugInfoObserver* observer) { 971 TypeDebugInfoObserver* observer) {
974 model_type_registry_->UnregisterDirectoryTypeDebugInfoObserver(observer); 972 model_type_registry_->UnregisterDirectoryTypeDebugInfoObserver(observer);
975 } 973 }
976 974
977 bool SyncManagerImpl::HasDirectoryTypeDebugInfoObserver( 975 bool SyncManagerImpl::HasDirectoryTypeDebugInfoObserver(
978 syncer::TypeDebugInfoObserver* observer) { 976 TypeDebugInfoObserver* observer) {
979 return model_type_registry_->HasDirectoryTypeDebugInfoObserver(observer); 977 return model_type_registry_->HasDirectoryTypeDebugInfoObserver(observer);
980 } 978 }
981 979
982 void SyncManagerImpl::RequestEmitDebugInfo() { 980 void SyncManagerImpl::RequestEmitDebugInfo() {
983 model_type_registry_->RequestEmitDebugInfo(); 981 model_type_registry_->RequestEmitDebugInfo();
984 } 982 }
985 983
986 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) { 984 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) {
987 DCHECK(thread_checker_.CalledOnValidThread()); 985 DCHECK(thread_checker_.CalledOnValidThread());
988 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time()); 986 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time());
989 ClearParams params(callback); 987 ClearParams params(callback);
990 scheduler_->ScheduleClearServerData(params); 988 scheduler_->ScheduleClearServerData(params);
991 } 989 }
992 990
993 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, 991 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch,
994 bool empty_jar) { 992 bool empty_jar) {
995 DCHECK(thread_checker_.CalledOnValidThread()); 993 DCHECK(thread_checker_.CalledOnValidThread());
996 cycle_context_->set_cookie_jar_mismatch(account_mismatch); 994 cycle_context_->set_cookie_jar_mismatch(account_mismatch);
997 cycle_context_->set_cookie_jar_empty(empty_jar); 995 cycle_context_->set_cookie_jar_empty(empty_jar);
998 } 996 }
999 997
1000 } // namespace syncer 998 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698