Chromium Code Reviews| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 &extensions_activity_monitor_, | 371 &extensions_activity_monitor_, |
| 372 event_handler, | 372 event_handler, |
| 373 sync_service_url, | 373 sync_service_url, |
| 374 base::Bind(&MakeHttpBridgeFactory, | 374 base::Bind(&MakeHttpBridgeFactory, |
| 375 make_scoped_refptr(profile_->GetRequestContext())), | 375 make_scoped_refptr(profile_->GetRequestContext())), |
| 376 credentials, | 376 credentials, |
| 377 &chrome_sync_notification_bridge_, | 377 &chrome_sync_notification_bridge_, |
| 378 &sync_notifier_factory_, | 378 &sync_notifier_factory_, |
| 379 delete_sync_data_folder, | 379 delete_sync_data_folder, |
| 380 sync_prefs_->GetEncryptionBootstrapToken(), | 380 sync_prefs_->GetEncryptionBootstrapToken(), |
| 381 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), | |
| 381 sync_api::SyncManager::NON_TEST, | 382 sync_api::SyncManager::NON_TEST, |
| 382 unrecoverable_error_handler, | 383 unrecoverable_error_handler, |
| 383 report_unrecoverable_error_function)); | 384 report_unrecoverable_error_function)); |
| 384 } | 385 } |
| 385 | 386 |
| 386 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { | 387 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { |
| 387 sync_thread_.message_loop()->PostTask(FROM_HERE, | 388 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 388 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), | 389 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), |
| 389 credentials)); | 390 credentials)); |
| 390 } | 391 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 713 base::Bind(&SyncBackendHost::Core::DoConfigureSyncer, | 714 base::Bind(&SyncBackendHost::Core::DoConfigureSyncer, |
| 714 core_.get(), | 715 core_.get(), |
| 715 reason, | 716 reason, |
| 716 types_to_config, | 717 types_to_config, |
| 717 routing_info, | 718 routing_info, |
| 718 ready_task, | 719 ready_task, |
| 719 retry_callback)); | 720 retry_callback)); |
| 720 } | 721 } |
| 721 | 722 |
| 722 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop( | 723 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop( |
| 724 const std::string& keystore_bootstrap_token, | |
|
rlarocque
2012/06/13 23:35:04
Is it really necessary to send the token back on e
Nicolas Zea
2012/06/15 00:42:07
Yeah, I guess the bootstrap token doesn't really r
rlarocque
2012/06/15 19:02:00
I'm not sure that's much better. Wouldn't it make
Nicolas Zea
2012/06/15 20:15:30
This is effectively the same logic used in the boo
| |
| 723 const syncable::ModelTypeSet& types_to_configure, | 725 const syncable::ModelTypeSet& types_to_configure, |
| 724 const syncable::ModelTypeSet& configured_types, | 726 const syncable::ModelTypeSet& configured_types, |
| 725 const base::Callback<void(syncable::ModelTypeSet)>& ready_task) { | 727 const base::Callback<void(syncable::ModelTypeSet)>& ready_task) { |
| 726 const syncable::ModelTypeSet failed_configuration_types = | 728 const syncable::ModelTypeSet failed_configuration_types = |
| 727 Difference(types_to_configure, configured_types); | 729 Difference(types_to_configure, configured_types); |
| 728 SDVLOG(1) | 730 SDVLOG(1) |
| 729 << "Added types: " | 731 << "Added types: " |
| 730 << syncable::ModelTypeSetToString(types_to_configure) | 732 << syncable::ModelTypeSetToString(types_to_configure) |
| 731 << ", configured types: " | 733 << ", configured types: " |
| 732 << syncable::ModelTypeSetToString(configured_types) | 734 << syncable::ModelTypeSetToString(configured_types) |
| 733 << ", failed configuration types: " | 735 << ", failed configuration types: " |
| 734 << syncable::ModelTypeSetToString(failed_configuration_types); | 736 << syncable::ModelTypeSetToString(failed_configuration_types); |
| 735 | 737 |
| 736 // Update |chrome_sync_notification_bridge_|'s enabled types here as it has | 738 // Update |chrome_sync_notification_bridge_|'s enabled types here as it has |
| 737 // to happen on the UI thread. | 739 // to happen on the UI thread. |
| 738 chrome_sync_notification_bridge_.UpdateEnabledTypes(configured_types); | 740 chrome_sync_notification_bridge_.UpdateEnabledTypes(configured_types); |
| 739 | 741 |
| 740 // Notify SyncManager (especially the notification listener) about new types. | 742 // Notify SyncManager (especially the notification listener) about new types. |
| 741 sync_thread_.message_loop()->PostTask(FROM_HERE, | 743 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 742 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), | 744 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), |
| 743 configured_types)); | 745 configured_types)); |
| 744 | 746 |
| 747 if (!keystore_bootstrap_token.empty()) { | |
| 748 DVLOG(1) << "Persisting keystore encryption bootstrap token."; | |
| 749 sync_prefs_->SetKeystoreEncryptionBootstrapToken(keystore_bootstrap_token); | |
| 750 } | |
| 751 | |
| 745 if (!ready_task.is_null()) | 752 if (!ready_task.is_null()) |
| 746 ready_task.Run(failed_configuration_types); | 753 ready_task.Run(failed_configuration_types); |
| 747 } | 754 } |
| 748 | 755 |
| 749 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( | 756 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( |
| 750 MessageLoop* sync_loop, | 757 MessageLoop* sync_loop, |
| 751 SyncBackendRegistrar* registrar, | 758 SyncBackendRegistrar* registrar, |
| 752 const ModelSafeRoutingInfo& routing_info, | 759 const ModelSafeRoutingInfo& routing_info, |
| 753 const std::vector<ModelSafeWorker*>& workers, | 760 const std::vector<ModelSafeWorker*>& workers, |
| 754 ExtensionsActivityMonitor* extensions_activity_monitor, | 761 ExtensionsActivityMonitor* extensions_activity_monitor, |
| 755 const WeakHandle<JsEventHandler>& event_handler, | 762 const WeakHandle<JsEventHandler>& event_handler, |
| 756 const GURL& service_url, | 763 const GURL& service_url, |
| 757 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, | 764 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, |
| 758 const sync_api::SyncCredentials& credentials, | 765 const sync_api::SyncCredentials& credentials, |
| 759 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, | 766 ChromeSyncNotificationBridge* chrome_sync_notification_bridge, |
| 760 sync_notifier::SyncNotifierFactory* sync_notifier_factory, | 767 sync_notifier::SyncNotifierFactory* sync_notifier_factory, |
| 761 bool delete_sync_data_folder, | 768 bool delete_sync_data_folder, |
| 762 const std::string& restored_key_for_bootstrapping, | 769 const std::string& restored_key_for_bootstrapping, |
| 770 const std::string& restored_keystore_key_for_bootstrapping, | |
| 763 sync_api::SyncManager::TestingMode testing_mode, | 771 sync_api::SyncManager::TestingMode testing_mode, |
| 764 UnrecoverableErrorHandler* unrecoverable_error_handler, | 772 UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 765 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) | 773 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) |
| 766 : sync_loop(sync_loop), | 774 : sync_loop(sync_loop), |
| 767 registrar(registrar), | 775 registrar(registrar), |
| 768 routing_info(routing_info), | 776 routing_info(routing_info), |
| 769 workers(workers), | 777 workers(workers), |
| 770 extensions_activity_monitor(extensions_activity_monitor), | 778 extensions_activity_monitor(extensions_activity_monitor), |
| 771 event_handler(event_handler), | 779 event_handler(event_handler), |
| 772 service_url(service_url), | 780 service_url(service_url), |
| 773 make_http_bridge_factory_fn(make_http_bridge_factory_fn), | 781 make_http_bridge_factory_fn(make_http_bridge_factory_fn), |
| 774 credentials(credentials), | 782 credentials(credentials), |
| 775 chrome_sync_notification_bridge(chrome_sync_notification_bridge), | 783 chrome_sync_notification_bridge(chrome_sync_notification_bridge), |
| 776 sync_notifier_factory(sync_notifier_factory), | 784 sync_notifier_factory(sync_notifier_factory), |
| 777 delete_sync_data_folder(delete_sync_data_folder), | 785 delete_sync_data_folder(delete_sync_data_folder), |
| 778 restored_key_for_bootstrapping(restored_key_for_bootstrapping), | 786 restored_key_for_bootstrapping(restored_key_for_bootstrapping), |
| 787 restored_keystore_key_for_bootstrapping( | |
| 788 restored_keystore_key_for_bootstrapping), | |
| 779 testing_mode(testing_mode), | 789 testing_mode(testing_mode), |
| 780 unrecoverable_error_handler(unrecoverable_error_handler), | 790 unrecoverable_error_handler(unrecoverable_error_handler), |
| 781 report_unrecoverable_error_function( | 791 report_unrecoverable_error_function( |
| 782 report_unrecoverable_error_function) { | 792 report_unrecoverable_error_function) { |
| 783 } | 793 } |
| 784 | 794 |
| 785 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} | 795 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} |
| 786 | 796 |
| 787 SyncBackendHost::Core::Core(const std::string& name, | 797 SyncBackendHost::Core::Core(const std::string& name, |
| 788 const FilePath& sync_data_folder_path, | 798 const FilePath& sync_data_folder_path, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1003 options.routing_info, | 1013 options.routing_info, |
| 1004 options.workers, | 1014 options.workers, |
| 1005 options.extensions_activity_monitor, | 1015 options.extensions_activity_monitor, |
| 1006 options.registrar /* as SyncManager::ChangeDelegate */, | 1016 options.registrar /* as SyncManager::ChangeDelegate */, |
| 1007 MakeUserAgentForSyncApi(), | 1017 MakeUserAgentForSyncApi(), |
| 1008 options.credentials, | 1018 options.credentials, |
| 1009 new BridgedSyncNotifier( | 1019 new BridgedSyncNotifier( |
| 1010 options.chrome_sync_notification_bridge, | 1020 options.chrome_sync_notification_bridge, |
| 1011 options.sync_notifier_factory->CreateSyncNotifier()), | 1021 options.sync_notifier_factory->CreateSyncNotifier()), |
| 1012 options.restored_key_for_bootstrapping, | 1022 options.restored_key_for_bootstrapping, |
| 1023 options.restored_keystore_key_for_bootstrapping, | |
| 1013 CommandLine::ForCurrentProcess()->HasSwitch( | 1024 CommandLine::ForCurrentProcess()->HasSwitch( |
| 1014 switches::kSyncKeystoreEncryption), | 1025 switches::kSyncKeystoreEncryption), |
| 1015 options.testing_mode, | 1026 options.testing_mode, |
| 1016 &encryptor_, | 1027 &encryptor_, |
| 1017 options.unrecoverable_error_handler, | 1028 options.unrecoverable_error_handler, |
| 1018 options.report_unrecoverable_error_function); | 1029 options.report_unrecoverable_error_function); |
| 1019 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; | 1030 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; |
| 1020 | 1031 |
| 1021 // Now check the command line to see if we need to simulate an | 1032 // Now check the command line to see if we need to simulate an |
| 1022 // unrecoverable error for testing purpose. Note the error is thrown | 1033 // unrecoverable error for testing purpose. Note the error is thrown |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 retry_callback)); | 1135 retry_callback)); |
| 1125 } | 1136 } |
| 1126 | 1137 |
| 1127 void SyncBackendHost::Core::DoFinishConfigureDataTypes( | 1138 void SyncBackendHost::Core::DoFinishConfigureDataTypes( |
| 1128 syncable::ModelTypeSet types_to_config, | 1139 syncable::ModelTypeSet types_to_config, |
| 1129 const base::Callback<void(syncable::ModelTypeSet)>& ready_task) { | 1140 const base::Callback<void(syncable::ModelTypeSet)>& ready_task) { |
| 1130 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1141 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1131 syncable::ModelTypeSet configured_types = | 1142 syncable::ModelTypeSet configured_types = |
| 1132 sync_manager_->InitialSyncEndedTypes(); | 1143 sync_manager_->InitialSyncEndedTypes(); |
| 1133 configured_types.RetainAll(types_to_config); | 1144 configured_types.RetainAll(types_to_config); |
| 1145 | |
| 1146 std::string keystore_token; | |
| 1147 sync_manager_->GetKeystoreKeyBootstrapToken(&keystore_token); | |
| 1148 | |
| 1134 host_.Call(FROM_HERE, | 1149 host_.Call(FROM_HERE, |
| 1135 &SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop, | 1150 &SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop, |
| 1151 keystore_token, | |
| 1136 types_to_config, | 1152 types_to_config, |
| 1137 configured_types, | 1153 configured_types, |
| 1138 ready_task); | 1154 ready_task); |
| 1139 } | 1155 } |
| 1140 | 1156 |
| 1141 void SyncBackendHost::Core::DoRetryConfiguration( | 1157 void SyncBackendHost::Core::DoRetryConfiguration( |
| 1142 const base::Closure& retry_callback) { | 1158 const base::Closure& retry_callback) { |
| 1143 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1159 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1144 host_.Call(FROM_HERE, | 1160 host_.Call(FROM_HERE, |
| 1145 &SyncBackendHost::RetryConfigurationOnFrontendLoop, | 1161 &SyncBackendHost::RetryConfigurationOnFrontendLoop, |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1407 FROM_HERE, | 1423 FROM_HERE, |
| 1408 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1424 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
| 1409 core_.get(), sync_thread_done_callback)); | 1425 core_.get(), sync_thread_done_callback)); |
| 1410 } | 1426 } |
| 1411 | 1427 |
| 1412 #undef SDVLOG | 1428 #undef SDVLOG |
| 1413 | 1429 |
| 1414 #undef SLOG | 1430 #undef SLOG |
| 1415 | 1431 |
| 1416 } // namespace browser_sync | 1432 } // namespace browser_sync |
| OLD | NEW |