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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 const FilePath& sync_data_folder_path, | 80 const FilePath& sync_data_folder_path, |
| 81 const base::WeakPtr<SyncBackendHost>& backend); | 81 const base::WeakPtr<SyncBackendHost>& backend); |
| 82 | 82 |
| 83 // SyncManager::Observer implementation. The Core just acts like an air | 83 // SyncManager::Observer implementation. The Core just acts like an air |
| 84 // traffic controller here, forwarding incoming messages to appropriate | 84 // traffic controller here, forwarding incoming messages to appropriate |
| 85 // landing threads. | 85 // landing threads. |
| 86 virtual void OnSyncCycleCompleted( | 86 virtual void OnSyncCycleCompleted( |
| 87 const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE; | 87 const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE; |
| 88 virtual void OnInitializationComplete( | 88 virtual void OnInitializationComplete( |
| 89 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 89 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 90 bool success) OVERRIDE; | 90 bool success, |
| 91 syncer::ModelTypeSet restored_types) OVERRIDE; | |
| 91 virtual void OnConnectionStatusChange( | 92 virtual void OnConnectionStatusChange( |
| 92 syncer::ConnectionStatus status) OVERRIDE; | 93 syncer::ConnectionStatus status) OVERRIDE; |
| 93 virtual void OnPassphraseRequired( | 94 virtual void OnPassphraseRequired( |
| 94 syncer::PassphraseRequiredReason reason, | 95 syncer::PassphraseRequiredReason reason, |
| 95 const sync_pb::EncryptedData& pending_keys) OVERRIDE; | 96 const sync_pb::EncryptedData& pending_keys) OVERRIDE; |
| 96 virtual void OnPassphraseAccepted() OVERRIDE; | 97 virtual void OnPassphraseAccepted() OVERRIDE; |
| 97 virtual void OnBootstrapTokenUpdated( | 98 virtual void OnBootstrapTokenUpdated( |
| 98 const std::string& bootstrap_token) OVERRIDE; | 99 const std::string& bootstrap_token) OVERRIDE; |
| 99 virtual void OnStopSyncingPermanently() OVERRIDE; | 100 virtual void OnStopSyncingPermanently() OVERRIDE; |
| 100 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; | 101 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 return scoped_ptr<syncer::HttpPostProviderFactory>( | 359 return scoped_ptr<syncer::HttpPostProviderFactory>( |
| 359 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi())); | 360 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi())); |
| 360 } | 361 } |
| 361 | 362 |
| 362 } // namespace | 363 } // namespace |
| 363 | 364 |
| 364 void SyncBackendHost::Initialize( | 365 void SyncBackendHost::Initialize( |
| 365 SyncFrontend* frontend, | 366 SyncFrontend* frontend, |
| 366 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 367 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 367 const GURL& sync_service_url, | 368 const GURL& sync_service_url, |
| 368 syncer::ModelTypeSet initial_types, | |
| 369 const SyncCredentials& credentials, | 369 const SyncCredentials& credentials, |
| 370 bool delete_sync_data_folder, | 370 bool delete_sync_data_folder, |
| 371 syncer::SyncManagerFactory* sync_manager_factory, | 371 syncer::SyncManagerFactory* sync_manager_factory, |
| 372 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 372 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 373 syncer::ReportUnrecoverableErrorFunction | 373 syncer::ReportUnrecoverableErrorFunction |
| 374 report_unrecoverable_error_function) { | 374 report_unrecoverable_error_function) { |
| 375 if (!sync_thread_.Start()) | 375 if (!sync_thread_.Start()) |
| 376 return; | 376 return; |
| 377 | 377 |
| 378 frontend_ = frontend; | 378 frontend_ = frontend; |
| 379 DCHECK(frontend); | 379 DCHECK(frontend); |
| 380 | 380 |
| 381 syncer::ModelTypeSet initial_types_with_nigori(initial_types); | 381 registrar_.reset(new SyncBackendRegistrar(name_, |
| 382 CHECK(sync_prefs_.get()); | |
| 383 if (sync_prefs_->HasSyncSetupCompleted()) { | |
| 384 initial_types_with_nigori.Put(syncer::NIGORI); | |
| 385 } | |
| 386 | |
| 387 registrar_.reset(new SyncBackendRegistrar(initial_types_with_nigori, | |
| 388 name_, | |
| 389 profile_, | 382 profile_, |
| 390 sync_thread_.message_loop())); | 383 sync_thread_.message_loop())); |
| 391 syncer::ModelSafeRoutingInfo routing_info; | 384 syncer::ModelSafeRoutingInfo routing_info; |
| 392 std::vector<syncer::ModelSafeWorker*> workers; | 385 std::vector<syncer::ModelSafeWorker*> workers; |
| 393 registrar_->GetModelSafeRoutingInfo(&routing_info); | 386 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 394 registrar_->GetWorkers(&workers); | 387 registrar_->GetWorkers(&workers); |
| 395 | 388 |
| 396 initialization_state_ = CREATING_SYNC_MANAGER; | 389 initialization_state_ = CREATING_SYNC_MANAGER; |
| 397 InitCore(DoInitializeOptions( | 390 InitCore(DoInitializeOptions( |
| 398 sync_thread_.message_loop(), | 391 sync_thread_.message_loop(), |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 core_ = NULL; // Releases reference to core_. | 578 core_ = NULL; // Releases reference to core_. |
| 586 } | 579 } |
| 587 | 580 |
| 588 void SyncBackendHost::ConfigureDataTypes( | 581 void SyncBackendHost::ConfigureDataTypes( |
| 589 syncer::ConfigureReason reason, | 582 syncer::ConfigureReason reason, |
| 590 syncer::ModelTypeSet types_to_add, | 583 syncer::ModelTypeSet types_to_add, |
| 591 syncer::ModelTypeSet types_to_remove, | 584 syncer::ModelTypeSet types_to_remove, |
| 592 NigoriState nigori_state, | 585 NigoriState nigori_state, |
| 593 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 586 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
| 594 const base::Callback<void()>& retry_callback) { | 587 const base::Callback<void()>& retry_callback) { |
| 588 // Only one configure is allowed at a time. This is guaranteed by our | |
| 589 // callers. The SyncBackendHost requests one configure as the backend is | |
| 590 // initializing and waits for it to complete. After initialization, all | |
| 591 // configurations will pass through the DataTypeMnaager, which is careful to | |
| 592 // never send a new configure request until the current request succeeds. | |
|
Nicolas Zea
2012/07/20 21:35:39
I think it'd be useful to also mention that the ba
rlarocque
2012/07/20 23:20:05
Why add that comment here? Is the configuration f
| |
| 593 | |
| 594 DCHECK_GT(initialization_state_, NOT_INITIALIZED); | |
| 595 | |
| 595 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add; | 596 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add; |
| 596 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove; | 597 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove; |
| 597 if (nigori_state == WITH_NIGORI) { | 598 if (nigori_state == WITH_NIGORI) { |
| 598 types_to_add_with_nigori.Put(syncer::NIGORI); | 599 types_to_add_with_nigori.Put(syncer::NIGORI); |
| 599 types_to_remove_with_nigori.Remove(syncer::NIGORI); | 600 types_to_remove_with_nigori.Remove(syncer::NIGORI); |
| 600 } else { | 601 } else { |
| 601 types_to_add_with_nigori.Remove(syncer::NIGORI); | 602 types_to_add_with_nigori.Remove(syncer::NIGORI); |
| 602 types_to_remove_with_nigori.Put(syncer::NIGORI); | 603 types_to_remove_with_nigori.Put(syncer::NIGORI); |
| 603 } | 604 } |
| 604 // Only one configure is allowed at a time (DataTypeManager handles user | |
| 605 // changes that happen while the syncer is reconfiguring, and will only | |
| 606 // trigger another call to ConfigureDataTypes once the current reconfiguration | |
| 607 // completes). | |
| 608 DCHECK_GT(initialization_state_, NOT_INITIALIZED); | |
| 609 | 605 |
| 610 // The new set of enabled types is types_to_add_with_nigori + the | 606 // The SyncBackendRegistrar's routing info will be updated by removing the |
| 611 // previously enabled types (on restart, the preferred types are already | 607 // types_to_remove_with_nigori from the list then adding |
|
Nicolas Zea
2012/07/20 21:35:39
it's actually the other way around (add, then remo
rlarocque
2012/07/23 20:50:30
Done.
| |
| 612 // enabled) - types_to_remove_with_nigori. After reconfiguring the registrar, | 608 // types_to_add_with_nigori. Any types which have are not in either of those |
|
Nicolas Zea
2012/07/20 21:35:39
which are not
rlarocque
2012/07/23 20:50:30
Done.
| |
| 613 // the new routing info will reflect the set of enabled types. | 609 // sets will remain untouched. |
| 610 // | |
| 611 // Types which were not in previously in the list are not cached locally, so | |
|
Nicolas Zea
2012/07/20 21:35:39
not in the list previously
rlarocque
2012/07/23 20:50:30
Done.
| |
| 612 // we must ask the syncer to download them. | |
| 613 // | |
| 614 // Note that the SyncBackendRegistrar's state was initially derrived from the | |
| 615 // types marked initial_sync_ended when the sync database was loaded. | |
| 616 | |
| 617 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes( | |
| 618 types_to_add_with_nigori, types_to_remove_with_nigori); | |
| 619 if (!types_to_download.Empty()) | |
| 620 types_to_download.Put(syncer::NIGORI); | |
| 621 | |
| 614 syncer::ModelSafeRoutingInfo routing_info; | 622 syncer::ModelSafeRoutingInfo routing_info; |
| 615 registrar_->ConfigureDataTypes(types_to_add_with_nigori, | |
| 616 types_to_remove_with_nigori); | |
| 617 registrar_->GetModelSafeRoutingInfo(&routing_info); | 623 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 618 const syncer::ModelTypeSet enabled_types = | |
| 619 GetRoutingInfoTypes(routing_info); | |
| 620 | |
| 621 // Figure out which types need to actually be downloaded. We pass those on | |
| 622 // to the syncer while it's in configuration mode so that they can be | |
| 623 // downloaded before we perform association. Once we switch to normal mode | |
| 624 // downloads will get applied normally and hit the datatype's change | |
| 625 // processor. | |
| 626 // A datatype is in need of downloading if any of the following are true: | |
| 627 // 1. it's enabled and initial_sync_ended is false (initial_sync_ended is | |
| 628 // set after applying updates, and hence is a more conservative measure | |
| 629 // than having a non-empty progress marker, which is set during | |
| 630 // StoreTimestamps). | |
| 631 // 2. the type is NIGORI, and any other datatype is being downloaded (nigori | |
| 632 // is always included if we download a datatype). | |
| 633 // TODO(sync): consider moving this logic onto the sync thread (perhaps | |
| 634 // as part of SyncManager::ConfigureSyncer). | |
| 635 syncer::ModelTypeSet initial_sync_ended_types = | |
| 636 core_->sync_manager()->InitialSyncEndedTypes(); | |
| 637 initial_sync_ended_types.RetainAll(enabled_types); | |
| 638 syncer::ModelTypeSet types_to_config = | |
| 639 Difference(enabled_types, initial_sync_ended_types); | |
| 640 if (!types_to_config.Empty() && enabled_types.Has(syncer::NIGORI)) | |
| 641 types_to_config.Put(syncer::NIGORI); | |
| 642 | 624 |
| 643 SDVLOG(1) << "Types " | 625 SDVLOG(1) << "Types " |
| 644 << syncer::ModelTypeSetToString(types_to_config) | 626 << syncer::ModelTypeSetToString(types_to_download) |
| 645 << " added; calling DoConfigureSyncer"; | 627 << " added; calling DoConfigureSyncer"; |
| 646 // TODO(zea): figure out how to bypass this call if no types are being | 628 // TODO(zea): figure out how to bypass this call if no types are being |
| 647 // configured and GetKey is not needed. For now we rely on determining the | 629 // configured and GetKey is not needed. For now we rely on determining the |
| 648 // need for GetKey as part of the SyncManager::ConfigureSyncer logic. | 630 // need for GetKey as part of the SyncManager::ConfigureSyncer logic. |
| 649 RequestConfigureSyncer(reason, | 631 RequestConfigureSyncer(reason, |
| 650 types_to_config, | 632 types_to_download, |
| 651 routing_info, | 633 routing_info, |
| 652 ready_task, | 634 ready_task, |
| 653 retry_callback); | 635 retry_callback); |
| 654 } | 636 } |
| 655 | 637 |
| 656 void SyncBackendHost::EnableEncryptEverything() { | 638 void SyncBackendHost::EnableEncryptEverything() { |
| 657 sync_thread_.message_loop()->PostTask(FROM_HERE, | 639 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 658 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, | 640 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, |
| 659 core_.get())); | 641 core_.get())); |
| 660 } | 642 } |
| 661 | 643 |
| 662 void SyncBackendHost::ActivateDataType( | 644 void SyncBackendHost::ActivateDataType( |
| 663 syncer::ModelType type, syncer::ModelSafeGroup group, | 645 syncer::ModelType type, syncer::ModelSafeGroup group, |
| 664 ChangeProcessor* change_processor) { | 646 ChangeProcessor* change_processor) { |
| 665 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); | 647 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); |
| 666 } | 648 } |
| 667 | 649 |
| 668 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) { | 650 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) { |
| 669 registrar_->DeactivateDataType(type); | 651 registrar_->DeactivateDataType(type); |
| 670 } | 652 } |
| 671 | 653 |
| 672 syncer::UserShare* SyncBackendHost::GetUserShare() const { | 654 syncer::UserShare* SyncBackendHost::GetUserShare() const { |
| 673 DCHECK(initialized()); | 655 DCHECK(initialized()); |
| 674 return core_->sync_manager()->GetUserShare(); | 656 return core_->sync_manager()->GetUserShare(); |
| 675 } | 657 } |
| 676 | 658 |
| 659 // Bypasses the initialized() check. | |
| 660 syncer::UserShare* SyncBackendHost::GetUserShareForTest() const { | |
|
Nicolas Zea
2012/07/20 21:35:39
I'd almost rather just get rif of DCHECK(initializ
rlarocque
2012/07/20 23:20:05
The intent of this CL is to ensure that the Profil
| |
| 661 return core_->sync_manager()->GetUserShare(); | |
| 662 } | |
| 663 | |
| 677 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { | 664 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { |
| 678 DCHECK(initialized()); | 665 DCHECK(initialized()); |
| 679 return core_->sync_manager()->GetDetailedStatus(); | 666 return core_->sync_manager()->GetDetailedStatus(); |
| 680 } | 667 } |
| 681 | 668 |
| 682 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const { | 669 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const { |
| 683 return last_snapshot_; | 670 return last_snapshot_; |
| 684 } | 671 } |
| 685 | 672 |
| 686 bool SyncBackendHost::HasUnsyncedItems() const { | 673 bool SyncBackendHost::HasUnsyncedItems() const { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 | 744 |
| 758 // Notify SyncManager (especially the notification listener) about new types. | 745 // Notify SyncManager (especially the notification listener) about new types. |
| 759 sync_thread_.message_loop()->PostTask(FROM_HERE, | 746 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 760 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), | 747 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), |
| 761 configured_types)); | 748 configured_types)); |
| 762 | 749 |
| 763 if (!ready_task.is_null()) | 750 if (!ready_task.is_null()) |
| 764 ready_task.Run(failed_configuration_types); | 751 ready_task.Run(failed_configuration_types); |
| 765 } | 752 } |
| 766 | 753 |
| 754 void SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( | |
| 755 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, | |
| 756 syncer::ModelTypeSet restored_types) { | |
| 757 registrar_->SetInitialTypes(restored_types); | |
| 758 HandleInitializationCompletedOnFrontendLoop(js_backend, success); | |
| 759 } | |
| 760 | |
| 767 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( | 761 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( |
| 768 MessageLoop* sync_loop, | 762 MessageLoop* sync_loop, |
| 769 SyncBackendRegistrar* registrar, | 763 SyncBackendRegistrar* registrar, |
| 770 const syncer::ModelSafeRoutingInfo& routing_info, | 764 const syncer::ModelSafeRoutingInfo& routing_info, |
| 771 const std::vector<syncer::ModelSafeWorker*>& workers, | 765 const std::vector<syncer::ModelSafeWorker*>& workers, |
| 772 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 766 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
| 773 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 767 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 774 const GURL& service_url, | 768 const GURL& service_url, |
| 775 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, | 769 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, |
| 776 const syncer::SyncCredentials& credentials, | 770 const syncer::SyncCredentials& credentials, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 822 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 829 host_.Call( | 823 host_.Call( |
| 830 FROM_HERE, | 824 FROM_HERE, |
| 831 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, | 825 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, |
| 832 snapshot); | 826 snapshot); |
| 833 } | 827 } |
| 834 | 828 |
| 835 | 829 |
| 836 void SyncBackendHost::Core::OnInitializationComplete( | 830 void SyncBackendHost::Core::OnInitializationComplete( |
| 837 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 831 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 838 bool success) { | 832 bool success, |
| 833 const syncer::ModelTypeSet restored_types) { | |
| 839 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 834 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 840 host_.Call( | 835 host_.Call( |
| 841 FROM_HERE, | 836 FROM_HERE, |
| 842 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, | 837 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, |
| 843 js_backend, success); | 838 js_backend, success, restored_types); |
| 844 | 839 |
| 845 if (success) { | 840 if (success) { |
| 846 // Initialization is complete, so we can schedule recurring SaveChanges. | 841 // Initialization is complete, so we can schedule recurring SaveChanges. |
| 847 sync_loop_->PostTask(FROM_HERE, | 842 sync_loop_->PostTask(FROM_HERE, |
| 848 base::Bind(&Core::StartSavingChanges, this)); | 843 base::Bind(&Core::StartSavingChanges, this)); |
| 849 } | 844 } |
| 850 } | 845 } |
| 851 | 846 |
| 852 void SyncBackendHost::Core::OnConnectionStatusChange( | 847 void SyncBackendHost::Core::OnConnectionStatusChange( |
| 853 syncer::ConnectionStatus status) { | 848 syncer::ConnectionStatus status) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 964 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); | 959 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); |
| 965 sync_manager_->AddObserver(this); | 960 sync_manager_->AddObserver(this); |
| 966 success = sync_manager_->Init( | 961 success = sync_manager_->Init( |
| 967 sync_data_folder_path_, | 962 sync_data_folder_path_, |
| 968 options.event_handler, | 963 options.event_handler, |
| 969 options.service_url.host() + options.service_url.path(), | 964 options.service_url.host() + options.service_url.path(), |
| 970 options.service_url.EffectiveIntPort(), | 965 options.service_url.EffectiveIntPort(), |
| 971 options.service_url.SchemeIsSecure(), | 966 options.service_url.SchemeIsSecure(), |
| 972 BrowserThread::GetBlockingPool(), | 967 BrowserThread::GetBlockingPool(), |
| 973 options.make_http_bridge_factory_fn.Run().Pass(), | 968 options.make_http_bridge_factory_fn.Run().Pass(), |
| 974 options.routing_info, | |
| 975 options.workers, | 969 options.workers, |
| 976 options.extensions_activity_monitor, | 970 options.extensions_activity_monitor, |
| 977 options.registrar /* as SyncManager::ChangeDelegate */, | 971 options.registrar /* as SyncManager::ChangeDelegate */, |
| 978 options.credentials, | 972 options.credentials, |
| 979 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( | 973 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( |
| 980 options.chrome_sync_notification_bridge, | 974 options.chrome_sync_notification_bridge, |
| 981 options.sync_notifier_factory->CreateSyncNotifier())), | 975 options.sync_notifier_factory->CreateSyncNotifier())), |
| 982 options.restored_key_for_bootstrapping, | 976 options.restored_key_for_bootstrapping, |
| 983 options.testing_mode, | 977 options.testing_mode, |
| 984 &encryptor_, | 978 &encryptor_, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1161 initialization_state_ = NOT_INITIALIZED; | 1155 initialization_state_ = NOT_INITIALIZED; |
| 1162 | 1156 |
| 1163 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1157 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
| 1164 if (!success) { | 1158 if (!success) { |
| 1165 initialization_state_ = NOT_INITIALIZED; | 1159 initialization_state_ = NOT_INITIALIZED; |
| 1166 frontend_->OnBackendInitialized( | 1160 frontend_->OnBackendInitialized( |
| 1167 syncer::WeakHandle<syncer::JsBackend>(), false); | 1161 syncer::WeakHandle<syncer::JsBackend>(), false); |
| 1168 return; | 1162 return; |
| 1169 } | 1163 } |
| 1170 | 1164 |
| 1171 // If setup has completed, start off in DOWNLOADING_NIGORI so that | |
| 1172 // we start off by refreshing nigori. | |
| 1173 CHECK(sync_prefs_.get()); | |
| 1174 if (sync_prefs_->HasSyncSetupCompleted() && | |
| 1175 initialization_state_ < DOWNLOADING_NIGORI) { | |
| 1176 initialization_state_ = DOWNLOADING_NIGORI; | |
| 1177 } | |
| 1178 | |
| 1179 // Run initialization state machine. | 1165 // Run initialization state machine. |
| 1180 switch (initialization_state_) { | 1166 switch (initialization_state_) { |
| 1181 case NOT_INITIALIZED: | 1167 case NOT_INITIALIZED: |
| 1182 initialization_state_ = DOWNLOADING_NIGORI; | 1168 initialization_state_ = DOWNLOADING_NIGORI; |
| 1183 ConfigureDataTypes( | 1169 ConfigureDataTypes( |
| 1184 syncer::CONFIGURE_REASON_NEW_CLIENT, | 1170 syncer::CONFIGURE_REASON_NEW_CLIENT, |
| 1185 syncer::ModelTypeSet(), | 1171 syncer::ModelTypeSet(), |
| 1186 syncer::ModelTypeSet(), | 1172 syncer::ModelTypeSet(), |
| 1187 WITH_NIGORI, | 1173 WITH_NIGORI, |
| 1188 // Calls back into this function. | 1174 // Calls back into this function. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1367 FROM_HERE, | 1353 FROM_HERE, |
| 1368 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1354 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
| 1369 core_.get(), sync_thread_done_callback)); | 1355 core_.get(), sync_thread_done_callback)); |
| 1370 } | 1356 } |
| 1371 | 1357 |
| 1372 #undef SDVLOG | 1358 #undef SDVLOG |
| 1373 | 1359 |
| 1374 #undef SLOG | 1360 #undef SLOG |
| 1375 | 1361 |
| 1376 } // namespace browser_sync | 1362 } // namespace browser_sync |
| OLD | NEW |