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 16 matching lines...) Expand all Loading... |
27 } // namespace syncer | 27 } // namespace syncer |
28 | 28 |
29 namespace browser_sync { | 29 namespace browser_sync { |
30 | 30 |
31 class ChangeProcessor; | 31 class ChangeProcessor; |
32 class UIModelWorker; | 32 class UIModelWorker; |
33 | 33 |
34 // A class that keep track of the workers, change processors, and | 34 // A class that keep track of the workers, change processors, and |
35 // routing info for the enabled sync types, and also routes change | 35 // routing info for the enabled sync types, and also routes change |
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: | 39 public: |
39 // |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 |
40 // |sync_loop|. Must be created on the UI thread. | 41 // |sync_loop|. Must be created on the UI thread. |
41 SyncBackendRegistrar(const std::string& name, | 42 SyncBackendRegistrar(const std::string& name, |
42 Profile* profile, | 43 Profile* profile, |
43 base::MessageLoop* sync_loop); | 44 base::MessageLoop* sync_loop); |
44 | 45 |
45 // Informs the SyncBackendRegistrar of the currently enabled set of types. | 46 // Informs the SyncBackendRegistrar of the currently enabled set of types. |
46 // These types will be placed in the passive group. This function should be | 47 // These types will be placed in the passive group. This function should be |
47 // called exactly once during startup. | 48 // called exactly once during startup. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 virtual void OnChangesApplied( | 102 virtual void OnChangesApplied( |
102 syncer::ModelType model_type, | 103 syncer::ModelType model_type, |
103 int64 model_version, | 104 int64 model_version, |
104 const syncer::BaseTransaction* trans, | 105 const syncer::BaseTransaction* trans, |
105 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; | 106 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; |
106 virtual void OnChangesComplete(syncer::ModelType model_type) OVERRIDE; | 107 virtual void OnChangesComplete(syncer::ModelType model_type) OVERRIDE; |
107 | 108 |
108 void GetWorkers(std::vector<syncer::ModelSafeWorker*>* out); | 109 void GetWorkers(std::vector<syncer::ModelSafeWorker*>* out); |
109 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out); | 110 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out); |
110 | 111 |
| 112 // syncer::WorkerLoopDestructionObserver implementation. |
| 113 virtual void OnWorkerLoopDestroyed(syncer::ModelSafeGroup group) OVERRIDE; |
| 114 |
111 private: | 115 private: |
112 typedef std::map<syncer::ModelSafeGroup, | 116 typedef std::map<syncer::ModelSafeGroup, |
113 scoped_refptr<syncer::ModelSafeWorker> > WorkerMap; | 117 scoped_refptr<syncer::ModelSafeWorker> > WorkerMap; |
114 | 118 |
115 // Returns the change processor for the given model, or NULL if none | 119 // Returns the change processor for the given model, or NULL if none |
116 // exists. Must be called from |group|'s native thread. | 120 // exists. Must be called from |group|'s native thread. |
117 ChangeProcessor* GetProcessor(syncer::ModelType type) const; | 121 ChangeProcessor* GetProcessor(syncer::ModelType type) const; |
118 | 122 |
119 // Must be called with |lock_| held. Simply returns the change | 123 // Must be called with |lock_| held. Simply returns the change |
120 // processor for the given type, if it exists. May be called from | 124 // processor for the given type, if it exists. May be called from |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 159 |
156 // The change processors that handle the different data types. | 160 // The change processors that handle the different data types. |
157 std::map<syncer::ModelType, ChangeProcessor*> processors_; | 161 std::map<syncer::ModelType, ChangeProcessor*> processors_; |
158 | 162 |
159 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 163 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
160 }; | 164 }; |
161 | 165 |
162 } // namespace browser_sync | 166 } // namespace browser_sync |
163 | 167 |
164 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 168 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
OLD | NEW |