summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/sync/backend_migrator.cc27
-rw-r--r--chrome/browser/sync/backend_migrator.h22
-rw-r--r--chrome/browser/sync/backend_migrator_unittest.cc13
-rw-r--r--chrome/browser/sync/profile_sync_service.cc22
-rw-r--r--chrome/browser/sync/profile_sync_service.h4
-rw-r--r--chrome/browser/sync/test/integration/migration_errors_test.cc16
-rw-r--r--sync/sessions/sync_session.cc3
7 files changed, 61 insertions, 46 deletions
diff --git a/chrome/browser/sync/backend_migrator.cc b/chrome/browser/sync/backend_migrator.cc
index 26e0b2a..3894bbd 100644
--- a/chrome/browser/sync/backend_migrator.cc
+++ b/chrome/browser/sync/backend_migrator.cc
@@ -28,12 +28,12 @@ MigrationObserver::~MigrationObserver() {}
BackendMigrator::BackendMigrator(const std::string& name,
sync_api::UserShare* user_share,
ProfileSyncService* service,
- DataTypeManager* manager)
+ DataTypeManager* manager,
+ const base::Closure &migration_done_callback)
: name_(name), user_share_(user_share), service_(service),
manager_(manager), state_(IDLE),
- weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
- registrar_.Add(this, chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
- content::Source<DataTypeManager>(manager_));
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ migration_done_callback_(migration_done_callback) {
}
BackendMigrator::~BackendMigrator() {
@@ -120,22 +120,18 @@ void BackendMigrator::RestartMigration() {
}
}
-void BackendMigrator::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, type);
+void BackendMigrator::OnConfigureDone(
+ const DataTypeManager::ConfigureResult& result) {
if (state_ == IDLE)
return;
// |manager_|'s methods aren't re-entrant, and we're notified from
// them, so post a task to avoid problems.
- SDVLOG(1) << "Posting OnConfigureDone from Observer";
+ SDVLOG(1) << "Posting OnConfigureDoneImpl";
MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&BackendMigrator::OnConfigureDone,
- weak_ptr_factory_.GetWeakPtr(),
- *content::Details<DataTypeManager::ConfigureResult>(
- details).ptr()));
+ base::Bind(&BackendMigrator::OnConfigureDoneImpl,
+ weak_ptr_factory_.GetWeakPtr(), result));
}
namespace {
@@ -157,7 +153,7 @@ syncable::ModelTypeSet GetUnsyncedDataTypes(sync_api::UserShare* user_share) {
} // namespace
-void BackendMigrator::OnConfigureDone(
+void BackendMigrator::OnConfigureDoneImpl(
const DataTypeManager::ConfigureResult& result) {
SDVLOG(1) << "OnConfigureDone with requested types "
<< ModelTypeSetToString(result.requested_types)
@@ -221,6 +217,9 @@ void BackendMigrator::OnConfigureDone(
SDVLOG(1) << "BackendMigrator: Migration complete for: "
<< syncable::ModelTypeSetToString(to_migrate_);
to_migrate_.Clear();
+
+ if (!migration_done_callback_.is_null())
+ migration_done_callback_.Run();
}
}
diff --git a/chrome/browser/sync/backend_migrator.h b/chrome/browser/sync/backend_migrator.h
index 4688ce6..d40ddbb 100644
--- a/chrome/browser/sync/backend_migrator.h
+++ b/chrome/browser/sync/backend_migrator.h
@@ -33,7 +33,7 @@ class MigrationObserver {
// A class to perform migration of a datatype pursuant to the 'MIGRATION_DONE'
// code in the sync protocol definition (protocol/sync.proto).
-class BackendMigrator : public content::NotificationObserver {
+class BackendMigrator {
public:
enum State {
IDLE,
@@ -50,7 +50,8 @@ class BackendMigrator : public content::NotificationObserver {
BackendMigrator(const std::string& name,
sync_api::UserShare* user_share,
ProfileSyncService* service,
- DataTypeManager* manager);
+ DataTypeManager* manager,
+ const base::Closure &migration_done_callback);
virtual ~BackendMigrator();
// Starts a sequence of events that will disable and reenable |types|.
@@ -60,13 +61,12 @@ class BackendMigrator : public content::NotificationObserver {
bool HasMigrationObserver(MigrationObserver* observer) const;
void RemoveMigrationObserver(MigrationObserver* observer);
- // content::NotificationObserver implementation.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
State state() const;
+ // Called from ProfileSyncService to notify us of configure done.
+ // Note: We receive these notificiations only when our state is not IDLE.
+ void OnConfigureDone(const DataTypeManager::ConfigureResult& result);
+
// Returns the types that are currently pending migration (if any).
syncable::ModelTypeSet GetPendingMigrationTypesForTest() const;
@@ -82,8 +82,8 @@ class BackendMigrator : public content::NotificationObserver {
// Restarts migration, interrupting any existing migration.
void RestartMigration();
- // Called by Observe().
- void OnConfigureDone(const DataTypeManager::ConfigureResult& result);
+ // Called by OnConfigureDone().
+ void OnConfigureDoneImpl(const DataTypeManager::ConfigureResult& result);
const std::string name_;
sync_api::UserShare* user_share_;
@@ -92,14 +92,14 @@ class BackendMigrator : public content::NotificationObserver {
State state_;
- content::NotificationRegistrar registrar_;
-
ObserverList<MigrationObserver> migration_observers_;
syncable::ModelTypeSet to_migrate_;
base::WeakPtrFactory<BackendMigrator> weak_ptr_factory_;
+ base::Closure migration_done_callback_;
+
DISALLOW_COPY_AND_ASSIGN(BackendMigrator);
};
diff --git a/chrome/browser/sync/backend_migrator_unittest.cc b/chrome/browser/sync/backend_migrator_unittest.cc
index a9cfd34..a9899ac 100644
--- a/chrome/browser/sync/backend_migrator_unittest.cc
+++ b/chrome/browser/sync/backend_migrator_unittest.cc
@@ -47,7 +47,8 @@ class SyncBackendMigratorTest : public testing::Test {
migrator_.reset(
new BackendMigrator(
- "Profile0", test_user_share_.user_share(), service(), manager()));
+ "Profile0", test_user_share_.user_share(), service(), manager(),
+ base::Closure()));
SetUnsyncedTypes(syncable::ModelTypeSet());
}
@@ -76,20 +77,14 @@ class SyncBackendMigratorTest : public testing::Test {
syncable::ModelTypeSet requested_types) {
if (status == DataTypeManager::OK) {
DataTypeManager::ConfigureResult result(status, requested_types);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
- content::Source<DataTypeManager>(&manager_),
- content::Details<const DataTypeManager::ConfigureResult>(&result));
+ migrator_->OnConfigureDone(result);
} else {
std::list<SyncError> errors;
DataTypeManager::ConfigureResult result(
status,
requested_types,
errors);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
- content::Source<DataTypeManager>(&manager_),
- content::Details<const DataTypeManager::ConfigureResult>(&result));
+ migrator_->OnConfigureDone(result);
}
message_loop_.RunAllPending();
}
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 3cc619b..40910f0 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -230,6 +230,11 @@ void ProfileSyncService::TryStart() {
}
}
+void ProfileSyncService::StartSyncingWithServer() {
+ if (backend_.get())
+ backend_->StartSyncingWithServer();
+}
+
void ProfileSyncService::RegisterAuthNotifications() {
TokenService* token_service = TokenServiceFactory::GetForProfile(profile_);
registrar_.Add(this,
@@ -1192,7 +1197,9 @@ void ProfileSyncService::ConfigureDataTypeManager() {
migrator_.reset(
new browser_sync::BackendMigrator(
profile_->GetDebugName(), GetUserShare(),
- this, data_type_manager_.get()));
+ this, data_type_manager_.get(),
+ base::Bind(&ProfileSyncService::StartSyncingWithServer,
+ base::Unretained(this))));
}
const syncable::ModelTypeSet types = GetPreferredDataTypes();
@@ -1456,10 +1463,15 @@ void ProfileSyncService::Observe(int type,
backend_->EnableEncryptEverything();
NotifyObservers();
- // In the old world, this would be a no-op. With new syncer thread,
- // this is the point where it is safe to switch from config-mode to
- // normal operation.
- backend_->StartSyncingWithServer();
+ if (migrator_.get() &&
+ migrator_->state() != browser_sync::BackendMigrator::IDLE) {
+ // Migration in progress. Let the migrator know we just finished
+ // configuring something. It will be up to the migrator to call
+ // StartSyncingWithServer() if migration is now finished.
+ migrator_->OnConfigureDone(*result);
+ } else {
+ StartSyncingWithServer();
+ }
break;
}
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index bfbeb92..0abf55d 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -562,6 +562,10 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// Called from Initialize() and UnsuppressAndStart().
void TryStart();
+ // Puts the backend's sync scheduler into NORMAL mode.
+ // Called when configuration is complete.
+ void StartSyncingWithServer();
+
// Called when we've determined that we don't need a passphrase (either
// because OnPassphraseAccepted() was called, or because we've gotten a
// OnPassphraseRequired() but no data types are enabled).
diff --git a/chrome/browser/sync/test/integration/migration_errors_test.cc b/chrome/browser/sync/test/integration/migration_errors_test.cc
index 10acde3..abfca57 100644
--- a/chrome/browser/sync/test/integration/migration_errors_test.cc
+++ b/chrome/browser/sync/test/integration/migration_errors_test.cc
@@ -251,13 +251,15 @@ IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, BookmarksPrefsBoth) {
// Two data types with one being nigori.
-IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsNigoriIndividiaully) {
+IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
+ DISABLED_PrefsNigoriIndividiaully) {
RunSingleClientMigrationTest(
MakeList(syncable::PREFERENCES, syncable::NIGORI),
TRIGGER_NOTIFICATION);
}
-IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsNigoriBoth) {
+// TODO(rlarocque): Re-enable this test when crbug.com/122033 is fixed.
+IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, DISABLED_PrefsNigoriBoth) {
RunSingleClientMigrationTest(
MakeList(MakeSet(syncable::PREFERENCES, syncable::NIGORI)),
MODIFY_PREF);
@@ -293,14 +295,16 @@ IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
// All data types plus nigori.
IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
- AllTypesWithNigoriIndividually) {
+ DISABLED_AllTypesWithNigoriIndividually) {
ASSERT_TRUE(SetupClients());
MigrationList migration_list = GetPreferredDataTypesList();
migration_list.push_front(MakeSet(syncable::NIGORI));
RunSingleClientMigrationTest(migration_list, MODIFY_BOOKMARK);
}
-IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesWithNigoriAtOnce) {
+// TODO(rlarocque): Re-enable this test when crbug.com/122033 is fixed.
+IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
+ DISABLED_AllTypesWithNigoriAtOnce) {
ASSERT_TRUE(SetupClients());
syncable::ModelTypeSet all_types = GetPreferredDataTypes();
all_types.Put(syncable::NIGORI);
@@ -374,7 +378,9 @@ IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest, MigrationHellWithoutNigori) {
RunTwoClientMigrationTest(migration_list, MODIFY_BOOKMARK);
}
-IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest, MigrationHellWithNigori) {
+// TODO(rlarocque) Re-enable this test when crbug.com/122033 is fixed.
+IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest,
+ DISABLED_MigrationHellWithNigori) {
ASSERT_TRUE(SetupClients());
MigrationList migration_list = GetPreferredDataTypesList();
// Let the first nudge be a datatype that's neither prefs nor
diff --git a/sync/sessions/sync_session.cc b/sync/sessions/sync_session.cc
index c557862..0d5835e 100644
--- a/sync/sessions/sync_session.cc
+++ b/sync/sessions/sync_session.cc
@@ -234,8 +234,7 @@ namespace {
//
bool IsError(SyncerError error) {
return error != UNSET
- && error != SYNCER_OK
- && error != SERVER_RETURN_MIGRATION_DONE;
+ && error != SYNCER_OK;
}
} // namespace