OLD | NEW |
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" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 }; | 48 }; |
49 | 49 |
50 // TODO(akalin): Remove the dependency on |user_share|. | 50 // TODO(akalin): Remove the dependency on |user_share|. |
51 BackendMigrator(const std::string& name, | 51 BackendMigrator(const std::string& name, |
52 sync_api::UserShare* user_share, | 52 sync_api::UserShare* user_share, |
53 ProfileSyncService* service, | 53 ProfileSyncService* service, |
54 DataTypeManager* manager); | 54 DataTypeManager* manager); |
55 virtual ~BackendMigrator(); | 55 virtual ~BackendMigrator(); |
56 | 56 |
57 // Starts a sequence of events that will disable and reenable |types|. | 57 // Starts a sequence of events that will disable and reenable |types|. |
58 void MigrateTypes(syncable::ModelEnumSet types); | 58 void MigrateTypes(syncable::ModelTypeSet types); |
59 | 59 |
60 void AddMigrationObserver(MigrationObserver* observer); | 60 void AddMigrationObserver(MigrationObserver* observer); |
61 bool HasMigrationObserver(MigrationObserver* observer) const; | 61 bool HasMigrationObserver(MigrationObserver* observer) const; |
62 void RemoveMigrationObserver(MigrationObserver* observer); | 62 void RemoveMigrationObserver(MigrationObserver* observer); |
63 | 63 |
64 // content::NotificationObserver implementation. | 64 // content::NotificationObserver implementation. |
65 virtual void Observe(int type, | 65 virtual void Observe(int type, |
66 const content::NotificationSource& source, | 66 const content::NotificationSource& source, |
67 const content::NotificationDetails& details) OVERRIDE; | 67 const content::NotificationDetails& details) OVERRIDE; |
68 | 68 |
69 State state() const; | 69 State state() const; |
70 | 70 |
71 // Returns the types that are currently pending migration (if any). | 71 // Returns the types that are currently pending migration (if any). |
72 syncable::ModelEnumSet GetPendingMigrationTypesForTest() const; | 72 syncable::ModelTypeSet GetPendingMigrationTypesForTest() const; |
73 | 73 |
74 private: | 74 private: |
75 void ChangeState(State new_state); | 75 void ChangeState(State new_state); |
76 | 76 |
77 // Must be called only in state WAITING_TO_START. If ready to | 77 // Must be called only in state WAITING_TO_START. If ready to |
78 // start, meaning the data type manager is configured, calls | 78 // start, meaning the data type manager is configured, calls |
79 // RestartMigration() and returns true. Otherwise, does nothing and | 79 // RestartMigration() and returns true. Otherwise, does nothing and |
80 // returns false. | 80 // returns false. |
81 bool TryStart(); | 81 bool TryStart(); |
82 | 82 |
83 // Restarts migration, interrupting any existing migration. | 83 // Restarts migration, interrupting any existing migration. |
84 void RestartMigration(); | 84 void RestartMigration(); |
85 | 85 |
86 // Called by Observe(). | 86 // Called by Observe(). |
87 void OnConfigureDone(const DataTypeManager::ConfigureResult& result); | 87 void OnConfigureDone(const DataTypeManager::ConfigureResult& result); |
88 | 88 |
89 const std::string name_; | 89 const std::string name_; |
90 sync_api::UserShare* user_share_; | 90 sync_api::UserShare* user_share_; |
91 ProfileSyncService* service_; | 91 ProfileSyncService* service_; |
92 DataTypeManager* manager_; | 92 DataTypeManager* manager_; |
93 | 93 |
94 State state_; | 94 State state_; |
95 | 95 |
96 content::NotificationRegistrar registrar_; | 96 content::NotificationRegistrar registrar_; |
97 | 97 |
98 ObserverList<MigrationObserver> migration_observers_; | 98 ObserverList<MigrationObserver> migration_observers_; |
99 | 99 |
100 syncable::ModelEnumSet to_migrate_; | 100 syncable::ModelTypeSet to_migrate_; |
101 | 101 |
102 base::WeakPtrFactory<BackendMigrator> weak_ptr_factory_; | 102 base::WeakPtrFactory<BackendMigrator> weak_ptr_factory_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(BackendMigrator); | 104 DISALLOW_COPY_AND_ASSIGN(BackendMigrator); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace browser_sync | 107 } // namespace browser_sync |
108 | 108 |
109 #endif // CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ | 109 #endif // CHROME_BROWSER_SYNC_BACKEND_MIGRATOR_H_ |
OLD | NEW |