OLD | NEW |
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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 178 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
179 scoped_ptr<HttpPostProviderFactory> post_factory, | 179 scoped_ptr<HttpPostProviderFactory> post_factory, |
180 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, | 180 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
181 const std::vector<syncer::ModelSafeWorker*>& workers, | 181 const std::vector<syncer::ModelSafeWorker*>& workers, |
182 syncer::ExtensionsActivityMonitor* | 182 syncer::ExtensionsActivityMonitor* |
183 extensions_activity_monitor, | 183 extensions_activity_monitor, |
184 SyncManager::ChangeDelegate* change_delegate, | 184 SyncManager::ChangeDelegate* change_delegate, |
185 const SyncCredentials& credentials, | 185 const SyncCredentials& credentials, |
186 scoped_ptr<syncer::SyncNotifier> sync_notifier, | 186 scoped_ptr<syncer::SyncNotifier> sync_notifier, |
187 const std::string& restored_key_for_bootstrapping, | 187 const std::string& restored_key_for_bootstrapping, |
| 188 bool keystore_encryption_enabled, |
188 SyncManager::TestingMode testing_mode, | 189 SyncManager::TestingMode testing_mode, |
189 Encryptor* encryptor, | 190 Encryptor* encryptor, |
190 UnrecoverableErrorHandler* unrecoverable_error_handler, | 191 UnrecoverableErrorHandler* unrecoverable_error_handler, |
191 ReportUnrecoverableErrorFunction | 192 ReportUnrecoverableErrorFunction |
192 report_unrecoverable_error_function); | 193 report_unrecoverable_error_function); |
193 | 194 |
194 // Sign into sync with given credentials. | 195 // Sign into sync with given credentials. |
195 // We do not verify the tokens given. After this call, the tokens are set | 196 // We do not verify the tokens given. After this call, the tokens are set |
196 // and the sync DB is open. True if successful, false if something | 197 // and the sync DB is open. True if successful, false if something |
197 // went wrong. | 198 // went wrong. |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 bool use_ssl, | 716 bool use_ssl, |
716 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 717 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
717 scoped_ptr<HttpPostProviderFactory> post_factory, | 718 scoped_ptr<HttpPostProviderFactory> post_factory, |
718 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, | 719 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
719 const std::vector<syncer::ModelSafeWorker*>& workers, | 720 const std::vector<syncer::ModelSafeWorker*>& workers, |
720 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 721 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
721 SyncManager::ChangeDelegate* change_delegate, | 722 SyncManager::ChangeDelegate* change_delegate, |
722 const SyncCredentials& credentials, | 723 const SyncCredentials& credentials, |
723 scoped_ptr<syncer::SyncNotifier> sync_notifier, | 724 scoped_ptr<syncer::SyncNotifier> sync_notifier, |
724 const std::string& restored_key_for_bootstrapping, | 725 const std::string& restored_key_for_bootstrapping, |
| 726 bool keystore_encryption_enabled, |
725 SyncManager::TestingMode testing_mode, | 727 SyncManager::TestingMode testing_mode, |
726 Encryptor* encryptor, | 728 Encryptor* encryptor, |
727 UnrecoverableErrorHandler* unrecoverable_error_handler, | 729 UnrecoverableErrorHandler* unrecoverable_error_handler, |
728 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { | 730 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { |
729 DCHECK(thread_checker_.CalledOnValidThread()); | 731 DCHECK(thread_checker_.CalledOnValidThread()); |
730 DCHECK(post_factory.get()); | 732 DCHECK(post_factory.get()); |
731 DVLOG(1) << "SyncManager starting Init..."; | 733 DVLOG(1) << "SyncManager starting Init..."; |
732 std::string server_string(sync_server_and_path); | 734 std::string server_string(sync_server_and_path); |
733 return data_->Init(database_location, | 735 return data_->Init(database_location, |
734 event_handler, | 736 event_handler, |
735 server_string, | 737 server_string, |
736 sync_server_port, | 738 sync_server_port, |
737 use_ssl, | 739 use_ssl, |
738 blocking_task_runner, | 740 blocking_task_runner, |
739 post_factory.Pass(), | 741 post_factory.Pass(), |
740 model_safe_routing_info, | 742 model_safe_routing_info, |
741 workers, | 743 workers, |
742 extensions_activity_monitor, | 744 extensions_activity_monitor, |
743 change_delegate, | 745 change_delegate, |
744 credentials, | 746 credentials, |
745 sync_notifier.Pass(), | 747 sync_notifier.Pass(), |
746 restored_key_for_bootstrapping, | 748 restored_key_for_bootstrapping, |
| 749 keystore_encryption_enabled, |
747 testing_mode, | 750 testing_mode, |
748 encryptor, | 751 encryptor, |
749 unrecoverable_error_handler, | 752 unrecoverable_error_handler, |
750 report_unrecoverable_error_function); | 753 report_unrecoverable_error_function); |
751 } | 754 } |
752 | 755 |
753 void SyncManagerImpl::UpdateCredentials(const SyncCredentials& credentials) { | 756 void SyncManagerImpl::UpdateCredentials(const SyncCredentials& credentials) { |
754 DCHECK(thread_checker_.CalledOnValidThread()); | 757 DCHECK(thread_checker_.CalledOnValidThread()); |
755 data_->UpdateCredentials(credentials); | 758 data_->UpdateCredentials(credentials); |
756 } | 759 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 DVLOG(1) << "Purging disabled types: " | 848 DVLOG(1) << "Purging disabled types: " |
846 << ModelTypeSetToString(disabled_types); | 849 << ModelTypeSetToString(disabled_types); |
847 data_->directory()->PurgeEntriesWithTypeIn(disabled_types); | 850 data_->directory()->PurgeEntriesWithTypeIn(disabled_types); |
848 } | 851 } |
849 } | 852 } |
850 | 853 |
851 // TODO(zea): set this based on whether cryptographer has keystore | 854 // TODO(zea): set this based on whether cryptographer has keystore |
852 // encryption key or not (requires opening a transaction). crbug.com/129665. | 855 // encryption key or not (requires opening a transaction). crbug.com/129665. |
853 ConfigurationParams::KeystoreKeyStatus keystore_key_status = | 856 ConfigurationParams::KeystoreKeyStatus keystore_key_status = |
854 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY; | 857 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY; |
| 858 if (data_->session_context() && |
| 859 data_->session_context()->keystore_encryption_enabled()) { |
| 860 ReadTransaction trans(FROM_HERE, GetUserShare()); |
| 861 Cryptographer* cryptographer = trans.GetCryptographer(); |
| 862 keystore_key_status = |
| 863 (cryptographer->HasKeystoreKey() ? |
| 864 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY : |
| 865 ConfigurationParams::KEYSTORE_KEY_NEEDED); |
| 866 } |
855 | 867 |
856 ConfigurationParams params(GetSourceFromReason(reason), | 868 ConfigurationParams params(GetSourceFromReason(reason), |
857 types_to_config, | 869 types_to_config, |
858 new_routing_info, | 870 new_routing_info, |
859 keystore_key_status, | 871 keystore_key_status, |
860 ready_task); | 872 ready_task); |
861 | 873 |
862 if (!data_->scheduler()) { | 874 if (!data_->scheduler()) { |
863 LOG(INFO) | 875 LOG(INFO) |
864 << "SyncManagerImpl::ConfigureSyncer: could not configure because " | 876 << "SyncManagerImpl::ConfigureSyncer: could not configure because " |
(...skipping 16 matching lines...) Expand all Loading... |
881 bool use_ssl, | 893 bool use_ssl, |
882 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 894 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
883 scoped_ptr<HttpPostProviderFactory> post_factory, | 895 scoped_ptr<HttpPostProviderFactory> post_factory, |
884 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, | 896 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
885 const std::vector<syncer::ModelSafeWorker*>& workers, | 897 const std::vector<syncer::ModelSafeWorker*>& workers, |
886 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 898 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
887 SyncManager::ChangeDelegate* change_delegate, | 899 SyncManager::ChangeDelegate* change_delegate, |
888 const SyncCredentials& credentials, | 900 const SyncCredentials& credentials, |
889 scoped_ptr<syncer::SyncNotifier> sync_notifier, | 901 scoped_ptr<syncer::SyncNotifier> sync_notifier, |
890 const std::string& restored_key_for_bootstrapping, | 902 const std::string& restored_key_for_bootstrapping, |
| 903 bool keystore_encryption_enabled, |
891 SyncManager::TestingMode testing_mode, | 904 SyncManager::TestingMode testing_mode, |
892 Encryptor* encryptor, | 905 Encryptor* encryptor, |
893 UnrecoverableErrorHandler* unrecoverable_error_handler, | 906 UnrecoverableErrorHandler* unrecoverable_error_handler, |
894 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { | 907 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { |
895 CHECK(!initialized_); | 908 CHECK(!initialized_); |
896 | 909 |
897 DCHECK(thread_checker_.CalledOnValidThread()); | 910 DCHECK(thread_checker_.CalledOnValidThread()); |
898 | 911 |
899 DVLOG(1) << "Starting SyncInternal initialization."; | 912 DVLOG(1) << "Starting SyncInternal initialization."; |
900 | 913 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 listeners.push_back(this); | 968 listeners.push_back(this); |
956 session_context_.reset(new SyncSessionContext( | 969 session_context_.reset(new SyncSessionContext( |
957 connection_manager_.get(), | 970 connection_manager_.get(), |
958 directory(), | 971 directory(), |
959 model_safe_routing_info, | 972 model_safe_routing_info, |
960 workers, | 973 workers, |
961 extensions_activity_monitor, | 974 extensions_activity_monitor, |
962 &throttled_data_type_tracker_, | 975 &throttled_data_type_tracker_, |
963 listeners, | 976 listeners, |
964 &debug_info_event_listener_, | 977 &debug_info_event_listener_, |
965 &traffic_recorder_)); | 978 &traffic_recorder_, |
| 979 keystore_encryption_enabled)); |
966 session_context()->set_account_name(credentials.email); | 980 session_context()->set_account_name(credentials.email); |
967 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer())); | 981 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer())); |
968 } | 982 } |
969 | 983 |
970 bool success = SignIn(credentials); | 984 bool success = SignIn(credentials); |
971 | 985 |
972 if (success) { | 986 if (success) { |
973 if (scheduler()) { | 987 if (scheduler()) { |
974 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); | 988 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); |
975 } | 989 } |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 int SyncManagerImpl::GetDefaultNudgeDelay() { | 2549 int SyncManagerImpl::GetDefaultNudgeDelay() { |
2536 return kDefaultNudgeDelayMilliseconds; | 2550 return kDefaultNudgeDelayMilliseconds; |
2537 } | 2551 } |
2538 | 2552 |
2539 // static. | 2553 // static. |
2540 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 2554 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
2541 return kPreferencesNudgeDelayMilliseconds; | 2555 return kPreferencesNudgeDelayMilliseconds; |
2542 } | 2556 } |
2543 | 2557 |
2544 } // namespace syncer | 2558 } // namespace syncer |
OLD | NEW |