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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_
6 #define CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ 6 #define CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_
7 7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
8 #include "base/task.h" 10 #include "base/task.h"
9 #include "chrome/browser/sync/profile_sync_service_observer.h" 11 #include "chrome/browser/sync/glue/data_type_manager.h"
10 #include "chrome/browser/sync/syncable/model_type.h" 12 #include "chrome/browser/sync/syncable/model_type.h"
11 #include "content/common/notification_observer.h" 13 #include "content/common/notification_observer.h"
12 #include "content/common/notification_registrar.h" 14 #include "content/common/notification_registrar.h"
13 15
14 class ProfileSyncService; 16 class ProfileSyncService;
15 17
16 namespace browser_sync { 18 namespace browser_sync {
17 19
18 class DataTypeManager;
19
20 // A class to perform migration of a datatype pursuant to the 'MIGRATION_DONE' 20 // A class to perform migration of a datatype pursuant to the 'MIGRATION_DONE'
21 // code in the sync protocol definition (protocol/sync.proto). 21 // code in the sync protocol definition (protocol/sync.proto).
22 class BackendMigrator : public NotificationObserver, 22 class BackendMigrator : public NotificationObserver {
23 public ProfileSyncServiceObserver {
24 public: 23 public:
25 enum State { 24 enum State {
26 IDLE, 25 IDLE,
27 WAITING_TO_START, // Waiting for previous configuration to finish. 26 WAITING_TO_START, // Waiting for previous configuration to finish.
28 DISABLING_TYPES, // Exit criteria: SYNC_CONFIGURE_DONE for enabled 27 DISABLING_TYPES, // Exit criteria: SYNC_CONFIGURE_DONE for enabled
29 // types _excluding_ |to_migrate_|. 28 // types _excluding_ |to_migrate_|.
30 WAITING_FOR_PURGE, // Exit criteria: SyncCycleEnded for enabled types
31 // excluding |to_migrate|
32 REENABLING_TYPES, // Exit criteria: SYNC_CONFIGURE_DONE for enabled 29 REENABLING_TYPES, // Exit criteria: SYNC_CONFIGURE_DONE for enabled
33 // types. 30 // types.
34 }; 31 };
35 32
36 BackendMigrator(ProfileSyncService* service, DataTypeManager* manager); 33 BackendMigrator(ProfileSyncService* service, DataTypeManager* manager);
37 virtual ~BackendMigrator(); 34 virtual ~BackendMigrator();
38 35
39 // Starts a sequence of events that will disable and reenable |types|. 36 // Starts a sequence of events that will disable and reenable |types|.
40 void MigrateTypes(const syncable::ModelTypeSet& types); 37 void MigrateTypes(const syncable::ModelTypeSet& types);
41 38
42 // ProfileSyncServiceObserver implementation.
43 virtual void OnStateChanged();
44
45 // NotificationObserver implementation. 39 // NotificationObserver implementation.
46 virtual void Observe(int type, 40 virtual void Observe(int type,
47 const NotificationSource& source, 41 const NotificationSource& source,
48 const NotificationDetails& details); 42 const NotificationDetails& details) OVERRIDE;
49 43
50 State state() const; 44 State state() const;
51 45
52 private: 46 private:
53 bool HasStartedMigrating() const; 47 // Must be called only in state WAITING_TO_START. If ready to
48 // start, calls RestartMigration() (which advances the state).
49 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.
50
51 // Restarts migration, interrupting any existing migration.
52 void RestartMigration();
53
54 // Called by Observe().
55 void OnConfigureDone(const DataTypeManager::ConfigureResult& result);
54 56
55 State state_; 57 State state_;
56 ProfileSyncService* service_; 58 ProfileSyncService* service_;
57 DataTypeManager* manager_; 59 DataTypeManager* manager_;
58 NotificationRegistrar registrar_; 60 NotificationRegistrar registrar_;
59 61
60 syncable::ModelTypeSet to_migrate_; 62 syncable::ModelTypeSet to_migrate_;
61 bool restart_migration_;
62 63
63 // We use this to gracefully re-start migrations. 64 base::WeakPtrFactory<BackendMigrator> weak_ptr_factory_;
64 ScopedRunnableMethodFactory<BackendMigrator> method_factory_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(BackendMigrator); 66 DISALLOW_COPY_AND_ASSIGN(BackendMigrator);
67 }; 67 };
68 68
69 } // namespace browser_sync 69 } // namespace browser_sync
70 70
71 #endif // CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ 71 #endif // CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_
OLDNEW
« 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