Commit dafbc4a1 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Make ProfileSyncService::ReconfigureDatatypeManager private

Callers can instead trigger a reconfigure by grabbing and immediately
releasing a SyncSetupInProgressHandle instead.
This resolves one of the last reasons for using ProfileSyncService
rather than SyncService.

Bug: 924508
Change-Id: I2ba2839356e32954d3c655356a60c6398d41adae
Reviewed-on: https://chromium-review.googlesource.com/c/1456658Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629970}
parent 2d079037
...@@ -24,10 +24,11 @@ ...@@ -24,10 +24,11 @@
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_user_settings.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
...@@ -217,11 +218,12 @@ bool ChildAccountService::SetActive(bool active) { ...@@ -217,11 +218,12 @@ bool ChildAccountService::SetActive(bool active) {
// Trigger a sync reconfig to enable/disable the right SU data types. // Trigger a sync reconfig to enable/disable the right SU data types.
// The logic to do this lives in the SupervisedUserSyncDataTypeController. // The logic to do this lives in the SupervisedUserSyncDataTypeController.
browser_sync::ProfileSyncService* sync_service = syncer::SyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_); ProfileSyncServiceFactory::GetSyncServiceForProfile(profile_);
if (sync_service->GetUserSettings()->IsFirstSetupComplete()) { if (sync_service->GetUserSettings()->IsFirstSetupComplete()) {
sync_service->ReconfigureDatatypeManager( // Trigger a reconfig by grabbing a SyncSetupInProgressHandle and
/*bypass_setup_in_progress_check=*/false); // immediately releasing it again (via the temporary unique_ptr going away).
sync_service->GetSetupInProgressHandle();
} }
return true; return true;
......
...@@ -283,13 +283,6 @@ class ProfileSyncService : public syncer::SyncService, ...@@ -283,13 +283,6 @@ class ProfileSyncService : public syncer::SyncService,
bool HasCookieJarMismatch( bool HasCookieJarMismatch(
const std::vector<gaia::ListedAccount>& cookie_jar_accounts); const std::vector<gaia::ListedAccount>& cookie_jar_accounts);
// Reconfigures the data type manager with the latest enabled types.
// Note: Does not initialize the engine if it is not already initialized.
// If a Sync setup is currently in progress (i.e. a settings UI is open), then
// the reconfiguration will only happen if |bypass_setup_in_progress_check| is
// set to true.
void ReconfigureDatatypeManager(bool bypass_setup_in_progress_check);
syncer::PassphraseRequiredReason passphrase_required_reason_for_test() const { syncer::PassphraseRequiredReason passphrase_required_reason_for_test() const {
return crypto_.passphrase_required_reason(); return crypto_.passphrase_required_reason();
} }
...@@ -403,6 +396,13 @@ class ProfileSyncService : public syncer::SyncService, ...@@ -403,6 +396,13 @@ class ProfileSyncService : public syncer::SyncService,
friend class TestProfileSyncService; friend class TestProfileSyncService;
// Reconfigures the data type manager with the latest enabled types.
// Note: Does not initialize the engine if it is not already initialized.
// If a Sync setup is currently in progress (i.e. a settings UI is open), then
// the reconfiguration will only happen if |bypass_setup_in_progress_check| is
// set to true.
void ReconfigureDatatypeManager(bool bypass_setup_in_progress_check);
// Helper to install and configure a data type manager. // Helper to install and configure a data type manager.
void ConfigureDataTypeManager(syncer::ConfigureReason reason); void ConfigureDataTypeManager(syncer::ConfigureReason reason);
......
...@@ -1531,8 +1531,9 @@ TEST_F(ProfileSyncServiceTest, ConfigureDataTypeManagerReason) { ...@@ -1531,8 +1531,9 @@ TEST_F(ProfileSyncServiceTest, ConfigureDataTypeManagerReason) {
service()->OnConfigureDone(configure_result); service()->OnConfigureDone(configure_result);
// Reconfiguration. // Reconfiguration.
service()->ReconfigureDatatypeManager( // Trigger a reconfig by grabbing a SyncSetupInProgressHandle and immediately
/*bypass_setup_in_progress_check=*/false); // releasing it again (via the temporary unique_ptr going away).
service()->GetSetupInProgressHandle();
EXPECT_EQ(syncer::CONFIGURE_REASON_RECONFIGURATION, configure_reason); EXPECT_EQ(syncer::CONFIGURE_REASON_RECONFIGURATION, configure_reason);
service()->OnConfigureDone(configure_result); service()->OnConfigureDone(configure_result);
ShutdownAndDeleteService(); ShutdownAndDeleteService();
...@@ -1550,8 +1551,9 @@ TEST_F(ProfileSyncServiceTest, ConfigureDataTypeManagerReason) { ...@@ -1550,8 +1551,9 @@ TEST_F(ProfileSyncServiceTest, ConfigureDataTypeManagerReason) {
service()->OnConfigureDone(configure_result); service()->OnConfigureDone(configure_result);
// Reconfiguration. // Reconfiguration.
service()->ReconfigureDatatypeManager( // Trigger a reconfig by grabbing a SyncSetupInProgressHandle and immediately
/*bypass_setup_in_progress_check=*/false); // releasing it again (via the temporary unique_ptr going away).
service()->GetSetupInProgressHandle();
EXPECT_EQ(syncer::CONFIGURE_REASON_RECONFIGURATION, configure_reason); EXPECT_EQ(syncer::CONFIGURE_REASON_RECONFIGURATION, configure_reason);
service()->OnConfigureDone(configure_result); service()->OnConfigureDone(configure_result);
ShutdownAndDeleteService(); ShutdownAndDeleteService();
......
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