diff options
author | nyquist@chromium.org <nyquist@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 20:10:16 +0000 |
---|---|---|
committer | nyquist@chromium.org <nyquist@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 20:10:16 +0000 |
commit | fc2137739ecaee6b917460f4de75ec2587b94824 (patch) | |
tree | 5557aea95843cadd7ab90afb7f8be10c75889d3e | |
parent | db0d2edeb44682531b95083ab394d993d3849682 (diff) | |
download | chromium_src-fc2137739ecaee6b917460f4de75ec2587b94824.zip chromium_src-fc2137739ecaee6b917460f4de75ec2587b94824.tar.gz chromium_src-fc2137739ecaee6b917460f4de75ec2587b94824.tar.bz2 |
[sync] Make SetSetupInProgress kick sync engine when needed
When we clear the sync setup_in_progress flag, and the sync engine is
not already initialized, we should should set the sync setup completed
flag, and kick the sync engine.
BUG=None
TEST=unit_tests
Review URL: https://chromiumcodereview.appspot.com/10534075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141952 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 25 insertions, 20 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 4ddaf6d..ebdc8d4 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -1001,6 +1001,15 @@ bool ProfileSyncService::FirstSetupInProgress() const { return !HasSyncSetupCompleted() && setup_in_progress_; } +void ProfileSyncService::SetSetupInProgress(bool setup_in_progress) { + setup_in_progress_ = setup_in_progress; + if (!setup_in_progress) { + if (sync_initialized()) { + ReconfigureDatatypeManager(); + } + } +} + bool ProfileSyncService::sync_initialized() const { return backend_initialized_; } diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index c446046..d00dac6 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -279,9 +279,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend, // downloading data types yet (we don't start syncing until after sync setup // is complete). The UI calls this as soon as any part of the signin wizard is // displayed (even just the login UI). - void set_setup_in_progress(bool setup_in_progress) { - setup_in_progress_ = setup_in_progress; - } + // If |setup_in_progress| is false, this also kicks the sync engine to ensure + // that data download starts. + virtual void SetSetupInProgress(bool setup_in_progress); // Returns true if the SyncBackendHost has told us it's ready to accept // changes. diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc index 5e4c33b..e337b51 100644 --- a/chrome/browser/sync/profile_sync_service_harness.cc +++ b/chrome/browser/sync/profile_sync_service_harness.cc @@ -171,7 +171,7 @@ bool ProfileSyncServiceHarness::SetupSync( // Tell the sync service that setup is in progress so we don't start syncing // until we've finished configuration. - service_->set_setup_in_progress(true); + service_->SetSetupInProgress(true); // Authenticate sync client using GAIA credentials. if (!CommandLine::ForCurrentProcess()->HasSwitch( @@ -238,7 +238,7 @@ bool ProfileSyncServiceHarness::SetupSync( } // Notify ProfileSyncService that we are done with configuration. - service_->set_setup_in_progress(false); + service_->SetSetupInProgress(false); // Indicate to the browser that sync setup is complete. service()->SetSyncSetupCompleted(); diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index 52d6406..fd20ff5 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc @@ -152,15 +152,13 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) { // Create some tokens in the token service; the service will startup when // it is notified that tokens are available. - service_->set_setup_in_progress(true); + service_->SetSetupInProgress(true); service_->signin()->StartSignIn("test_user", "", "", ""); TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( GaiaConstants::kSyncService, "sync_token"); TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token"); - service_->set_setup_in_progress(false); - service_->OnUserChoseDatatypes( - false, syncable::ModelTypeSet(syncable::BOOKMARKS)); + service_->SetSetupInProgress(false); EXPECT_TRUE(service_->ShouldPushChanges()); } @@ -193,7 +191,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) { EXPECT_CALL(*data_type_manager, Stop()).Times(1); EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); - service_->set_setup_in_progress(true); + service_->SetSetupInProgress(true); service_->signin()->StartSignIn("test_user", "", "", ""); // NOTE: Unlike StartFirstTime, this test does not issue any auth tokens. content::NotificationService::current()->Notify( @@ -201,9 +199,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) { content::Source<TokenService>( TokenServiceFactory::GetForProfile(profile_.get())), content::NotificationService::NoDetails()); - service_->set_setup_in_progress(false); - service_->OnUserChoseDatatypes( - false, syncable::ModelTypeSet(syncable::BOOKMARKS)); + service_->SetSetupInProgress(false); // Backend should initialize using a bogus GAIA token for credentials. EXPECT_TRUE(service_->ShouldPushChanges()); } @@ -222,7 +218,7 @@ TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { content::Source<TokenService>( TokenServiceFactory::GetForProfile(profile_.get())), content::NotificationService::NoDetails()); - service_->set_setup_in_progress(false); + service_->SetSetupInProgress(false); // Sync should not start because there are still no tokens. EXPECT_FALSE(service_->ShouldPushChanges()); EXPECT_FALSE(service_->GetBackendForTest()); diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc index 29baed14..3f00d89 100644 --- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc +++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc @@ -35,7 +35,7 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter( ProfileSyncServiceFactory::GetForProfile(profile_); // Let the sync service know that setup is in progress so it doesn't start // syncing until the user has finished any configuration. - profile_sync_service->set_setup_in_progress(true); + profile_sync_service->SetSetupInProgress(true); SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); manager->StartSignInWithCredentials(session_index, email, password); } @@ -50,7 +50,7 @@ void OneClickSigninSyncStarter::SigninFailed( const GoogleServiceAuthError& error) { ProfileSyncService* profile_sync_service = ProfileSyncServiceFactory::GetForProfile(profile_); - profile_sync_service->set_setup_in_progress(false); + profile_sync_service->SetSetupInProgress(false); delete this; } @@ -61,7 +61,7 @@ void OneClickSigninSyncStarter::SigninSuccess() { if (start_mode_ == SYNC_WITH_DEFAULT_SETTINGS) { // Just kick off the sync machine, no need to configure it first. profile_sync_service->SetSyncSetupCompleted(); - profile_sync_service->set_setup_in_progress(false); + profile_sync_service->SetSetupInProgress(false); profile_sync_service->UnsuppressAndStart(); } else { // Give the user a chance to configure things. We don't clear the diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc index dfc6dfe0..94d4eda 100644 --- a/chrome/browser/ui/webui/sync_setup_handler.cc +++ b/chrome/browser/ui/webui/sync_setup_handler.cc @@ -862,7 +862,7 @@ void SyncSetupHandler::CloseSyncSetup() { // Let the various services know that we're no longer active. GetLoginUIService()->LoginUIClosed(this); if (sync_service) - sync_service->set_setup_in_progress(false); + sync_service->SetSetupInProgress(false); // Make sure user isn't left half-logged-in (signed in, but without sync // started up). If the user hasn't finished setting up sync, then sign out @@ -912,7 +912,7 @@ void SyncSetupHandler::OpenSyncSetup(bool force_login) { // Notify services that we are now active. GetLoginUIService()->SetLoginUI(this); - service->set_setup_in_progress(true); + service->SetSetupInProgress(true); // There are several different UI flows that can bring the user here: // 1) Signin promo (passes force_login=true) @@ -955,7 +955,7 @@ void SyncSetupHandler::PrepareConfigDialog() { signin_tracker_.reset( new SigninTracker(GetProfile(), this, SigninTracker::SERVICES_INITIALIZING)); - service->set_setup_in_progress(true); + service->SetSetupInProgress(true); service->UnsuppressAndStart(); DisplaySpinner(); } else { |