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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 const FilePath& sync_data_folder_path, | 84 const FilePath& sync_data_folder_path, |
85 const base::WeakPtr<SyncBackendHost>& backend); | 85 const base::WeakPtr<SyncBackendHost>& backend); |
86 | 86 |
87 // SyncManager::Observer implementation. The Core just acts like an air | 87 // SyncManager::Observer implementation. The Core just acts like an air |
88 // traffic controller here, forwarding incoming messages to appropriate | 88 // traffic controller here, forwarding incoming messages to appropriate |
89 // landing threads. | 89 // landing threads. |
90 virtual void OnSyncCycleCompleted( | 90 virtual void OnSyncCycleCompleted( |
91 const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE; | 91 const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE; |
92 virtual void OnInitializationComplete( | 92 virtual void OnInitializationComplete( |
93 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 93 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
94 bool success) OVERRIDE; | 94 bool success, |
95 syncer::ModelTypeSet restored_types) OVERRIDE; | |
95 virtual void OnConnectionStatusChange( | 96 virtual void OnConnectionStatusChange( |
96 syncer::ConnectionStatus status) OVERRIDE; | 97 syncer::ConnectionStatus status) OVERRIDE; |
97 virtual void OnPassphraseRequired( | 98 virtual void OnPassphraseRequired( |
98 syncer::PassphraseRequiredReason reason, | 99 syncer::PassphraseRequiredReason reason, |
99 const sync_pb::EncryptedData& pending_keys) OVERRIDE; | 100 const sync_pb::EncryptedData& pending_keys) OVERRIDE; |
100 virtual void OnPassphraseAccepted() OVERRIDE; | 101 virtual void OnPassphraseAccepted() OVERRIDE; |
101 virtual void OnBootstrapTokenUpdated( | 102 virtual void OnBootstrapTokenUpdated( |
102 const std::string& bootstrap_token) OVERRIDE; | 103 const std::string& bootstrap_token) OVERRIDE; |
103 virtual void OnStopSyncingPermanently() OVERRIDE; | 104 virtual void OnStopSyncingPermanently() OVERRIDE; |
104 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; | 105 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 return scoped_ptr<syncer::HttpPostProviderFactory>( | 361 return scoped_ptr<syncer::HttpPostProviderFactory>( |
361 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi())); | 362 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi())); |
362 } | 363 } |
363 | 364 |
364 } // namespace | 365 } // namespace |
365 | 366 |
366 void SyncBackendHost::Initialize( | 367 void SyncBackendHost::Initialize( |
367 SyncFrontend* frontend, | 368 SyncFrontend* frontend, |
368 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 369 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
369 const GURL& sync_service_url, | 370 const GURL& sync_service_url, |
370 syncer::ModelTypeSet initial_types, | |
371 const SyncCredentials& credentials, | 371 const SyncCredentials& credentials, |
372 bool delete_sync_data_folder, | 372 bool delete_sync_data_folder, |
373 syncer::SyncManagerFactory* sync_manager_factory, | 373 syncer::SyncManagerFactory* sync_manager_factory, |
374 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 374 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
375 syncer::ReportUnrecoverableErrorFunction | 375 syncer::ReportUnrecoverableErrorFunction |
376 report_unrecoverable_error_function) { | 376 report_unrecoverable_error_function) { |
377 if (!sync_thread_.Start()) | 377 if (!sync_thread_.Start()) |
378 return; | 378 return; |
379 | 379 |
380 chrome_sync_notification_bridge_.reset( | 380 chrome_sync_notification_bridge_.reset( |
381 new ChromeSyncNotificationBridge( | 381 new ChromeSyncNotificationBridge( |
382 profile_, sync_thread_.message_loop_proxy())); | 382 profile_, sync_thread_.message_loop_proxy())); |
383 | 383 |
384 frontend_ = frontend; | 384 frontend_ = frontend; |
385 DCHECK(frontend); | 385 DCHECK(frontend); |
386 | 386 |
387 syncer::ModelTypeSet initial_types_with_nigori(initial_types); | 387 registrar_.reset(new SyncBackendRegistrar(name_, |
388 CHECK(sync_prefs_.get()); | |
389 if (sync_prefs_->HasSyncSetupCompleted()) { | |
390 initial_types_with_nigori.Put(syncer::NIGORI); | |
391 } | |
392 | |
393 registrar_.reset(new SyncBackendRegistrar(initial_types_with_nigori, | |
394 name_, | |
395 profile_, | 388 profile_, |
396 sync_thread_.message_loop())); | 389 sync_thread_.message_loop())); |
397 syncer::ModelSafeRoutingInfo routing_info; | 390 syncer::ModelSafeRoutingInfo routing_info; |
398 std::vector<syncer::ModelSafeWorker*> workers; | 391 std::vector<syncer::ModelSafeWorker*> workers; |
399 registrar_->GetModelSafeRoutingInfo(&routing_info); | 392 registrar_->GetModelSafeRoutingInfo(&routing_info); |
400 registrar_->GetWorkers(&workers); | 393 registrar_->GetWorkers(&workers); |
401 | 394 |
402 initialization_state_ = CREATING_SYNC_MANAGER; | 395 initialization_state_ = CREATING_SYNC_MANAGER; |
403 InitCore(DoInitializeOptions( | 396 InitCore(DoInitializeOptions( |
404 sync_thread_.message_loop(), | 397 sync_thread_.message_loop(), |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 core_ = NULL; // Releases reference to core_. | 585 core_ = NULL; // Releases reference to core_. |
593 } | 586 } |
594 | 587 |
595 void SyncBackendHost::ConfigureDataTypes( | 588 void SyncBackendHost::ConfigureDataTypes( |
596 syncer::ConfigureReason reason, | 589 syncer::ConfigureReason reason, |
597 syncer::ModelTypeSet types_to_add, | 590 syncer::ModelTypeSet types_to_add, |
598 syncer::ModelTypeSet types_to_remove, | 591 syncer::ModelTypeSet types_to_remove, |
599 NigoriState nigori_state, | 592 NigoriState nigori_state, |
600 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 593 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
601 const base::Callback<void()>& retry_callback) { | 594 const base::Callback<void()>& retry_callback) { |
595 // Only one configure is allowed at a time. This is guaranteed by our | |
596 // callers. The SyncBackendHost requests one configure as the backend is | |
597 // initializing and waits for it to complete. After initialization, all | |
598 // configurations will pass through the DataTypeManager, which is careful to | |
599 // never send a new configure request until the current request succeeds. | |
600 | |
601 DCHECK_GT(initialization_state_, NOT_INITIALIZED); | |
602 | |
602 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add; | 603 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add; |
603 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove; | 604 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove; |
604 if (nigori_state == WITH_NIGORI) { | 605 if (nigori_state == WITH_NIGORI) { |
605 types_to_add_with_nigori.Put(syncer::NIGORI); | 606 types_to_add_with_nigori.Put(syncer::NIGORI); |
606 types_to_remove_with_nigori.Remove(syncer::NIGORI); | 607 types_to_remove_with_nigori.Remove(syncer::NIGORI); |
607 } else { | 608 } else { |
608 types_to_add_with_nigori.Remove(syncer::NIGORI); | 609 types_to_add_with_nigori.Remove(syncer::NIGORI); |
609 types_to_remove_with_nigori.Put(syncer::NIGORI); | 610 types_to_remove_with_nigori.Put(syncer::NIGORI); |
610 } | 611 } |
611 // Only one configure is allowed at a time (DataTypeManager handles user | |
612 // changes that happen while the syncer is reconfiguring, and will only | |
613 // trigger another call to ConfigureDataTypes once the current reconfiguration | |
614 // completes). | |
615 DCHECK_GT(initialization_state_, NOT_INITIALIZED); | |
616 | 612 |
617 // The new set of enabled types is types_to_add_with_nigori + the | 613 // The SyncBackendRegistrar's routing info will be updated by adding the |
618 // previously enabled types (on restart, the preferred types are already | 614 // types_to_add_with_nigori to the list then removing |
619 // enabled) - types_to_remove_with_nigori. After reconfiguring the registrar, | 615 // types_to_remove_with_nigori. Any types which are not in either of those |
620 // the new routing info will reflect the set of enabled types. | 616 // sets will remain untouched. |
617 // | |
618 // Types which were not in the list previously are not cached locally, so we | |
619 // must ask the syncer to download them. Any newly supported datatypes will | |
620 // not have been in that routing info list, so they will be among the types | |
621 // downloaded if they are enabled. | |
622 // | |
623 // The SyncBackendRegistrar's state was initially derrived from the types | |
624 // marked initial_sync_ended when the sync database was loaded. Afterwards it | |
625 // is modified only by this function. We expect it to remain in sync with the | |
626 // backend because configuration requests are never aborted; they are retried | |
627 // until they succeed or the browser is closed. | |
628 | |
629 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes( | |
630 types_to_add_with_nigori, types_to_remove_with_nigori); | |
631 if (!types_to_download.Empty()) | |
632 types_to_download.Put(syncer::NIGORI); | |
633 | |
634 // TODO(137550): It's dangerous to configure types that have progress markers. | |
Nicolas Zea
2012/07/23 19:12:16
nit: the more common format is TODO(sync/username)
| |
635 // Types with progress markers can trigger a MIGRATION_DONE response. We are | |
636 // not prepared to handle a migration during a configure, so we must ensure | |
637 // that all our types_to_download actually contain no data before we sync | |
638 // them. | |
639 // | |
640 // The most common way to end up in this situation used to be types which had | |
641 // !initial_sync_ended, but did have some progress markers. We avoid problems | |
642 // with those types by purging the data of any such partially synced types | |
643 // soon after we load the directory. | |
644 | |
621 syncer::ModelSafeRoutingInfo routing_info; | 645 syncer::ModelSafeRoutingInfo routing_info; |
622 registrar_->ConfigureDataTypes(types_to_add_with_nigori, | |
623 types_to_remove_with_nigori); | |
624 registrar_->GetModelSafeRoutingInfo(&routing_info); | 646 registrar_->GetModelSafeRoutingInfo(&routing_info); |
625 const syncer::ModelTypeSet enabled_types = | |
626 GetRoutingInfoTypes(routing_info); | |
627 | |
628 // Figure out which types need to actually be downloaded. We pass those on | |
629 // to the syncer while it's in configuration mode so that they can be | |
630 // downloaded before we perform association. Once we switch to normal mode | |
631 // downloads will get applied normally and hit the datatype's change | |
632 // processor. | |
633 // A datatype is in need of downloading if any of the following are true: | |
634 // 1. it's enabled and initial_sync_ended is false (initial_sync_ended is | |
635 // set after applying updates, and hence is a more conservative measure | |
636 // than having a non-empty progress marker, which is set during | |
637 // StoreTimestamps). | |
638 // 2. the type is NIGORI, and any other datatype is being downloaded (nigori | |
639 // is always included if we download a datatype). | |
640 // TODO(sync): consider moving this logic onto the sync thread (perhaps | |
641 // as part of SyncManager::ConfigureSyncer). | |
642 syncer::ModelTypeSet initial_sync_ended_types = | |
643 core_->sync_manager()->InitialSyncEndedTypes(); | |
644 initial_sync_ended_types.RetainAll(enabled_types); | |
645 syncer::ModelTypeSet types_to_config = | |
646 Difference(enabled_types, initial_sync_ended_types); | |
647 if (!types_to_config.Empty() && enabled_types.Has(syncer::NIGORI)) | |
648 types_to_config.Put(syncer::NIGORI); | |
649 | 647 |
650 SDVLOG(1) << "Types " | 648 SDVLOG(1) << "Types " |
651 << syncer::ModelTypeSetToString(types_to_config) | 649 << syncer::ModelTypeSetToString(types_to_download) |
652 << " added; calling DoConfigureSyncer"; | 650 << " added; calling DoConfigureSyncer"; |
653 // TODO(zea): figure out how to bypass this call if no types are being | 651 // TODO(zea): figure out how to bypass this call if no types are being |
654 // configured and GetKey is not needed. For now we rely on determining the | 652 // configured and GetKey is not needed. For now we rely on determining the |
655 // need for GetKey as part of the SyncManager::ConfigureSyncer logic. | 653 // need for GetKey as part of the SyncManager::ConfigureSyncer logic. |
656 RequestConfigureSyncer(reason, | 654 RequestConfigureSyncer(reason, |
657 types_to_config, | 655 types_to_download, |
658 routing_info, | 656 routing_info, |
659 ready_task, | 657 ready_task, |
660 retry_callback); | 658 retry_callback); |
661 } | 659 } |
662 | 660 |
663 void SyncBackendHost::EnableEncryptEverything() { | 661 void SyncBackendHost::EnableEncryptEverything() { |
664 sync_thread_.message_loop()->PostTask(FROM_HERE, | 662 sync_thread_.message_loop()->PostTask(FROM_HERE, |
665 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, | 663 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, |
666 core_.get())); | 664 core_.get())); |
667 } | 665 } |
668 | 666 |
669 void SyncBackendHost::ActivateDataType( | 667 void SyncBackendHost::ActivateDataType( |
670 syncer::ModelType type, syncer::ModelSafeGroup group, | 668 syncer::ModelType type, syncer::ModelSafeGroup group, |
671 ChangeProcessor* change_processor) { | 669 ChangeProcessor* change_processor) { |
672 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); | 670 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); |
673 } | 671 } |
674 | 672 |
675 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) { | 673 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) { |
676 registrar_->DeactivateDataType(type); | 674 registrar_->DeactivateDataType(type); |
677 } | 675 } |
678 | 676 |
679 syncer::UserShare* SyncBackendHost::GetUserShare() const { | 677 syncer::UserShare* SyncBackendHost::GetUserShare() const { |
680 DCHECK(initialized()); | 678 DCHECK(initialized()); |
681 return core_->sync_manager()->GetUserShare(); | 679 return core_->sync_manager()->GetUserShare(); |
682 } | 680 } |
683 | 681 |
682 // Bypasses the initialized() check. | |
683 syncer::UserShare* SyncBackendHost::GetUserShareForTest() const { | |
684 return core_->sync_manager()->GetUserShare(); | |
685 } | |
686 | |
684 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { | 687 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { |
685 DCHECK(initialized()); | 688 DCHECK(initialized()); |
686 return core_->sync_manager()->GetDetailedStatus(); | 689 return core_->sync_manager()->GetDetailedStatus(); |
687 } | 690 } |
688 | 691 |
689 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const { | 692 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const { |
690 return last_snapshot_; | 693 return last_snapshot_; |
691 } | 694 } |
692 | 695 |
693 bool SyncBackendHost::HasUnsyncedItems() const { | 696 bool SyncBackendHost::HasUnsyncedItems() const { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 | 767 |
765 // Notify SyncManager (especially the notification listener) about new types. | 768 // Notify SyncManager (especially the notification listener) about new types. |
766 sync_thread_.message_loop()->PostTask(FROM_HERE, | 769 sync_thread_.message_loop()->PostTask(FROM_HERE, |
767 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), | 770 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), |
768 configured_types)); | 771 configured_types)); |
769 | 772 |
770 if (!ready_task.is_null()) | 773 if (!ready_task.is_null()) |
771 ready_task.Run(failed_configuration_types); | 774 ready_task.Run(failed_configuration_types); |
772 } | 775 } |
773 | 776 |
777 void SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( | |
778 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success, | |
779 syncer::ModelTypeSet restored_types) { | |
780 registrar_->SetInitialTypes(restored_types); | |
781 HandleInitializationCompletedOnFrontendLoop(js_backend, success); | |
782 } | |
783 | |
774 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( | 784 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( |
775 MessageLoop* sync_loop, | 785 MessageLoop* sync_loop, |
776 SyncBackendRegistrar* registrar, | 786 SyncBackendRegistrar* registrar, |
777 const syncer::ModelSafeRoutingInfo& routing_info, | 787 const syncer::ModelSafeRoutingInfo& routing_info, |
778 const std::vector<syncer::ModelSafeWorker*>& workers, | 788 const std::vector<syncer::ModelSafeWorker*>& workers, |
779 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 789 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
780 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 790 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
781 const GURL& service_url, | 791 const GURL& service_url, |
782 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, | 792 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, |
783 const syncer::SyncCredentials& credentials, | 793 const syncer::SyncCredentials& credentials, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 845 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
836 host_.Call( | 846 host_.Call( |
837 FROM_HERE, | 847 FROM_HERE, |
838 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, | 848 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, |
839 snapshot); | 849 snapshot); |
840 } | 850 } |
841 | 851 |
842 | 852 |
843 void SyncBackendHost::Core::OnInitializationComplete( | 853 void SyncBackendHost::Core::OnInitializationComplete( |
844 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 854 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
845 bool success) { | 855 bool success, |
856 const syncer::ModelTypeSet restored_types) { | |
846 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 857 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
847 host_.Call( | 858 host_.Call( |
848 FROM_HERE, | 859 FROM_HERE, |
849 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, | 860 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, |
850 js_backend, success); | 861 js_backend, success, restored_types); |
851 | 862 |
852 if (success) { | 863 if (success) { |
853 // Initialization is complete, so we can schedule recurring SaveChanges. | 864 // Initialization is complete, so we can schedule recurring SaveChanges. |
854 sync_loop_->PostTask(FROM_HERE, | 865 sync_loop_->PostTask(FROM_HERE, |
855 base::Bind(&Core::StartSavingChanges, this)); | 866 base::Bind(&Core::StartSavingChanges, this)); |
856 } | 867 } |
857 } | 868 } |
858 | 869 |
859 void SyncBackendHost::Core::OnConnectionStatusChange( | 870 void SyncBackendHost::Core::OnConnectionStatusChange( |
860 syncer::ConnectionStatus status) { | 871 syncer::ConnectionStatus status) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); | 982 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); |
972 sync_manager_->AddObserver(this); | 983 sync_manager_->AddObserver(this); |
973 success = sync_manager_->Init( | 984 success = sync_manager_->Init( |
974 sync_data_folder_path_, | 985 sync_data_folder_path_, |
975 options.event_handler, | 986 options.event_handler, |
976 options.service_url.host() + options.service_url.path(), | 987 options.service_url.host() + options.service_url.path(), |
977 options.service_url.EffectiveIntPort(), | 988 options.service_url.EffectiveIntPort(), |
978 options.service_url.SchemeIsSecure(), | 989 options.service_url.SchemeIsSecure(), |
979 BrowserThread::GetBlockingPool(), | 990 BrowserThread::GetBlockingPool(), |
980 options.make_http_bridge_factory_fn.Run().Pass(), | 991 options.make_http_bridge_factory_fn.Run().Pass(), |
981 options.routing_info, | |
982 options.workers, | 992 options.workers, |
983 options.extensions_activity_monitor, | 993 options.extensions_activity_monitor, |
984 options.registrar /* as SyncManager::ChangeDelegate */, | 994 options.registrar /* as SyncManager::ChangeDelegate */, |
985 options.credentials, | 995 options.credentials, |
986 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( | 996 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( |
987 options.chrome_sync_notification_bridge, | 997 options.chrome_sync_notification_bridge, |
988 options.sync_notifier_factory->CreateSyncNotifier())), | 998 options.sync_notifier_factory->CreateSyncNotifier())), |
989 options.restored_key_for_bootstrapping, | 999 options.restored_key_for_bootstrapping, |
990 scoped_ptr<InternalComponentsFactory>( | 1000 scoped_ptr<InternalComponentsFactory>( |
991 options.internal_components_factory), | 1001 options.internal_components_factory), |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 initialization_state_ = NOT_INITIALIZED; | 1179 initialization_state_ = NOT_INITIALIZED; |
1170 | 1180 |
1171 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1181 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1172 if (!success) { | 1182 if (!success) { |
1173 initialization_state_ = NOT_INITIALIZED; | 1183 initialization_state_ = NOT_INITIALIZED; |
1174 frontend_->OnBackendInitialized( | 1184 frontend_->OnBackendInitialized( |
1175 syncer::WeakHandle<syncer::JsBackend>(), false); | 1185 syncer::WeakHandle<syncer::JsBackend>(), false); |
1176 return; | 1186 return; |
1177 } | 1187 } |
1178 | 1188 |
1179 // If setup has completed, start off in DOWNLOADING_NIGORI so that | |
1180 // we start off by refreshing nigori. | |
1181 CHECK(sync_prefs_.get()); | |
1182 if (sync_prefs_->HasSyncSetupCompleted() && | |
1183 initialization_state_ < DOWNLOADING_NIGORI) { | |
1184 initialization_state_ = DOWNLOADING_NIGORI; | |
1185 } | |
1186 | |
1187 // Run initialization state machine. | 1189 // Run initialization state machine. |
1188 switch (initialization_state_) { | 1190 switch (initialization_state_) { |
1189 case NOT_INITIALIZED: | 1191 case NOT_INITIALIZED: |
1192 // It is essential that only the Nigori node is actually downloaded here. | |
1193 // The receipt of a MIGRATION_DONE response in this download attempt would | |
1194 // be very bad. The server is smart enough to ignore migration | |
1195 // requirements only if the source (configure reason) is properly set and | |
1196 // NIGORI is the only enabled type. | |
Nicolas Zea
2012/07/23 19:12:16
Note: as discussed offline, the server does not pr
| |
1190 initialization_state_ = DOWNLOADING_NIGORI; | 1197 initialization_state_ = DOWNLOADING_NIGORI; |
1191 ConfigureDataTypes( | 1198 ConfigureDataTypes( |
1192 syncer::CONFIGURE_REASON_NEW_CLIENT, | 1199 syncer::CONFIGURE_REASON_NEW_CLIENT, |
1193 syncer::ModelTypeSet(), | 1200 syncer::ModelTypeSet(), |
1194 syncer::ModelTypeSet(), | 1201 syncer::ModelTypeSet(), |
1195 WITH_NIGORI, | 1202 WITH_NIGORI, |
1196 // Calls back into this function. | 1203 // Calls back into this function. |
1197 base::Bind( | 1204 base::Bind( |
1198 &SyncBackendHost:: | 1205 &SyncBackendHost:: |
1199 HandleNigoriConfigurationCompletedOnFrontendLoop, | 1206 HandleNigoriConfigurationCompletedOnFrontendLoop, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1375 FROM_HERE, | 1382 FROM_HERE, |
1376 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1383 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
1377 core_.get(), sync_thread_done_callback)); | 1384 core_.get(), sync_thread_done_callback)); |
1378 } | 1385 } |
1379 | 1386 |
1380 #undef SDVLOG | 1387 #undef SDVLOG |
1381 | 1388 |
1382 #undef SLOG | 1389 #undef SLOG |
1383 | 1390 |
1384 } // namespace browser_sync | 1391 } // namespace browser_sync |
OLD | NEW |