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

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: Rebase 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 "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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return scoped_ptr<syncer::HttpPostProviderFactory>( 363 return scoped_ptr<syncer::HttpPostProviderFactory>(
363 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi())); 364 new syncer::HttpBridgeFactory(getter, MakeUserAgentForSyncApi()));
364 } 365 }
365 366
366 } // namespace 367 } // namespace
367 368
368 void SyncBackendHost::Initialize( 369 void SyncBackendHost::Initialize(
369 SyncFrontend* frontend, 370 SyncFrontend* frontend,
370 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 371 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
371 const GURL& sync_service_url, 372 const GURL& sync_service_url,
372 syncer::ModelTypeSet initial_types,
373 const SyncCredentials& credentials, 373 const SyncCredentials& credentials,
374 bool delete_sync_data_folder, 374 bool delete_sync_data_folder,
375 syncer::SyncManagerFactory* sync_manager_factory, 375 syncer::SyncManagerFactory* sync_manager_factory,
376 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, 376 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
377 syncer::ReportUnrecoverableErrorFunction 377 syncer::ReportUnrecoverableErrorFunction
378 report_unrecoverable_error_function) { 378 report_unrecoverable_error_function) {
379 if (!sync_thread_.Start()) 379 if (!sync_thread_.Start())
380 return; 380 return;
381 381
382 chrome_sync_notification_bridge_.reset( 382 chrome_sync_notification_bridge_.reset(
383 new ChromeSyncNotificationBridge( 383 new ChromeSyncNotificationBridge(
384 profile_, sync_thread_.message_loop_proxy())); 384 profile_, sync_thread_.message_loop_proxy()));
385 385
386 frontend_ = frontend; 386 frontend_ = frontend;
387 DCHECK(frontend); 387 DCHECK(frontend);
388 388
389 syncer::ModelTypeSet initial_types_with_nigori(initial_types); 389 registrar_.reset(new SyncBackendRegistrar(name_,
390 CHECK(sync_prefs_.get());
391 if (sync_prefs_->HasSyncSetupCompleted()) {
392 initial_types_with_nigori.Put(syncer::NIGORI);
393 }
394
395 registrar_.reset(new SyncBackendRegistrar(initial_types_with_nigori,
396 name_,
397 profile_, 390 profile_,
398 sync_thread_.message_loop())); 391 sync_thread_.message_loop()));
399 syncer::ModelSafeRoutingInfo routing_info; 392 syncer::ModelSafeRoutingInfo routing_info;
400 std::vector<syncer::ModelSafeWorker*> workers; 393 std::vector<syncer::ModelSafeWorker*> workers;
401 registrar_->GetModelSafeRoutingInfo(&routing_info); 394 registrar_->GetModelSafeRoutingInfo(&routing_info);
402 registrar_->GetWorkers(&workers); 395 registrar_->GetWorkers(&workers);
403 396
404 initialization_state_ = CREATING_SYNC_MANAGER; 397 initialization_state_ = CREATING_SYNC_MANAGER;
405 InitCore(DoInitializeOptions( 398 InitCore(DoInitializeOptions(
406 sync_thread_.message_loop(), 399 sync_thread_.message_loop(),
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 core_ = NULL; // Releases reference to core_. 587 core_ = NULL; // Releases reference to core_.
595 } 588 }
596 589
597 void SyncBackendHost::ConfigureDataTypes( 590 void SyncBackendHost::ConfigureDataTypes(
598 syncer::ConfigureReason reason, 591 syncer::ConfigureReason reason,
599 syncer::ModelTypeSet types_to_add, 592 syncer::ModelTypeSet types_to_add,
600 syncer::ModelTypeSet types_to_remove, 593 syncer::ModelTypeSet types_to_remove,
601 NigoriState nigori_state, 594 NigoriState nigori_state,
602 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, 595 const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
603 const base::Callback<void()>& retry_callback) { 596 const base::Callback<void()>& retry_callback) {
597 // Only one configure is allowed at a time. This is guaranteed by our
598 // callers. The SyncBackendHost requests one configure as the backend is
599 // initializing and waits for it to complete. After initialization, all
600 // configurations will pass through the DataTypeManager, which is careful to
601 // never send a new configure request until the current request succeeds.
602
603 DCHECK_GT(initialization_state_, NOT_INITIALIZED);
604
604 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add; 605 syncer::ModelTypeSet types_to_add_with_nigori = types_to_add;
605 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove; 606 syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove;
606 if (nigori_state == WITH_NIGORI) { 607 if (nigori_state == WITH_NIGORI) {
607 types_to_add_with_nigori.Put(syncer::NIGORI); 608 types_to_add_with_nigori.Put(syncer::NIGORI);
608 types_to_remove_with_nigori.Remove(syncer::NIGORI); 609 types_to_remove_with_nigori.Remove(syncer::NIGORI);
609 } else { 610 } else {
610 types_to_add_with_nigori.Remove(syncer::NIGORI); 611 types_to_add_with_nigori.Remove(syncer::NIGORI);
611 types_to_remove_with_nigori.Put(syncer::NIGORI); 612 types_to_remove_with_nigori.Put(syncer::NIGORI);
612 } 613 }
613 // Only one configure is allowed at a time (DataTypeManager handles user
614 // changes that happen while the syncer is reconfiguring, and will only
615 // trigger another call to ConfigureDataTypes once the current reconfiguration
616 // completes).
617 DCHECK_GT(initialization_state_, NOT_INITIALIZED);
618 614
619 // The new set of enabled types is types_to_add_with_nigori + the 615 // The SyncBackendRegistrar's routing info will be updated by adding the
620 // previously enabled types (on restart, the preferred types are already 616 // types_to_add_with_nigori to the list then removing
621 // enabled) - types_to_remove_with_nigori. After reconfiguring the registrar, 617 // types_to_remove_with_nigori. Any types which are not in either of those
622 // the new routing info will reflect the set of enabled types. 618 // sets will remain untouched.
619 //
620 // Types which were not in the list previously are not fully downloaded, so we
621 // must ask the syncer to download them. Any newly supported datatypes will
622 // not have been in that routing info list, so they will be among the types
623 // downloaded if they are enabled.
624 //
625 // The SyncBackendRegistrar's state was initially derived from the types
626 // marked initial_sync_ended when the sync database was loaded. Afterwards it
627 // is modified only by this function. We expect it to remain in sync with the
628 // backend because configuration requests are never aborted; they are retried
629 // until they succeed or the browser is closed.
630
631 syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes(
632 types_to_add_with_nigori, types_to_remove_with_nigori);
633 if (!types_to_download.Empty())
634 types_to_download.Put(syncer::NIGORI);
635
636 // TODO(sync): crbug.com/137550.
637 // It's dangerous to configure types that have progress markers. Types with
638 // progress markers can trigger a MIGRATION_DONE response. We are not
639 // prepared to handle a migration during a configure, so we must ensure that
640 // all our types_to_download actually contain no data before we sync them.
641 //
642 // The most common way to end up in this situation used to be types which had
643 // !initial_sync_ended, but did have some progress markers. We avoid problems
644 // with those types by purging the data of any such partially synced types
645 // soon after we load the directory.
646 //
647 // Another possible scenario is that we have newly supported or newly enabled
648 // data types being downloaded here but the nigori type, which is always
649 // included in any GetUpdates request, requires migration. The server has
650 // code to detect this scenario based on the configure reason, the fact that
651 // the nigori type is the only requested type which requires migration, and
652 // that the requested types list includes at least one non-nigori type. It
653 // will not send a MIGRATION_DONE response in that case. We still need to be
654 // careful to not send progress markers for non-nigori types, though. If a
655 // non-nigori type in the request requires migration, a MIGRATION_DONE
656 // response will be sent.
657
623 syncer::ModelSafeRoutingInfo routing_info; 658 syncer::ModelSafeRoutingInfo routing_info;
624 registrar_->ConfigureDataTypes(types_to_add_with_nigori,
625 types_to_remove_with_nigori);
626 registrar_->GetModelSafeRoutingInfo(&routing_info); 659 registrar_->GetModelSafeRoutingInfo(&routing_info);
627 const syncer::ModelTypeSet enabled_types =
628 GetRoutingInfoTypes(routing_info);
629
630 // Figure out which types need to actually be downloaded. We pass those on
631 // to the syncer while it's in configuration mode so that they can be
632 // downloaded before we perform association. Once we switch to normal mode
633 // downloads will get applied normally and hit the datatype's change
634 // processor.
635 // A datatype is in need of downloading if any of the following are true:
636 // 1. it's enabled and initial_sync_ended is false (initial_sync_ended is
637 // set after applying updates, and hence is a more conservative measure
638 // than having a non-empty progress marker, which is set during
639 // StoreTimestamps).
640 // 2. the type is NIGORI, and any other datatype is being downloaded (nigori
641 // is always included if we download a datatype).
642 // TODO(sync): consider moving this logic onto the sync thread (perhaps
643 // as part of SyncManager::ConfigureSyncer).
644 syncer::ModelTypeSet initial_sync_ended_types =
645 core_->sync_manager()->InitialSyncEndedTypes();
646 initial_sync_ended_types.RetainAll(enabled_types);
647 syncer::ModelTypeSet types_to_config =
648 Difference(enabled_types, initial_sync_ended_types);
649 if (!types_to_config.Empty() && enabled_types.Has(syncer::NIGORI))
650 types_to_config.Put(syncer::NIGORI);
651 660
652 SDVLOG(1) << "Types " 661 SDVLOG(1) << "Types "
653 << syncer::ModelTypeSetToString(types_to_config) 662 << syncer::ModelTypeSetToString(types_to_download)
654 << " added; calling DoConfigureSyncer"; 663 << " added; calling DoConfigureSyncer";
655 // TODO(zea): figure out how to bypass this call if no types are being 664 // TODO(zea): figure out how to bypass this call if no types are being
656 // configured and GetKey is not needed. For now we rely on determining the 665 // configured and GetKey is not needed. For now we rely on determining the
657 // need for GetKey as part of the SyncManager::ConfigureSyncer logic. 666 // need for GetKey as part of the SyncManager::ConfigureSyncer logic.
658 RequestConfigureSyncer(reason, 667 RequestConfigureSyncer(reason,
659 types_to_config, 668 types_to_download,
660 routing_info, 669 routing_info,
661 ready_task, 670 ready_task,
662 retry_callback); 671 retry_callback);
663 } 672 }
664 673
665 void SyncBackendHost::EnableEncryptEverything() { 674 void SyncBackendHost::EnableEncryptEverything() {
666 sync_thread_.message_loop()->PostTask(FROM_HERE, 675 sync_thread_.message_loop()->PostTask(FROM_HERE,
667 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, 676 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything,
668 core_.get())); 677 core_.get()));
669 } 678 }
670 679
671 void SyncBackendHost::ActivateDataType( 680 void SyncBackendHost::ActivateDataType(
672 syncer::ModelType type, syncer::ModelSafeGroup group, 681 syncer::ModelType type, syncer::ModelSafeGroup group,
673 ChangeProcessor* change_processor) { 682 ChangeProcessor* change_processor) {
674 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); 683 registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
675 } 684 }
676 685
677 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) { 686 void SyncBackendHost::DeactivateDataType(syncer::ModelType type) {
678 registrar_->DeactivateDataType(type); 687 registrar_->DeactivateDataType(type);
679 } 688 }
680 689
681 syncer::UserShare* SyncBackendHost::GetUserShare() const { 690 syncer::UserShare* SyncBackendHost::GetUserShare() const {
682 DCHECK(initialized());
683 return core_->sync_manager()->GetUserShare(); 691 return core_->sync_manager()->GetUserShare();
684 } 692 }
685 693
686 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { 694 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() {
687 DCHECK(initialized()); 695 DCHECK(initialized());
688 return core_->sync_manager()->GetDetailedStatus(); 696 return core_->sync_manager()->GetDetailedStatus();
689 } 697 }
690 698
691 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const { 699 SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const {
692 return last_snapshot_; 700 return last_snapshot_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop( 757 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(
750 syncer::ModelTypeSet failed_configuration_types, 758 syncer::ModelTypeSet failed_configuration_types,
751 const base::Callback<void(syncer::ModelTypeSet)>& ready_task) { 759 const base::Callback<void(syncer::ModelTypeSet)>& ready_task) {
752 if (!frontend_) 760 if (!frontend_)
753 return; 761 return;
754 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 762 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
755 if (!ready_task.is_null()) 763 if (!ready_task.is_null())
756 ready_task.Run(failed_configuration_types); 764 ready_task.Run(failed_configuration_types);
757 } 765 }
758 766
767 void SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop(
768 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
769 syncer::ModelTypeSet restored_types) {
770 registrar_->SetInitialTypes(restored_types);
771 HandleInitializationCompletedOnFrontendLoop(js_backend, success);
772 }
773
759 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( 774 SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
760 MessageLoop* sync_loop, 775 MessageLoop* sync_loop,
761 SyncBackendRegistrar* registrar, 776 SyncBackendRegistrar* registrar,
762 const syncer::ModelSafeRoutingInfo& routing_info, 777 const syncer::ModelSafeRoutingInfo& routing_info,
763 const std::vector<syncer::ModelSafeWorker*>& workers, 778 const std::vector<syncer::ModelSafeWorker*>& workers,
764 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, 779 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
765 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, 780 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
766 const GURL& service_url, 781 const GURL& service_url,
767 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 782 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
768 const syncer::SyncCredentials& credentials, 783 const syncer::SyncCredentials& credentials,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 DCHECK_EQ(MessageLoop::current(), sync_loop_); 836 DCHECK_EQ(MessageLoop::current(), sync_loop_);
822 host_.Call( 837 host_.Call(
823 FROM_HERE, 838 FROM_HERE,
824 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, 839 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop,
825 snapshot); 840 snapshot);
826 } 841 }
827 842
828 843
829 void SyncBackendHost::Core::OnInitializationComplete( 844 void SyncBackendHost::Core::OnInitializationComplete(
830 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 845 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
831 bool success) { 846 bool success,
847 const syncer::ModelTypeSet restored_types) {
832 DCHECK_EQ(MessageLoop::current(), sync_loop_); 848 DCHECK_EQ(MessageLoop::current(), sync_loop_);
833 host_.Call( 849 host_.Call(
834 FROM_HERE, 850 FROM_HERE,
835 &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop, 851 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop,
836 js_backend, success); 852 js_backend, success, restored_types);
837 853
838 if (success) { 854 if (success) {
839 // Initialization is complete, so we can schedule recurring SaveChanges. 855 // Initialization is complete, so we can schedule recurring SaveChanges.
840 sync_loop_->PostTask(FROM_HERE, 856 sync_loop_->PostTask(FROM_HERE,
841 base::Bind(&Core::StartSavingChanges, this)); 857 base::Bind(&Core::StartSavingChanges, this));
842 } 858 }
843 } 859 }
844 860
845 void SyncBackendHost::Core::OnConnectionStatusChange( 861 void SyncBackendHost::Core::OnConnectionStatusChange(
846 syncer::ConnectionStatus status) { 862 syncer::ConnectionStatus status) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_); 977 sync_manager_ = options.sync_manager_factory->CreateSyncManager(name_);
962 sync_manager_->AddObserver(this); 978 sync_manager_->AddObserver(this);
963 success = sync_manager_->Init( 979 success = sync_manager_->Init(
964 sync_data_folder_path_, 980 sync_data_folder_path_,
965 options.event_handler, 981 options.event_handler,
966 options.service_url.host() + options.service_url.path(), 982 options.service_url.host() + options.service_url.path(),
967 options.service_url.EffectiveIntPort(), 983 options.service_url.EffectiveIntPort(),
968 options.service_url.SchemeIsSecure(), 984 options.service_url.SchemeIsSecure(),
969 BrowserThread::GetBlockingPool(), 985 BrowserThread::GetBlockingPool(),
970 options.make_http_bridge_factory_fn.Run().Pass(), 986 options.make_http_bridge_factory_fn.Run().Pass(),
971 options.routing_info,
972 options.workers, 987 options.workers,
973 options.extensions_activity_monitor, 988 options.extensions_activity_monitor,
974 options.registrar /* as SyncManager::ChangeDelegate */, 989 options.registrar /* as SyncManager::ChangeDelegate */,
975 options.credentials, 990 options.credentials,
976 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier( 991 scoped_ptr<syncer::SyncNotifier>(new BridgedSyncNotifier(
977 options.chrome_sync_notification_bridge, 992 options.chrome_sync_notification_bridge,
978 options.sync_notifier_factory->CreateSyncNotifier())), 993 options.sync_notifier_factory->CreateSyncNotifier())),
979 options.restored_key_for_bootstrapping, 994 options.restored_key_for_bootstrapping,
980 scoped_ptr<InternalComponentsFactory>( 995 scoped_ptr<InternalComponentsFactory>(
981 options.internal_components_factory), 996 options.internal_components_factory),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 initialization_state_ = NOT_INITIALIZED; 1175 initialization_state_ = NOT_INITIALIZED;
1161 1176
1162 DCHECK_EQ(MessageLoop::current(), frontend_loop_); 1177 DCHECK_EQ(MessageLoop::current(), frontend_loop_);
1163 if (!success) { 1178 if (!success) {
1164 initialization_state_ = NOT_INITIALIZED; 1179 initialization_state_ = NOT_INITIALIZED;
1165 frontend_->OnBackendInitialized( 1180 frontend_->OnBackendInitialized(
1166 syncer::WeakHandle<syncer::JsBackend>(), false); 1181 syncer::WeakHandle<syncer::JsBackend>(), false);
1167 return; 1182 return;
1168 } 1183 }
1169 1184
1170 // If setup has completed, start off in DOWNLOADING_NIGORI so that
1171 // we start off by refreshing nigori.
1172 CHECK(sync_prefs_.get());
1173 if (sync_prefs_->HasSyncSetupCompleted() &&
1174 initialization_state_ < DOWNLOADING_NIGORI) {
1175 initialization_state_ = DOWNLOADING_NIGORI;
1176 }
1177
1178 // Run initialization state machine. 1185 // Run initialization state machine.
1179 switch (initialization_state_) { 1186 switch (initialization_state_) {
1180 case NOT_INITIALIZED: 1187 case NOT_INITIALIZED:
1188 // This configuration should result in a download request if the nigori
1189 // type's initial_sync_ended bit is unset. If the download request
1190 // contains progress markers, there is a risk that the server will try to
1191 // trigger migration. That would be disastrous, so we must rely on the
1192 // sync manager to ensure that this type never has both progress markers
1193 // and !initial_sync_ended.
1181 initialization_state_ = DOWNLOADING_NIGORI; 1194 initialization_state_ = DOWNLOADING_NIGORI;
1182 ConfigureDataTypes( 1195 ConfigureDataTypes(
1183 syncer::CONFIGURE_REASON_NEW_CLIENT, 1196 syncer::CONFIGURE_REASON_NEW_CLIENT,
1184 syncer::ModelTypeSet(), 1197 syncer::ModelTypeSet(),
1185 syncer::ModelTypeSet(), 1198 syncer::ModelTypeSet(),
1186 WITH_NIGORI, 1199 WITH_NIGORI,
1187 // Calls back into this function. 1200 // Calls back into this function.
1188 base::Bind( 1201 base::Bind(
1189 &SyncBackendHost:: 1202 &SyncBackendHost::
1190 HandleNigoriConfigurationCompletedOnFrontendLoop, 1203 HandleNigoriConfigurationCompletedOnFrontendLoop,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 FROM_HERE, 1379 FROM_HERE,
1367 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1380 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1368 core_.get(), sync_thread_done_callback)); 1381 core_.get(), sync_thread_done_callback));
1369 } 1382 }
1370 1383
1371 #undef SDVLOG 1384 #undef SDVLOG
1372 1385
1373 #undef SLOG 1386 #undef SLOG
1374 1387
1375 } // namespace browser_sync 1388 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/glue/sync_backend_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698