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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 10804039: Make SyncBackendRegistrar aware of loaded data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better comments Created 8 years, 5 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 "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
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
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
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 removing the
618 // previously enabled types (on restart, the preferred types are already 614 // types_to_remove_with_nigori from the list then adding
Nicolas Zea 2012/07/23 20:47:15 add then remove.
rlarocque 2012/07/23 23:16:10 You mentioned this in your first set of comments,
619 // enabled) - types_to_remove_with_nigori. After reconfiguring the registrar, 615 // types_to_add_with_nigori. Any types which are not in either of those sets
620 // the new routing info will reflect the set of enabled types. 616 // will remain untouched.
617 //
618 // Types which were not in the list previously are not cached locally, so we
Nicolas Zea 2012/07/23 20:47:15 Cached seems kind of ambiguous. Perhaps just say a
rlarocque 2012/07/23 23:16:10 Done.
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
Nicolas Zea 2012/07/23 20:47:15 derrived ->derived
rlarocque 2012/07/23 23:16:10 Done.
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(sync): crbug.com/137550.
635 // It's dangerous to configure types that have progress markers. Types with
636 // progress markers can trigger a MIGRATION_DONE response. We are not
637 // prepared to handle a migration during a configure, so we must ensure that
638 // all our types_to_download actually contain no data before we sync 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 //
645 // Another possible scenario is that we have newly supported or newly enabled
646 // data types being downloaded here but the nigori type, which is always
647 // included in any GetUpdates request, requires migration. The server has
648 // code to detect this scenario based on the configure reason, the fact that
649 // the nigori type is the only requested type which requires migration, and
650 // that the requested types list includes at least one non-nigori type. It
651 // will not send a MIGRATION_DONE response in that case. We still need to be
652 // careful to not send progress markers for non-nigori types, though. If a
653 // non-nigori type in the request requires migration, a MIGRATION_DONE
654 // response will be sent.
655
621 syncer::ModelSafeRoutingInfo routing_info; 656 syncer::ModelSafeRoutingInfo routing_info;
622 registrar_->ConfigureDataTypes(types_to_add_with_nigori,
623 types_to_remove_with_nigori);
624 registrar_->GetModelSafeRoutingInfo(&routing_info); 657 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 658
650 SDVLOG(1) << "Types " 659 SDVLOG(1) << "Types "
651 << syncer::ModelTypeSetToString(types_to_config) 660 << syncer::ModelTypeSetToString(types_to_download)
652 << " added; calling DoConfigureSyncer"; 661 << " added; calling DoConfigureSyncer";
653 // TODO(zea): figure out how to bypass this call if no types are being 662 // 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 663 // configured and GetKey is not needed. For now we rely on determining the
655 // need for GetKey as part of the SyncManager::ConfigureSyncer logic. 664 // need for GetKey as part of the SyncManager::ConfigureSyncer logic.
656 RequestConfigureSyncer(reason, 665 RequestConfigureSyncer(reason,
657 types_to_config, 666 types_to_download,
658 routing_info, 667 routing_info,
659 ready_task, 668 ready_task,
660 retry_callback); 669 retry_callback);
661 } 670 }
662 671
663 void SyncBackendHost::EnableEncryptEverything() { 672 void SyncBackendHost::EnableEncryptEverything() {
664 sync_thread_.message_loop()->PostTask(FROM_HERE, 673 sync_thread_.message_loop()->PostTask(FROM_HERE,
665 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, 674 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything,
666 core_.get())); 675 core_.get()));
667 } 676 }
668 677
669 void SyncBackendHost::ActivateDataType( 678 void SyncBackendHost::ActivateDataType(
670 syncer::ModelType type, syncer::ModelSafeGroup group, 679 syncer::ModelType type, syncer::ModelSafeGroup group,
671 ChangeProcessor* change_processor) { 680 ChangeProcessor* change_processor) {
672 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); 681 registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
673 } 682 }
674 683
675 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) { 684 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) {
676 registrar_->DeactivateDataType(type); 685 registrar_->DeactivateDataType(type);
677 } 686 }
678 687
679 syncer::UserShare* SyncBackendHost::GetUserShare() const { 688 syncer::UserShare* SyncBackendHost::GetUserShare() const {
680 DCHECK(initialized()); 689 DCHECK(initialized());
681 return core_->sync_manager()->GetUserShare(); 690 return core_->sync_manager()->GetUserShare();
682 } 691 }
683 692
693 // Bypasses the initialized() check.
694 syncer::UserShare* SyncBackendHost::GetUserShareForTest() const {
695 return core_->sync_manager()->GetUserShare();
696 }
697
684 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { 698 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() {
685 DCHECK(initialized()); 699 DCHECK(initialized());
686 return core_->sync_manager()->GetDetailedStatus(); 700 return core_->sync_manager()->GetDetailedStatus();
687 } 701 }
688 702
689 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const { 703 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const {
690 return last_snapshot_; 704 return last_snapshot_;
691 } 705 }
692 706
693 bool SyncBackendHost::HasUnsyncedItems() const { 707 bool SyncBackendHost::HasUnsyncedItems() const {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 778
765 // Notify SyncManager (especially the notification listener) about new types. 779 // Notify SyncManager (especially the notification listener) about new types.
766 sync_thread_.message_loop()->PostTask(FROM_HERE, 780 sync_thread_.message_loop()->PostTask(FROM_HERE,
767 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(), 781 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get(),
768 configured_types)); 782 configured_types));
769 783
770 if (!ready_task.is_null()) 784 if (!ready_task.is_null())
771 ready_task.Run(failed_configuration_types); 785 ready_task.Run(failed_configuration_types);
772 } 786 }
773 787
788 void SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop(
789 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
790 syncer::ModelTypeSet restored_types) {
791 registrar_->SetInitialTypes(restored_types);
792 HandleInitializationCompletedOnFrontendLoop(js_backend, success);
793 }
794
774 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( 795 SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
775 MessageLoop* sync_loop, 796 MessageLoop* sync_loop,
776 SyncBackendRegistrar* registrar, 797 SyncBackendRegistrar* registrar,
777 const syncer::ModelSafeRoutingInfo& routing_info, 798 const syncer::ModelSafeRoutingInfo& routing_info,
778 const std::vector<syncer::ModelSafeWorker*>& workers, 799 const std::vector<syncer::ModelSafeWorker*>& workers,
779 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 800 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
780 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 801 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
781 const GURL& service_url, 802 const GURL& service_url,
782 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 803 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
783 const syncer::SyncCredentials& credentials, 804 const syncer::SyncCredentials& credentials,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 DCHECK_EQ(MessageLoop::current(), sync_loop_); 856 DCHECK_EQ(MessageLoop::current(), sync_loop_);
836 host_.Call( 857 host_.Call(
837 FROM_HERE, 858 FROM_HERE,
838 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, 859 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop,
839 snapshot); 860 snapshot);
840 } 861 }
841 862
842 863
843 void SyncBackendHost::Core::OnInitializationComplete( 864 void SyncBackendHost::Core::OnInitializationComplete(
844 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 865 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
845 bool success) { 866 bool success,
867 const syncer::ModelTypeSet restored_types) {
846 DCHECK_EQ(MessageLoop::current(), sync_loop_); 868 DCHECK_EQ(MessageLoop::current(), sync_loop_);
847 host_.Call( 869 host_.Call(
848 FROM_HERE, 870 FROM_HERE,
849 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, 871 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop,
850 js_backend, success); 872 js_backend, success, restored_types);
851 873
852 if (success) { 874 if (success) {
853 // Initialization is complete, so we can schedule recurring SaveChanges. 875 // Initialization is complete, so we can schedule recurring SaveChanges.
854 sync_loop_->PostTask(FROM_HERE, 876 sync_loop_->PostTask(FROM_HERE,
855 base::Bind(&Core::StartSavingChanges, this)); 877 base::Bind(&Core::StartSavingChanges, this));
856 } 878 }
857 } 879 }
858 880
859 void SyncBackendHost::Core::OnConnectionStatusChange( 881 void SyncBackendHost::Core::OnConnectionStatusChange(
860 syncer::ConnectionStatus status) { 882 syncer::ConnectionStatus status) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); 993 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_);
972 sync_manager_->AddObserver(this); 994 sync_manager_->AddObserver(this);
973 success = sync_manager_->Init( 995 success = sync_manager_->Init(
974 sync_data_folder_path_, 996 sync_data_folder_path_,
975 options.event_handler, 997 options.event_handler,
976 options.service_url.host() + options.service_url.path(), 998 options.service_url.host() + options.service_url.path(),
977 options.service_url.EffectiveIntPort(), 999 options.service_url.EffectiveIntPort(),
978 options.service_url.SchemeIsSecure(), 1000 options.service_url.SchemeIsSecure(),
979 BrowserThread::GetBlockingPool(), 1001 BrowserThread::GetBlockingPool(),
980 options.make_http_bridge_factory_fn.Run().Pass(), 1002 options.make_http_bridge_factory_fn.Run().Pass(),
981 options.routing_info,
982 options.workers, 1003 options.workers,
983 options.extensions_activity_monitor, 1004 options.extensions_activity_monitor,
984 options.registrar /* as SyncManager::ChangeDelegate */, 1005 options.registrar /* as SyncManager::ChangeDelegate */,
985 options.credentials, 1006 options.credentials,
986 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( 1007 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier(
987 options.chrome_sync_notification_bridge, 1008 options.chrome_sync_notification_bridge,
988 options.sync_notifier_factory->CreateSyncNotifier())), 1009 options.sync_notifier_factory->CreateSyncNotifier())),
989 options.restored_key_for_bootstrapping, 1010 options.restored_key_for_bootstrapping,
990 scoped_ptr<InternalComponentsFactory>( 1011 scoped_ptr<InternalComponentsFactory>(
991 options.internal_components_factory), 1012 options.internal_components_factory),
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 initialization_state_ = NOT_INITIALIZED; 1190 initialization_state_ = NOT_INITIALIZED;
1170 1191
1171 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 1192 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
1172 if (!success) { 1193 if (!success) {
1173 initialization_state_ = NOT_INITIALIZED; 1194 initialization_state_ = NOT_INITIALIZED;
1174 frontend_->OnBackendInitialized( 1195 frontend_->OnBackendInitialized(
1175 syncer::WeakHandle<syncer::JsBackend>(), false); 1196 syncer::WeakHandle<syncer::JsBackend>(), false);
1176 return; 1197 return;
1177 } 1198 }
1178 1199
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. 1200 // Run initialization state machine.
1188 switch (initialization_state_) { 1201 switch (initialization_state_) {
1189 case NOT_INITIALIZED: 1202 case NOT_INITIALIZED:
1203 // This configuration should result in a download request if the nigori
1204 // type's initial_sync_ended bit is unset. If the download request
1205 // contains progress markers, there is a risk that the server will try to
1206 // trigger migration. That would be disastrous, so we must rely on the
1207 // backend to ensure that this type never has both progress markers and
Nicolas Zea 2012/07/23 20:47:15 did you mean rely on the sync manager purging? Sin
rlarocque 2012/07/23 23:16:10 I'm using "backend" as a generic term to refer to
1208 // !initial_sync_ended.
1190 initialization_state_ = DOWNLOADING_NIGORI; 1209 initialization_state_ = DOWNLOADING_NIGORI;
1191 ConfigureDataTypes( 1210 ConfigureDataTypes(
1192 syncer::CONFIGURE_REASON_NEW_CLIENT, 1211 syncer::CONFIGURE_REASON_NEW_CLIENT,
1193 syncer::ModelTypeSet(), 1212 syncer::ModelTypeSet(),
1194 syncer::ModelTypeSet(), 1213 syncer::ModelTypeSet(),
1195 WITH_NIGORI, 1214 WITH_NIGORI,
1196 // Calls back into this function. 1215 // Calls back into this function.
1197 base::Bind( 1216 base::Bind(
1198 &SyncBackendHost:: 1217 &SyncBackendHost::
1199 HandleNigoriConfigurationCompletedOnFrontendLoop, 1218 HandleNigoriConfigurationCompletedOnFrontendLoop,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 FROM_HERE, 1394 FROM_HERE,
1376 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1395 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1377 core_.get(), sync_thread_done_callback)); 1396 core_.get(), sync_thread_done_callback));
1378 } 1397 }
1379 1398
1380 #undef SDVLOG 1399 #undef SDVLOG
1381 1400
1382 #undef SLOG 1401 #undef SLOG
1383 1402
1384 } // namespace browser_sync 1403 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698