Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Unified Diff: chrome/browser/sync/backend_migrator.h

Issue 7655055: [Sync] Make BackendMigrator not wait for full sync cycles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sync/backend_migrator.cc » ('j') | chrome/browser/sync/backend_migrator.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « no previous file | chrome/browser/sync/backend_migrator.cc » ('j') | chrome/browser/sync/backend_migrator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698