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

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move GetEncryptionKey logic into GetUpdates Created 8 years, 4 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 | Annotate | Revision Log
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 "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
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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 Difference( 844 Difference(
842 GetRoutingInfoTypes(data_->session_context()->routing_info()), 845 GetRoutingInfoTypes(data_->session_context()->routing_info()),
843 GetRoutingInfoTypes(new_routing_info)); 846 GetRoutingInfoTypes(new_routing_info));
844 if (!disabled_types.Empty()) { 847 if (!disabled_types.Empty()) {
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
852 // encryption key or not (requires opening a transaction). crbug.com/129665.
853 ConfigurationParams::KeystoreKeyStatus keystore_key_status =
854 ConfigurationParams::KEYSTORE_KEY_UNNECESSARY;
855
856 ConfigurationParams params(GetSourceFromReason(reason), 854 ConfigurationParams params(GetSourceFromReason(reason),
857 types_to_config, 855 types_to_config,
858 new_routing_info, 856 new_routing_info,
859 keystore_key_status,
860 ready_task); 857 ready_task);
861 858
862 if (!data_->scheduler()) { 859 if (!data_->scheduler()) {
863 LOG(INFO) 860 LOG(INFO)
864 << "SyncManagerImpl::ConfigureSyncer: could not configure because " 861 << "SyncManagerImpl::ConfigureSyncer: could not configure because "
865 << "scheduler is null"; 862 << "scheduler is null";
866 params.ready_task.Run(); 863 params.ready_task.Run();
867 return; 864 return;
868 } 865 }
869 866
(...skipping 11 matching lines...) Expand all
881 bool use_ssl, 878 bool use_ssl,
882 const scoped_refptr<base::TaskRunner>& blocking_task_runner, 879 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
883 scoped_ptr<HttpPostProviderFactory> post_factory, 880 scoped_ptr<HttpPostProviderFactory> post_factory,
884 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, 881 const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
885 const std::vector<syncer::ModelSafeWorker*>& workers, 882 const std::vector<syncer::ModelSafeWorker*>& workers,
886 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 883 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
887 SyncManager::ChangeDelegate* change_delegate, 884 SyncManager::ChangeDelegate* change_delegate,
888 const SyncCredentials& credentials, 885 const SyncCredentials& credentials,
889 scoped_ptr<syncer::SyncNotifier> sync_notifier, 886 scoped_ptr<syncer::SyncNotifier> sync_notifier,
890 const std::string& restored_key_for_bootstrapping, 887 const std::string& restored_key_for_bootstrapping,
888 bool keystore_encryption_enabled,
891 SyncManager::TestingMode testing_mode, 889 SyncManager::TestingMode testing_mode,
892 Encryptor* encryptor, 890 Encryptor* encryptor,
893 UnrecoverableErrorHandler* unrecoverable_error_handler, 891 UnrecoverableErrorHandler* unrecoverable_error_handler,
894 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { 892 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) {
895 CHECK(!initialized_); 893 CHECK(!initialized_);
896 894
897 DCHECK(thread_checker_.CalledOnValidThread()); 895 DCHECK(thread_checker_.CalledOnValidThread());
898 896
899 DVLOG(1) << "Starting SyncInternal initialization."; 897 DVLOG(1) << "Starting SyncInternal initialization.";
900 898
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 listeners.push_back(this); 953 listeners.push_back(this);
956 session_context_.reset(new SyncSessionContext( 954 session_context_.reset(new SyncSessionContext(
957 connection_manager_.get(), 955 connection_manager_.get(),
958 directory(), 956 directory(),
959 model_safe_routing_info, 957 model_safe_routing_info,
960 workers, 958 workers,
961 extensions_activity_monitor, 959 extensions_activity_monitor,
962 &throttled_data_type_tracker_, 960 &throttled_data_type_tracker_,
963 listeners, 961 listeners,
964 &debug_info_event_listener_, 962 &debug_info_event_listener_,
965 &traffic_recorder_)); 963 &traffic_recorder_,
964 keystore_encryption_enabled));
966 session_context()->set_account_name(credentials.email); 965 session_context()->set_account_name(credentials.email);
967 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer())); 966 scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer()));
968 } 967 }
969 968
970 bool success = SignIn(credentials); 969 bool success = SignIn(credentials);
971 970
972 if (success) { 971 if (success) {
973 if (scheduler()) { 972 if (scheduler()) {
974 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); 973 scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE);
975 } 974 }
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 int SyncManagerImpl::GetDefaultNudgeDelay() { 2534 int SyncManagerImpl::GetDefaultNudgeDelay() {
2536 return kDefaultNudgeDelayMilliseconds; 2535 return kDefaultNudgeDelayMilliseconds;
2537 } 2536 }
2538 2537
2539 // static. 2538 // static.
2540 int SyncManagerImpl::GetPreferencesNudgeDelay() { 2539 int SyncManagerImpl::GetPreferencesNudgeDelay() {
2541 return kPreferencesNudgeDelayMilliseconds; 2540 return kPreferencesNudgeDelayMilliseconds;
2542 } 2541 }
2543 2542
2544 } // namespace syncer 2543 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698