Commit 0e952cbe authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Configure sync when engine is initialized

Already configure sync in the UnifiedConsentService when the
sync engine is initialized, instead of waiting for sync to be
active.

Bug: 891706
Change-Id: I4f072e56820784f42ce9f2033724e43d8d5f5bf3
Reviewed-on: https://chromium-review.googlesource.com/c/1264656Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597099}
parent 0273cde7
...@@ -311,16 +311,8 @@ void UnifiedConsentService::OnStateChanged(syncer::SyncService* sync) { ...@@ -311,16 +311,8 @@ void UnifiedConsentService::OnStateChanged(syncer::SyncService* sync) {
syncer::SyncPrefs sync_prefs(pref_service_); syncer::SyncPrefs sync_prefs(pref_service_);
if (IsUnifiedConsentGiven() != sync_prefs.HasKeepEverythingSynced()) { if (IsUnifiedConsentGiven() != sync_prefs.HasKeepEverythingSynced()) {
// |OnStateChanged| is called after every update in the sync service, // Make sync-everything consistent with the |kUnifiedConsentGiven| pref.
// therefore only allow to update the sync settings when the transport PostTaskToUpdateSyncSettings(/*sync_everything=*/IsUnifiedConsentGiven());
// state is ACTIVE.
// Note: This is a safety measure. Theoretically this can be done when
// the sync engine is initialized.
if (sync_service_->GetTransportState() ==
syncer::SyncService::TransportState::ACTIVE) {
// Make sync-everything consistent with the |kUnifiedConsentGiven| pref.
PostTaskToUpdateSyncSettings(/*sync_everything=*/IsUnifiedConsentGiven());
}
} }
} }
...@@ -452,8 +444,7 @@ void UnifiedConsentService::MigrateProfileToUnifiedConsent() { ...@@ -452,8 +444,7 @@ void UnifiedConsentService::MigrateProfileToUnifiedConsent() {
} }
void UnifiedConsentService::UpdateSettingsForMigration() { void UnifiedConsentService::UpdateSettingsForMigration() {
if (sync_service_->GetTransportState() != if (!sync_service_->IsEngineInitialized()) {
syncer::SyncService::TransportState::ACTIVE) {
SetMigrationState(MigrationState::kInProgressWaitForSyncInit); SetMigrationState(MigrationState::kInProgressWaitForSyncInit);
return; return;
} }
......
...@@ -384,7 +384,7 @@ TEST_F(UnifiedConsentServiceTest, Migration_SyncingEverythingAndAllServicesOn) { ...@@ -384,7 +384,7 @@ TEST_F(UnifiedConsentServiceTest, Migration_SyncingEverythingAndAllServicesOn) {
EXPECT_TRUE(sync_prefs.HasKeepEverythingSynced()); EXPECT_TRUE(sync_prefs.HasKeepEverythingSynced());
EXPECT_FALSE(pref_service_.GetBoolean(prefs::kUnifiedConsentGiven)); EXPECT_FALSE(pref_service_.GetBoolean(prefs::kUnifiedConsentGiven));
sync_service_.SetTransportState( sync_service_.SetTransportState(
syncer::SyncService::TransportState::PENDING_DESIRED_CONFIGURATION); syncer::SyncService::TransportState::INITIALIZING);
EXPECT_FALSE(sync_service_.IsSyncFeatureActive()); EXPECT_FALSE(sync_service_.IsSyncFeatureActive());
CreateConsentService(true /* client_services_on_by_default */); CreateConsentService(true /* client_services_on_by_default */);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment