OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 // events to the right processors. | 36 // events to the right processors. |
37 class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate, | 37 class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate, |
38 public syncer::WorkerLoopDestructionObserver { | 38 public syncer::WorkerLoopDestructionObserver { |
39 public: | 39 public: |
40 // |name| is used for debugging. Does not take ownership of |profile| or | 40 // |name| is used for debugging. Does not take ownership of |profile| or |
41 // |sync_loop|. Must be created on the UI thread. | 41 // |sync_loop|. Must be created on the UI thread. |
42 SyncBackendRegistrar(const std::string& name, | 42 SyncBackendRegistrar(const std::string& name, |
43 Profile* profile, | 43 Profile* profile, |
44 base::MessageLoop* sync_loop); | 44 base::MessageLoop* sync_loop); |
45 | 45 |
46 // Informs the SyncBackendRegistrar of the currently enabled set of types. | |
47 // These types will be placed in the passive group. This function should be | |
48 // called exactly once during startup. | |
49 void SetInitialTypes(syncer::ModelTypeSet initial_types); | |
50 | |
51 // SyncBackendRegistrar must be destroyed as follows: | 46 // SyncBackendRegistrar must be destroyed as follows: |
52 // | 47 // |
53 // 1) On the sync thread, call OnSyncerShutdownComplete() after | 48 // 1) On the sync thread, call OnSyncerShutdownComplete() after |
54 // the syncer is shutdown. | 49 // the syncer is shutdown. |
55 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which | 50 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which |
56 // blocks until OnSyncerShutdownComplete() is called. | 51 // blocks until OnSyncerShutdownComplete() is called. |
57 // 3) Destroy the SyncBackendRegistrar. | 52 // 3) Destroy the SyncBackendRegistrar. |
58 // | 53 // |
59 // This is to handle the complicated shutdown requirements of the | 54 // This is to handle the complicated shutdown requirements of the |
60 // UIModelWorker (since the UI thread is both the main thread and a | 55 // UIModelWorker (since the UI thread is both the main thread and a |
61 // thread which the syncer pushes changes to). | 56 // thread which the syncer pushes changes to). |
62 virtual ~SyncBackendRegistrar(); | 57 virtual ~SyncBackendRegistrar(); |
63 | 58 |
| 59 // Informs the SyncBackendRegistrar of the currently enabled set of types. |
| 60 // These types will be placed in the passive group. This function should be |
| 61 // called exactly once during startup. |
| 62 void SetInitialTypes(syncer::ModelTypeSet initial_types); |
| 63 |
64 // Returns whether or not we are currently syncing encryption keys. | 64 // Returns whether or not we are currently syncing encryption keys. |
65 // Must be called on the UI thread. | 65 // Must be called on the UI thread. |
66 bool IsNigoriEnabled() const; | 66 bool IsNigoriEnabled() const; |
67 | 67 |
68 // Removes all types in |types_to_remove| from the routing info and | 68 // Removes all types in |types_to_remove| from the routing info and |
69 // adds all the types in |types_to_add| to the routing info that are | 69 // adds all the types in |types_to_add| to the routing info that are |
70 // not already there (initially put in the passive group). | 70 // not already there (initially put in the passive group). |
71 // |types_to_remove| and |types_to_add| must be disjoint. Returns | 71 // |types_to_remove| and |types_to_add| must be disjoint. Returns |
72 // the set of newly-added types. Must be called on the UI thread. | 72 // the set of newly-added types. Must be called on the UI thread. |
73 syncer::ModelTypeSet ConfigureDataTypes( | 73 syncer::ModelTypeSet ConfigureDataTypes( |
74 syncer::ModelTypeSet types_to_add, | 74 syncer::ModelTypeSet types_to_add, |
75 syncer::ModelTypeSet types_to_remove); | 75 syncer::ModelTypeSet types_to_remove); |
76 | 76 |
| 77 // Returns the set of enabled types as of the last configuration. Note that |
| 78 // this might be different from the current types in the routing info due |
| 79 // to DeactiveDataType being called separately from ConfigureDataTypes. |
| 80 syncer::ModelTypeSet GetLastConfiguredTypes() const; |
| 81 |
77 // Must be called from the UI thread. (See destructor comment.) | 82 // Must be called from the UI thread. (See destructor comment.) |
78 void StopOnUIThread(); | 83 void StopOnUIThread(); |
79 | 84 |
80 // Must be called from the sync thread. (See destructor comment.) | 85 // Must be called from the sync thread. (See destructor comment.) |
81 void OnSyncerShutdownComplete(); | 86 void OnSyncerShutdownComplete(); |
82 | 87 |
83 // Activates the given data type (which should belong to the given | 88 // Activates the given data type (which should belong to the given |
84 // group) and starts the given change processor. Must be called | 89 // group) and starts the given change processor. Must be called |
85 // from |group|'s native thread. | 90 // from |group|'s native thread. |
86 void ActivateDataType(syncer::ModelType type, | 91 void ActivateDataType(syncer::ModelType type, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // case, we'll destroy on demand *after* routing any dependent types | 158 // case, we'll destroy on demand *after* routing any dependent types |
154 // to syncer::GROUP_PASSIVE, so that the syncapi doesn't call into garbage. | 159 // to syncer::GROUP_PASSIVE, so that the syncapi doesn't call into garbage. |
155 // If a key is present, it means at least one ModelType that routes | 160 // If a key is present, it means at least one ModelType that routes |
156 // to that model safe group is being synced. | 161 // to that model safe group is being synced. |
157 WorkerMap workers_; | 162 WorkerMap workers_; |
158 syncer::ModelSafeRoutingInfo routing_info_; | 163 syncer::ModelSafeRoutingInfo routing_info_; |
159 | 164 |
160 // The change processors that handle the different data types. | 165 // The change processors that handle the different data types. |
161 std::map<syncer::ModelType, ChangeProcessor*> processors_; | 166 std::map<syncer::ModelType, ChangeProcessor*> processors_; |
162 | 167 |
| 168 // The types that were enabled as of the last configuration. Updated on each |
| 169 // call to ConfigureDataTypes as well as SetInitialTypes. |
| 170 syncer::ModelTypeSet last_configured_types_; |
| 171 |
163 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 172 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
164 }; | 173 }; |
165 | 174 |
166 } // namespace browser_sync | 175 } // namespace browser_sync |
167 | 176 |
168 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 177 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
OLD | NEW |