Chromium Code Reviews| Index: chrome/browser/sync/backend_migrator.h |
| diff --git a/chrome/browser/sync/backend_migrator.h b/chrome/browser/sync/backend_migrator.h |
| index d3314aa94f0ff19674a04de6f9aac5c147a33683..a52a9ee8baad70ffe08348043846f0c6e356e88e 100644 |
| --- a/chrome/browser/sync/backend_migrator.h |
| +++ b/chrome/browser/sync/backend_migrator.h |
| @@ -5,8 +5,10 @@ |
| #ifndef CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ |
| #define CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/task.h" |
| -#include "chrome/browser/sync/profile_sync_service_observer.h" |
| +#include "chrome/browser/sync/glue/data_type_manager.h" |
| #include "chrome/browser/sync/syncable/model_type.h" |
| #include "content/common/notification_observer.h" |
| #include "content/common/notification_registrar.h" |
| @@ -15,20 +17,15 @@ class ProfileSyncService; |
| namespace browser_sync { |
| -class DataTypeManager; |
| - |
| // 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 NotificationObserver, |
| - public ProfileSyncServiceObserver { |
| +class BackendMigrator : public NotificationObserver { |
| public: |
| enum State { |
| IDLE, |
| WAITING_TO_START, // Waiting for previous configuration to finish. |
| DISABLING_TYPES, // Exit criteria: SYNC_CONFIGURE_DONE for enabled |
| // types _excluding_ |to_migrate_|. |
| - WAITING_FOR_PURGE, // Exit criteria: SyncCycleEnded for enabled types |
| - // excluding |to_migrate| |
| REENABLING_TYPES, // Exit criteria: SYNC_CONFIGURE_DONE for enabled |
| // types. |
| }; |
| @@ -39,18 +36,23 @@ class BackendMigrator : public NotificationObserver, |
| // Starts a sequence of events that will disable and reenable |types|. |
| void MigrateTypes(const syncable::ModelTypeSet& types); |
| - // ProfileSyncServiceObserver implementation. |
| - virtual void OnStateChanged(); |
| - |
| // NotificationObserver implementation. |
| virtual void Observe(int type, |
| const NotificationSource& source, |
| - const NotificationDetails& details); |
| + const NotificationDetails& details) OVERRIDE; |
| State state() const; |
| private: |
| - bool HasStartedMigrating() const; |
| + // Must be called only in state WAITING_TO_START. If ready to |
| + // start, calls RestartMigration() (which advances the state). |
| + void TryStart(); |
|
tim (not reviewing)
2011/08/22 15:08:49
This comment should specify what the start conditi
akalin
2011/08/24 22:50:17
Done.
|
| + |
| + // Restarts migration, interrupting any existing migration. |
| + void RestartMigration(); |
| + |
| + // Called by Observe(). |
| + void OnConfigureDone(const DataTypeManager::ConfigureResult& result); |
| State state_; |
| ProfileSyncService* service_; |
| @@ -58,10 +60,8 @@ class BackendMigrator : public NotificationObserver, |
| NotificationRegistrar registrar_; |
| syncable::ModelTypeSet to_migrate_; |
| - bool restart_migration_; |
| - // We use this to gracefully re-start migrations. |
| - ScopedRunnableMethodFactory<BackendMigrator> method_factory_; |
| + base::WeakPtrFactory<BackendMigrator> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(BackendMigrator); |
| }; |