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

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

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: 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 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 778 }
779 779
780 void SyncManagerImpl::RequestNudgeForDataTypes( 780 void SyncManagerImpl::RequestNudgeForDataTypes(
781 const tracked_objects::Location& nudge_location, 781 const tracked_objects::Location& nudge_location,
782 ModelTypeSet types) { 782 ModelTypeSet types) {
783 debug_info_event_listener_.OnNudgeFromDatatype(types.First().Get()); 783 debug_info_event_listener_.OnNudgeFromDatatype(types.First().Get());
784 784
785 scheduler_->ScheduleLocalNudge(types, nudge_location); 785 scheduler_->ScheduleLocalNudge(types, nudge_location);
786 } 786 }
787 787
788 void SyncManagerImpl::NudgeForInitialDownload(ModelType type) { 788 void SyncManagerImpl::NudgeForInitialDownload(syncer::ModelType type) {
789 DCHECK(thread_checker_.CalledOnValidThread()); 789 DCHECK(thread_checker_.CalledOnValidThread());
790 scheduler_->ScheduleInitialSyncNudge(type); 790 scheduler_->ScheduleInitialSyncNudge(type);
791 } 791 }
792 792
793 void SyncManagerImpl::NudgeForCommit(ModelType type) { 793 void SyncManagerImpl::NudgeForCommit(syncer::ModelType type) {
794 DCHECK(thread_checker_.CalledOnValidThread()); 794 DCHECK(thread_checker_.CalledOnValidThread());
795 RequestNudgeForDataTypes(FROM_HERE, ModelTypeSet(type)); 795 RequestNudgeForDataTypes(FROM_HERE, ModelTypeSet(type));
796 } 796 }
797 797
798 void SyncManagerImpl::NudgeForRefresh(ModelType type) { 798 void SyncManagerImpl::NudgeForRefresh(syncer::ModelType type) {
799 DCHECK(thread_checker_.CalledOnValidThread()); 799 DCHECK(thread_checker_.CalledOnValidThread());
800 RefreshTypes(ModelTypeSet(type)); 800 RefreshTypes(ModelTypeSet(type));
801 } 801 }
802 802
803 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) { 803 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) {
804 DCHECK(thread_checker_.CalledOnValidThread()); 804 DCHECK(thread_checker_.CalledOnValidThread());
805 // Only send an event if this is due to a cycle ending and this cycle 805 // Only send an event if this is due to a cycle ending and this cycle
806 // concludes a canonical "sync" process; that is, based on what is known 806 // concludes a canonical "sync" process; that is, based on what is known
807 // locally we are "all happy" and up to date. There may be new changes on 807 // locally we are "all happy" and up to date. There may be new changes on
808 // the server, but we'll get them on a subsequent sync. 808 // the server, but we'll get them on a subsequent sync.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 850
851 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) { 851 void SyncManagerImpl::SetInvalidatorEnabled(bool invalidator_enabled) {
852 DCHECK(thread_checker_.CalledOnValidThread()); 852 DCHECK(thread_checker_.CalledOnValidThread());
853 853
854 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled; 854 DVLOG(1) << "Invalidator enabled state is now: " << invalidator_enabled;
855 allstatus_.SetNotificationsEnabled(invalidator_enabled); 855 allstatus_.SetNotificationsEnabled(invalidator_enabled);
856 scheduler_->SetNotificationsEnabled(invalidator_enabled); 856 scheduler_->SetNotificationsEnabled(invalidator_enabled);
857 } 857 }
858 858
859 void SyncManagerImpl::OnIncomingInvalidation( 859 void SyncManagerImpl::OnIncomingInvalidation(
860 ModelType type, 860 syncer::ModelType type,
861 std::unique_ptr<InvalidationInterface> invalidation) { 861 std::unique_ptr<InvalidationInterface> invalidation) {
862 DCHECK(thread_checker_.CalledOnValidThread()); 862 DCHECK(thread_checker_.CalledOnValidThread());
863 863
864 allstatus_.IncrementNotificationsReceived(); 864 allstatus_.IncrementNotificationsReceived();
865 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), 865 scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation),
866 FROM_HERE); 866 FROM_HERE);
867 } 867 }
868 868
869 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { 869 void SyncManagerImpl::RefreshTypes(ModelTypeSet types) {
870 DCHECK(thread_checker_.CalledOnValidThread()); 870 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 10 matching lines...) Expand all
881 881
882 void SyncManagerImpl::SaveChanges() { 882 void SyncManagerImpl::SaveChanges() {
883 directory()->SaveChanges(); 883 directory()->SaveChanges();
884 } 884 }
885 885
886 UserShare* SyncManagerImpl::GetUserShare() { 886 UserShare* SyncManagerImpl::GetUserShare() {
887 DCHECK(initialized_); 887 DCHECK(initialized_);
888 return &share_; 888 return &share_;
889 } 889 }
890 890
891 std::unique_ptr<ModelTypeConnector> 891 std::unique_ptr<syncer_v2::ModelTypeConnector>
892 SyncManagerImpl::GetModelTypeConnectorProxy() { 892 SyncManagerImpl::GetModelTypeConnectorProxy() {
893 DCHECK(initialized_); 893 DCHECK(initialized_);
894 return base::MakeUnique<ModelTypeConnectorProxy>( 894 return base::MakeUnique<syncer_v2::ModelTypeConnectorProxy>(
895 base::ThreadTaskRunnerHandle::Get(), model_type_registry_->AsWeakPtr()); 895 base::ThreadTaskRunnerHandle::Get(), model_type_registry_->AsWeakPtr());
896 } 896 }
897 897
898 const std::string SyncManagerImpl::cache_guid() { 898 const std::string SyncManagerImpl::cache_guid() {
899 DCHECK(initialized_); 899 DCHECK(initialized_);
900 return directory()->cache_guid(); 900 return directory()->cache_guid();
901 } 901 }
902 902
903 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) { 903 bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) {
904 ReadTransaction trans(FROM_HERE, GetUserShare()); 904 ReadTransaction trans(FROM_HERE, GetUserShare());
905 ReadNode nigori_node(&trans); 905 ReadNode nigori_node(&trans);
906 if (nigori_node.InitTypeRoot(NIGORI) != BaseNode::INIT_OK) { 906 if (nigori_node.InitTypeRoot(NIGORI) != BaseNode::INIT_OK) {
907 DVLOG(1) << "Couldn't find Nigori node."; 907 DVLOG(1) << "Couldn't find Nigori node.";
908 return false; 908 return false;
909 } 909 }
910 bool found_experiment = false; 910 bool found_experiment = false;
911 911
912 ReadNode favicon_sync_node(&trans); 912 ReadNode favicon_sync_node(&trans);
913 if (favicon_sync_node.InitByClientTagLookup(EXPERIMENTS, kFaviconSyncTag) == 913 if (favicon_sync_node.InitByClientTagLookup(
914 BaseNode::INIT_OK) { 914 syncer::EXPERIMENTS, syncer::kFaviconSyncTag) == BaseNode::INIT_OK) {
915 experiments->favicon_sync_limit = 915 experiments->favicon_sync_limit =
916 favicon_sync_node.GetExperimentsSpecifics() 916 favicon_sync_node.GetExperimentsSpecifics()
917 .favicon_sync() 917 .favicon_sync()
918 .favicon_sync_limit(); 918 .favicon_sync_limit();
919 found_experiment = true; 919 found_experiment = true;
920 } 920 }
921 921
922 ReadNode pre_commit_update_avoidance_node(&trans); 922 ReadNode pre_commit_update_avoidance_node(&trans);
923 if (pre_commit_update_avoidance_node.InitByClientTagLookup( 923 if (pre_commit_update_avoidance_node.InitByClientTagLookup(
924 EXPERIMENTS, kPreCommitUpdateAvoidanceTag) == BaseNode::INIT_OK) { 924 syncer::EXPERIMENTS, syncer::kPreCommitUpdateAvoidanceTag) ==
925 BaseNode::INIT_OK) {
925 cycle_context_->set_server_enabled_pre_commit_update_avoidance( 926 cycle_context_->set_server_enabled_pre_commit_update_avoidance(
926 pre_commit_update_avoidance_node.GetExperimentsSpecifics() 927 pre_commit_update_avoidance_node.GetExperimentsSpecifics()
927 .pre_commit_update_avoidance() 928 .pre_commit_update_avoidance()
928 .enabled()); 929 .enabled());
929 // We don't bother setting found_experiment. The frontend doesn't need to 930 // We don't bother setting found_experiment. The frontend doesn't need to
930 // know about this. 931 // know about this.
931 } 932 }
932 933
933 ReadNode gcm_invalidations_node(&trans); 934 ReadNode gcm_invalidations_node(&trans);
934 if (gcm_invalidations_node.InitByClientTagLookup( 935 if (gcm_invalidations_node.InitByClientTagLookup(
935 EXPERIMENTS, kGCMInvalidationsTag) == BaseNode::INIT_OK) { 936 syncer::EXPERIMENTS, syncer::kGCMInvalidationsTag) ==
937 BaseNode::INIT_OK) {
936 const sync_pb::GcmInvalidationsFlags& gcm_invalidations = 938 const sync_pb::GcmInvalidationsFlags& gcm_invalidations =
937 gcm_invalidations_node.GetExperimentsSpecifics().gcm_invalidations(); 939 gcm_invalidations_node.GetExperimentsSpecifics().gcm_invalidations();
938 if (gcm_invalidations.has_enabled()) { 940 if (gcm_invalidations.has_enabled()) {
939 experiments->gcm_invalidations_enabled = gcm_invalidations.enabled(); 941 experiments->gcm_invalidations_enabled = gcm_invalidations.enabled();
940 found_experiment = true; 942 found_experiment = true;
941 } 943 }
942 } 944 }
943 945
944 return found_experiment; 946 return found_experiment;
945 } 947 }
946 948
947 bool SyncManagerImpl::HasUnsyncedItems() { 949 bool SyncManagerImpl::HasUnsyncedItems() {
948 ReadTransaction trans(FROM_HERE, GetUserShare()); 950 ReadTransaction trans(FROM_HERE, GetUserShare());
949 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 951 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
950 } 952 }
951 953
952 SyncEncryptionHandler* SyncManagerImpl::GetEncryptionHandler() { 954 SyncEncryptionHandler* SyncManagerImpl::GetEncryptionHandler() {
953 return sync_encryption_handler_.get(); 955 return sync_encryption_handler_.get();
954 } 956 }
955 957
956 std::vector<std::unique_ptr<ProtocolEvent>> 958 std::vector<std::unique_ptr<ProtocolEvent>>
957 SyncManagerImpl::GetBufferedProtocolEvents() { 959 SyncManagerImpl::GetBufferedProtocolEvents() {
958 return protocol_event_buffer_.GetBufferedProtocolEvents(); 960 return protocol_event_buffer_.GetBufferedProtocolEvents();
959 } 961 }
960 962
961 void SyncManagerImpl::RegisterDirectoryTypeDebugInfoObserver( 963 void SyncManagerImpl::RegisterDirectoryTypeDebugInfoObserver(
962 TypeDebugInfoObserver* observer) { 964 syncer::TypeDebugInfoObserver* observer) {
963 model_type_registry_->RegisterDirectoryTypeDebugInfoObserver(observer); 965 model_type_registry_->RegisterDirectoryTypeDebugInfoObserver(observer);
964 } 966 }
965 967
966 void SyncManagerImpl::UnregisterDirectoryTypeDebugInfoObserver( 968 void SyncManagerImpl::UnregisterDirectoryTypeDebugInfoObserver(
967 TypeDebugInfoObserver* observer) { 969 syncer::TypeDebugInfoObserver* observer) {
968 model_type_registry_->UnregisterDirectoryTypeDebugInfoObserver(observer); 970 model_type_registry_->UnregisterDirectoryTypeDebugInfoObserver(observer);
969 } 971 }
970 972
971 bool SyncManagerImpl::HasDirectoryTypeDebugInfoObserver( 973 bool SyncManagerImpl::HasDirectoryTypeDebugInfoObserver(
972 TypeDebugInfoObserver* observer) { 974 syncer::TypeDebugInfoObserver* observer) {
973 return model_type_registry_->HasDirectoryTypeDebugInfoObserver(observer); 975 return model_type_registry_->HasDirectoryTypeDebugInfoObserver(observer);
974 } 976 }
975 977
976 void SyncManagerImpl::RequestEmitDebugInfo() { 978 void SyncManagerImpl::RequestEmitDebugInfo() {
977 model_type_registry_->RequestEmitDebugInfo(); 979 model_type_registry_->RequestEmitDebugInfo();
978 } 980 }
979 981
980 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) { 982 void SyncManagerImpl::ClearServerData(const ClearServerDataCallback& callback) {
981 DCHECK(thread_checker_.CalledOnValidThread()); 983 DCHECK(thread_checker_.CalledOnValidThread());
982 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time()); 984 scheduler_->Start(SyncScheduler::CLEAR_SERVER_DATA_MODE, base::Time());
983 ClearParams params(callback); 985 ClearParams params(callback);
984 scheduler_->ScheduleClearServerData(params); 986 scheduler_->ScheduleClearServerData(params);
985 } 987 }
986 988
987 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, 989 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch,
988 bool empty_jar) { 990 bool empty_jar) {
989 DCHECK(thread_checker_.CalledOnValidThread()); 991 DCHECK(thread_checker_.CalledOnValidThread());
990 cycle_context_->set_cookie_jar_mismatch(account_mismatch); 992 cycle_context_->set_cookie_jar_mismatch(account_mismatch);
991 cycle_context_->set_cookie_jar_empty(empty_jar); 993 cycle_context_->set_cookie_jar_empty(empty_jar);
992 } 994 }
993 995
994 } // namespace syncer 996 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core_impl/sync_manager_impl.h ('k') | components/sync/core_impl/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698