| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 SyncBackendHost::~SyncBackendHost() { | 96 SyncBackendHost::~SyncBackendHost() { |
| 97 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; | 97 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; |
| 98 DCHECK(!registrar_.get()); | 98 DCHECK(!registrar_.get()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void SyncBackendHost::Initialize( | 101 void SyncBackendHost::Initialize( |
| 102 SyncFrontend* frontend, | 102 SyncFrontend* frontend, |
| 103 const WeakHandle<JsEventHandler>& event_handler, | 103 const WeakHandle<JsEventHandler>& event_handler, |
| 104 const GURL& sync_service_url, | 104 const GURL& sync_service_url, |
| 105 syncable::ModelEnumSet initial_types, | 105 syncable::ModelTypeSet initial_types, |
| 106 const SyncCredentials& credentials, | 106 const SyncCredentials& credentials, |
| 107 bool delete_sync_data_folder) { | 107 bool delete_sync_data_folder) { |
| 108 if (!sync_thread_.Start()) | 108 if (!sync_thread_.Start()) |
| 109 return; | 109 return; |
| 110 | 110 |
| 111 frontend_ = frontend; | 111 frontend_ = frontend; |
| 112 DCHECK(frontend); | 112 DCHECK(frontend); |
| 113 | 113 |
| 114 syncable::ModelEnumSet initial_types_with_nigori(initial_types); | 114 syncable::ModelTypeSet initial_types_with_nigori(initial_types); |
| 115 CHECK(sync_prefs_.get()); | 115 CHECK(sync_prefs_.get()); |
| 116 if (sync_prefs_->HasSyncSetupCompleted()) { | 116 if (sync_prefs_->HasSyncSetupCompleted()) { |
| 117 initial_types_with_nigori.Put(syncable::NIGORI); | 117 initial_types_with_nigori.Put(syncable::NIGORI); |
| 118 } | 118 } |
| 119 | 119 |
| 120 registrar_.reset(new SyncBackendRegistrar(initial_types_with_nigori, | 120 registrar_.reset(new SyncBackendRegistrar(initial_types_with_nigori, |
| 121 name_, | 121 name_, |
| 122 profile_, | 122 profile_, |
| 123 sync_thread_.message_loop())); | 123 sync_thread_.message_loop())); |
| 124 initialization_state_ = CREATING_SYNC_MANAGER; | 124 initialization_state_ = CREATING_SYNC_MANAGER; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 base::ThreadRestrictions::ScopedAllowIO allow_io; | 240 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 241 sync_thread_.Stop(); | 241 sync_thread_.Stop(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 registrar_.reset(); | 244 registrar_.reset(); |
| 245 frontend_ = NULL; | 245 frontend_ = NULL; |
| 246 core_ = NULL; // Releases reference to core_. | 246 core_ = NULL; // Releases reference to core_. |
| 247 } | 247 } |
| 248 | 248 |
| 249 void SyncBackendHost::ConfigureDataTypes( | 249 void SyncBackendHost::ConfigureDataTypes( |
| 250 syncable::ModelEnumSet types_to_add, | 250 syncable::ModelTypeSet types_to_add, |
| 251 syncable::ModelEnumSet types_to_remove, | 251 syncable::ModelTypeSet types_to_remove, |
| 252 sync_api::ConfigureReason reason, | 252 sync_api::ConfigureReason reason, |
| 253 base::Callback<void(syncable::ModelEnumSet)> ready_task, | 253 base::Callback<void(syncable::ModelTypeSet)> ready_task, |
| 254 bool enable_nigori) { | 254 bool enable_nigori) { |
| 255 syncable::ModelEnumSet types_to_add_with_nigori = types_to_add; | 255 syncable::ModelTypeSet types_to_add_with_nigori = types_to_add; |
| 256 syncable::ModelEnumSet types_to_remove_with_nigori = types_to_remove; | 256 syncable::ModelTypeSet types_to_remove_with_nigori = types_to_remove; |
| 257 if (enable_nigori) { | 257 if (enable_nigori) { |
| 258 types_to_add_with_nigori.Put(syncable::NIGORI); | 258 types_to_add_with_nigori.Put(syncable::NIGORI); |
| 259 types_to_remove_with_nigori.Remove(syncable::NIGORI); | 259 types_to_remove_with_nigori.Remove(syncable::NIGORI); |
| 260 } else { | 260 } else { |
| 261 types_to_add_with_nigori.Remove(syncable::NIGORI); | 261 types_to_add_with_nigori.Remove(syncable::NIGORI); |
| 262 types_to_remove_with_nigori.Put(syncable::NIGORI); | 262 types_to_remove_with_nigori.Put(syncable::NIGORI); |
| 263 } | 263 } |
| 264 // Only one configure is allowed at a time. | 264 // Only one configure is allowed at a time. |
| 265 DCHECK(!pending_config_mode_state_.get()); | 265 DCHECK(!pending_config_mode_state_.get()); |
| 266 DCHECK(!pending_download_state_.get()); | 266 DCHECK(!pending_download_state_.get()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 void SyncBackendHost::Core::OnClearServerDataSucceeded() { | 476 void SyncBackendHost::Core::OnClearServerDataSucceeded() { |
| 477 if (!sync_loop_) | 477 if (!sync_loop_) |
| 478 return; | 478 return; |
| 479 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 479 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 480 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( | 480 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
| 481 &Core::HandleClearServerDataSucceededOnFrontendLoop, this)); | 481 &Core::HandleClearServerDataSucceededOnFrontendLoop, this)); |
| 482 } | 482 } |
| 483 | 483 |
| 484 void SyncBackendHost::Core::OnEncryptedTypesChanged( | 484 void SyncBackendHost::Core::OnEncryptedTypesChanged( |
| 485 syncable::ModelEnumSet encrypted_types, | 485 syncable::ModelTypeSet encrypted_types, |
| 486 bool encrypt_everything) { | 486 bool encrypt_everything) { |
| 487 if (!sync_loop_) | 487 if (!sync_loop_) |
| 488 return; | 488 return; |
| 489 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 489 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 490 // NOTE: We're in a transaction. | 490 // NOTE: We're in a transaction. |
| 491 host_->frontend_loop_->PostTask( | 491 host_->frontend_loop_->PostTask( |
| 492 FROM_HERE, | 492 FROM_HERE, |
| 493 base::Bind(&Core::NotifyEncryptedTypesChanged, this, | 493 base::Bind(&Core::NotifyEncryptedTypesChanged, this, |
| 494 encrypted_types, encrypt_everything)); | 494 encrypted_types, encrypt_everything)); |
| 495 } | 495 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 677 |
| 678 if (sync_disabled) | 678 if (sync_disabled) |
| 679 DeleteSyncDataFolder(); | 679 DeleteSyncDataFolder(); |
| 680 | 680 |
| 681 sync_loop_ = NULL; | 681 sync_loop_ = NULL; |
| 682 | 682 |
| 683 host_ = NULL; | 683 host_ = NULL; |
| 684 } | 684 } |
| 685 | 685 |
| 686 void SyncBackendHost::Core::DoRequestConfig( | 686 void SyncBackendHost::Core::DoRequestConfig( |
| 687 syncable::ModelEnumSet types_to_config, | 687 syncable::ModelTypeSet types_to_config, |
| 688 sync_api::ConfigureReason reason) { | 688 sync_api::ConfigureReason reason) { |
| 689 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 689 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 690 sync_manager_->RequestConfig(types_to_config, reason); | 690 sync_manager_->RequestConfig(types_to_config, reason); |
| 691 } | 691 } |
| 692 | 692 |
| 693 void SyncBackendHost::Core::DoStartConfiguration( | 693 void SyncBackendHost::Core::DoStartConfiguration( |
| 694 const base::Closure& callback) { | 694 const base::Closure& callback) { |
| 695 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 695 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 696 sync_manager_->StartConfigurationMode(callback); | 696 sync_manager_->StartConfigurationMode(callback); |
| 697 } | 697 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 713 void SyncBackendHost::Core::HandleInitializationCompletedOnFrontendLoop( | 713 void SyncBackendHost::Core::HandleInitializationCompletedOnFrontendLoop( |
| 714 const WeakHandle<JsBackend>& js_backend, | 714 const WeakHandle<JsBackend>& js_backend, |
| 715 bool success) { | 715 bool success) { |
| 716 if (!host_) | 716 if (!host_) |
| 717 return; | 717 return; |
| 718 host_->HandleInitializationCompletedOnFrontendLoop(js_backend, success); | 718 host_->HandleInitializationCompletedOnFrontendLoop(js_backend, success); |
| 719 } | 719 } |
| 720 | 720 |
| 721 void SyncBackendHost::Core::HandleNigoriConfigurationCompletedOnFrontendLoop( | 721 void SyncBackendHost::Core::HandleNigoriConfigurationCompletedOnFrontendLoop( |
| 722 const WeakHandle<JsBackend>& js_backend, | 722 const WeakHandle<JsBackend>& js_backend, |
| 723 const syncable::ModelEnumSet failed_configuration_types) { | 723 const syncable::ModelTypeSet failed_configuration_types) { |
| 724 if (!host_) | 724 if (!host_) |
| 725 return; | 725 return; |
| 726 host_->HandleInitializationCompletedOnFrontendLoop( | 726 host_->HandleInitializationCompletedOnFrontendLoop( |
| 727 js_backend, failed_configuration_types.Empty()); | 727 js_backend, failed_configuration_types.Empty()); |
| 728 } | 728 } |
| 729 | 729 |
| 730 void SyncBackendHost::Core::StartSavingChanges() { | 730 void SyncBackendHost::Core::StartSavingChanges() { |
| 731 // We may already be shut down. | 731 // We may already be shut down. |
| 732 if (!sync_loop_) | 732 if (!sync_loop_) |
| 733 return; | 733 return; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 return; | 787 return; |
| 788 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 788 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 789 TokenAvailableDetails details(GaiaConstants::kSyncService, token); | 789 TokenAvailableDetails details(GaiaConstants::kSyncService, token); |
| 790 content::NotificationService::current()->Notify( | 790 content::NotificationService::current()->Notify( |
| 791 chrome::NOTIFICATION_TOKEN_UPDATED, | 791 chrome::NOTIFICATION_TOKEN_UPDATED, |
| 792 content::Source<Profile>(host_->profile_), | 792 content::Source<Profile>(host_->profile_), |
| 793 content::Details<const TokenAvailableDetails>(&details)); | 793 content::Details<const TokenAvailableDetails>(&details)); |
| 794 } | 794 } |
| 795 | 795 |
| 796 void SyncBackendHost::Core::NotifyEncryptedTypesChanged( | 796 void SyncBackendHost::Core::NotifyEncryptedTypesChanged( |
| 797 syncable::ModelEnumSet encrypted_types, | 797 syncable::ModelTypeSet encrypted_types, |
| 798 bool encrypt_everything) { | 798 bool encrypt_everything) { |
| 799 if (!host_) | 799 if (!host_) |
| 800 return; | 800 return; |
| 801 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); | 801 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); |
| 802 host_->frontend_->OnEncryptedTypesChanged( | 802 host_->frontend_->OnEncryptedTypesChanged( |
| 803 encrypted_types, encrypt_everything); | 803 encrypted_types, encrypt_everything); |
| 804 } | 804 } |
| 805 | 805 |
| 806 void SyncBackendHost::Core::NotifyEncryptionComplete() { | 806 void SyncBackendHost::Core::NotifyEncryptionComplete() { |
| 807 if (!host_) | 807 if (!host_) |
| 808 return; | 808 return; |
| 809 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); | 809 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); |
| 810 host_->frontend_->OnEncryptionComplete(); | 810 host_->frontend_->OnEncryptionComplete(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 void SyncBackendHost::Core::HandleSyncCycleCompletedOnFrontendLoop( | 813 void SyncBackendHost::Core::HandleSyncCycleCompletedOnFrontendLoop( |
| 814 SyncSessionSnapshot* snapshot) { | 814 SyncSessionSnapshot* snapshot) { |
| 815 if (!host_ || !host_->frontend_) | 815 if (!host_ || !host_->frontend_) |
| 816 return; | 816 return; |
| 817 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); | 817 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); |
| 818 | 818 |
| 819 host_->last_snapshot_.reset(snapshot); | 819 host_->last_snapshot_.reset(snapshot); |
| 820 | 820 |
| 821 SVLOG(1) << "Got snapshot " << snapshot->ToString(); | 821 SVLOG(1) << "Got snapshot " << snapshot->ToString(); |
| 822 | 822 |
| 823 const syncable::ModelEnumSet to_migrate = | 823 const syncable::ModelTypeSet to_migrate = |
| 824 snapshot->syncer_status.types_needing_local_migration; | 824 snapshot->syncer_status.types_needing_local_migration; |
| 825 if (!to_migrate.Empty()) | 825 if (!to_migrate.Empty()) |
| 826 host_->frontend_->OnMigrationNeededForTypes(to_migrate); | 826 host_->frontend_->OnMigrationNeededForTypes(to_migrate); |
| 827 | 827 |
| 828 // Process any changes to the datatypes we're syncing. | 828 // Process any changes to the datatypes we're syncing. |
| 829 // TODO(sync): add support for removing types. | 829 // TODO(sync): add support for removing types. |
| 830 if (host_->initialized()) | 830 if (host_->initialized()) |
| 831 host_->AddExperimentalTypes(); | 831 host_->AddExperimentalTypes(); |
| 832 | 832 |
| 833 // If we are waiting for a configuration change, check here to see | 833 // If we are waiting for a configuration change, check here to see |
| 834 // if this sync cycle has initialized all of the types we've been | 834 // if this sync cycle has initialized all of the types we've been |
| 835 // waiting for. | 835 // waiting for. |
| 836 if (host_->pending_download_state_.get()) { | 836 if (host_->pending_download_state_.get()) { |
| 837 scoped_ptr<PendingConfigureDataTypesState> state( | 837 scoped_ptr<PendingConfigureDataTypesState> state( |
| 838 host_->pending_download_state_.release()); | 838 host_->pending_download_state_.release()); |
| 839 const syncable::ModelEnumSet types_to_add = state->types_to_add; | 839 const syncable::ModelTypeSet types_to_add = state->types_to_add; |
| 840 const syncable::ModelEnumSet added_types = state->added_types; | 840 const syncable::ModelTypeSet added_types = state->added_types; |
| 841 DCHECK(types_to_add.HasAll(added_types)); | 841 DCHECK(types_to_add.HasAll(added_types)); |
| 842 const syncable::ModelEnumSet initial_sync_ended = | 842 const syncable::ModelTypeSet initial_sync_ended = |
| 843 snapshot->initial_sync_ended; | 843 snapshot->initial_sync_ended; |
| 844 const syncable::ModelEnumSet failed_configuration_types = | 844 const syncable::ModelTypeSet failed_configuration_types = |
| 845 Difference(added_types, initial_sync_ended); | 845 Difference(added_types, initial_sync_ended); |
| 846 SVLOG(1) | 846 SVLOG(1) |
| 847 << "Added types: " | 847 << "Added types: " |
| 848 << syncable::ModelEnumSetToString(added_types) | 848 << syncable::ModelTypeSetToString(added_types) |
| 849 << ", configured types: " | 849 << ", configured types: " |
| 850 << syncable::ModelEnumSetToString(initial_sync_ended) | 850 << syncable::ModelTypeSetToString(initial_sync_ended) |
| 851 << ", failed configuration types: " | 851 << ", failed configuration types: " |
| 852 << syncable::ModelEnumSetToString(failed_configuration_types); | 852 << syncable::ModelTypeSetToString(failed_configuration_types); |
| 853 state->ready_task.Run(failed_configuration_types); | 853 state->ready_task.Run(failed_configuration_types); |
| 854 if (!failed_configuration_types.Empty()) | 854 if (!failed_configuration_types.Empty()) |
| 855 return; | 855 return; |
| 856 } | 856 } |
| 857 | 857 |
| 858 if (host_->initialized()) | 858 if (host_->initialized()) |
| 859 host_->frontend_->OnSyncCycleCompleted(); | 859 host_->frontend_->OnSyncCycleCompleted(); |
| 860 } | 860 } |
| 861 | 861 |
| 862 void SyncBackendHost::Core::HandleStopSyncingPermanentlyOnFrontendLoop() { | 862 void SyncBackendHost::Core::HandleStopSyncingPermanentlyOnFrontendLoop() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 876 return; | 876 return; |
| 877 host_->frontend_->OnClearServerDataFailed(); | 877 host_->frontend_->OnClearServerDataFailed(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 void SyncBackendHost::Core::FinishConfigureDataTypesOnFrontendLoop() { | 880 void SyncBackendHost::Core::FinishConfigureDataTypesOnFrontendLoop() { |
| 881 host_->FinishConfigureDataTypesOnFrontendLoop(); | 881 host_->FinishConfigureDataTypesOnFrontendLoop(); |
| 882 } | 882 } |
| 883 | 883 |
| 884 void SyncBackendHost::AddExperimentalTypes() { | 884 void SyncBackendHost::AddExperimentalTypes() { |
| 885 CHECK(initialized()); | 885 CHECK(initialized()); |
| 886 syncable::ModelEnumSet to_add; | 886 syncable::ModelTypeSet to_add; |
| 887 if (core_->sync_manager()->ReceivedExperimentalTypes(&to_add)) | 887 if (core_->sync_manager()->ReceivedExperimentalTypes(&to_add)) |
| 888 frontend_->OnDataTypesChanged(to_add); | 888 frontend_->OnDataTypesChanged(to_add); |
| 889 } | 889 } |
| 890 | 890 |
| 891 void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop( | 891 void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop( |
| 892 const WeakHandle<JsBackend>& js_backend, bool success) { | 892 const WeakHandle<JsBackend>& js_backend, bool success) { |
| 893 DCHECK_NE(NOT_ATTEMPTED, initialization_state_); | 893 DCHECK_NE(NOT_ATTEMPTED, initialization_state_); |
| 894 if (!frontend_) | 894 if (!frontend_) |
| 895 return; | 895 return; |
| 896 | 896 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 912 if (sync_prefs_->HasSyncSetupCompleted() && | 912 if (sync_prefs_->HasSyncSetupCompleted() && |
| 913 initialization_state_ < DOWNLOADING_NIGORI) { | 913 initialization_state_ < DOWNLOADING_NIGORI) { |
| 914 initialization_state_ = DOWNLOADING_NIGORI; | 914 initialization_state_ = DOWNLOADING_NIGORI; |
| 915 } | 915 } |
| 916 | 916 |
| 917 // Run initialization state machine. | 917 // Run initialization state machine. |
| 918 switch (initialization_state_) { | 918 switch (initialization_state_) { |
| 919 case NOT_INITIALIZED: | 919 case NOT_INITIALIZED: |
| 920 initialization_state_ = DOWNLOADING_NIGORI; | 920 initialization_state_ = DOWNLOADING_NIGORI; |
| 921 ConfigureDataTypes( | 921 ConfigureDataTypes( |
| 922 syncable::ModelEnumSet(), | 922 syncable::ModelTypeSet(), |
| 923 syncable::ModelEnumSet(), | 923 syncable::ModelTypeSet(), |
| 924 sync_api::CONFIGURE_REASON_NEW_CLIENT, | 924 sync_api::CONFIGURE_REASON_NEW_CLIENT, |
| 925 // Calls back into this function. | 925 // Calls back into this function. |
| 926 base::Bind( | 926 base::Bind( |
| 927 &SyncBackendHost::Core:: | 927 &SyncBackendHost::Core:: |
| 928 HandleNigoriConfigurationCompletedOnFrontendLoop, | 928 HandleNigoriConfigurationCompletedOnFrontendLoop, |
| 929 core_.get(), js_backend), | 929 core_.get(), js_backend), |
| 930 true); | 930 true); |
| 931 break; | 931 break; |
| 932 case DOWNLOADING_NIGORI: | 932 case DOWNLOADING_NIGORI: |
| 933 initialization_state_ = REFRESHING_ENCRYPTION; | 933 initialization_state_ = REFRESHING_ENCRYPTION; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 // downloading updates for newly added data types. Once this is | 970 // downloading updates for newly added data types. Once this is |
| 971 // complete, the configure_state_.ready_task_ is run via an | 971 // complete, the configure_state_.ready_task_ is run via an |
| 972 // OnInitializationComplete notification. | 972 // OnInitializationComplete notification. |
| 973 | 973 |
| 974 SVLOG(1) << "Syncer in config mode. SBH executing " | 974 SVLOG(1) << "Syncer in config mode. SBH executing " |
| 975 << "FinishConfigureDataTypesOnFrontendLoop"; | 975 << "FinishConfigureDataTypesOnFrontendLoop"; |
| 976 | 976 |
| 977 if (pending_config_mode_state_->added_types.Empty() && | 977 if (pending_config_mode_state_->added_types.Empty() && |
| 978 !core_->sync_manager()->InitialSyncEndedForAllEnabledTypes()) { | 978 !core_->sync_manager()->InitialSyncEndedForAllEnabledTypes()) { |
| 979 | 979 |
| 980 syncable::ModelEnumSet enabled_types; | 980 syncable::ModelTypeSet enabled_types; |
| 981 ModelSafeRoutingInfo routing_info; | 981 ModelSafeRoutingInfo routing_info; |
| 982 registrar_->GetModelSafeRoutingInfo(&routing_info); | 982 registrar_->GetModelSafeRoutingInfo(&routing_info); |
| 983 for (ModelSafeRoutingInfo::const_iterator i = routing_info.begin(); | 983 for (ModelSafeRoutingInfo::const_iterator i = routing_info.begin(); |
| 984 i != routing_info.end(); ++i) { | 984 i != routing_info.end(); ++i) { |
| 985 enabled_types.Put(i->first); | 985 enabled_types.Put(i->first); |
| 986 } | 986 } |
| 987 | 987 |
| 988 // TODO(tim): Log / UMA / count this somehow? | 988 // TODO(tim): Log / UMA / count this somehow? |
| 989 // Add only the types with empty progress markers. Note: it is possible | 989 // Add only the types with empty progress markers. Note: it is possible |
| 990 // that some types have their initial_sync_ended be false but with non | 990 // that some types have their initial_sync_ended be false but with non |
| 991 // empty progress marker. Which is ok as the rest of the changes would | 991 // empty progress marker. Which is ok as the rest of the changes would |
| 992 // be downloaded on a regular nudge and initial_sync_ended should be set | 992 // be downloaded on a regular nudge and initial_sync_ended should be set |
| 993 // to true. However this is a very corner case. So it is not explicitly | 993 // to true. However this is a very corner case. So it is not explicitly |
| 994 // handled. | 994 // handled. |
| 995 pending_config_mode_state_->added_types = | 995 pending_config_mode_state_->added_types = |
| 996 sync_api::GetTypesWithEmptyProgressMarkerToken(enabled_types, | 996 sync_api::GetTypesWithEmptyProgressMarkerToken(enabled_types, |
| 997 GetUserShare()); | 997 GetUserShare()); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 // If we've added types, we always want to request a nudge/config (even if | 1000 // If we've added types, we always want to request a nudge/config (even if |
| 1001 // the initial sync is ended), in case we could not decrypt the data. | 1001 // the initial sync is ended), in case we could not decrypt the data. |
| 1002 if (pending_config_mode_state_->added_types.Empty()) { | 1002 if (pending_config_mode_state_->added_types.Empty()) { |
| 1003 SVLOG(1) << "No new types added; calling ready_task directly"; | 1003 SVLOG(1) << "No new types added; calling ready_task directly"; |
| 1004 // No new types - just notify the caller that the types are available. | 1004 // No new types - just notify the caller that the types are available. |
| 1005 const syncable::ModelEnumSet failed_configuration_types; | 1005 const syncable::ModelTypeSet failed_configuration_types; |
| 1006 pending_config_mode_state_->ready_task.Run(failed_configuration_types); | 1006 pending_config_mode_state_->ready_task.Run(failed_configuration_types); |
| 1007 } else { | 1007 } else { |
| 1008 pending_download_state_.reset(pending_config_mode_state_.release()); | 1008 pending_download_state_.reset(pending_config_mode_state_.release()); |
| 1009 | 1009 |
| 1010 // Always configure nigori if it's enabled. | 1010 // Always configure nigori if it's enabled. |
| 1011 syncable::ModelEnumSet types_to_config = | 1011 syncable::ModelTypeSet types_to_config = |
| 1012 pending_download_state_->added_types; | 1012 pending_download_state_->added_types; |
| 1013 if (IsNigoriEnabled()) { | 1013 if (IsNigoriEnabled()) { |
| 1014 // Note: Nigori is the only type that gets added with a nonempty | 1014 // Note: Nigori is the only type that gets added with a nonempty |
| 1015 // progress marker during config. If the server returns a migration | 1015 // progress marker during config. If the server returns a migration |
| 1016 // error then we will go into unrecoverable error. We dont handle it | 1016 // error then we will go into unrecoverable error. We dont handle it |
| 1017 // explicitly because server might help us out here by not sending a | 1017 // explicitly because server might help us out here by not sending a |
| 1018 // migraiton error for nigori during config. | 1018 // migraiton error for nigori during config. |
| 1019 types_to_config.Put(syncable::NIGORI); | 1019 types_to_config.Put(syncable::NIGORI); |
| 1020 } | 1020 } |
| 1021 SVLOG(1) << "Types " | 1021 SVLOG(1) << "Types " |
| 1022 << syncable::ModelEnumSetToString(types_to_config) | 1022 << syncable::ModelTypeSetToString(types_to_config) |
| 1023 << " added; calling DoRequestConfig"; | 1023 << " added; calling DoRequestConfig"; |
| 1024 sync_thread_.message_loop()->PostTask(FROM_HERE, | 1024 sync_thread_.message_loop()->PostTask(FROM_HERE, |
| 1025 base::Bind(&SyncBackendHost::Core::DoRequestConfig, | 1025 base::Bind(&SyncBackendHost::Core::DoRequestConfig, |
| 1026 core_.get(), | 1026 core_.get(), |
| 1027 types_to_config, | 1027 types_to_config, |
| 1028 pending_download_state_->reason)); | 1028 pending_download_state_->reason)); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 pending_config_mode_state_.reset(); | 1031 pending_config_mode_state_.reset(); |
| 1032 | 1032 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 FROM_HERE, | 1073 FROM_HERE, |
| 1074 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, | 1074 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, |
| 1075 core_.get(), sync_thread_done_callback)); | 1075 core_.get(), sync_thread_done_callback)); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 #undef SVLOG | 1078 #undef SVLOG |
| 1079 | 1079 |
| 1080 #undef SLOG | 1080 #undef SLOG |
| 1081 | 1081 |
| 1082 } // namespace browser_sync | 1082 } // namespace browser_sync |
| OLD | NEW |