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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "sync/internal_api/public/base/model_type.h" | 15 #include "sync/internal_api/public/base/model_type.h" |
16 #include "sync/internal_api/public/engine/model_safe_worker.h" | 16 #include "sync/internal_api/public/engine/model_safe_worker.h" |
17 #include "sync/internal_api/public/sync_manager.h" | 17 #include "sync/internal_api/public/sync_manager.h" |
18 | 18 |
| 19 class Profile; |
| 20 |
| 21 namespace base { |
19 class MessageLoop; | 22 class MessageLoop; |
20 class Profile; | 23 } |
21 | 24 |
22 namespace syncer { | 25 namespace syncer { |
23 struct UserShare; | 26 struct UserShare; |
24 } // namespace syncer | 27 } // namespace syncer |
25 | 28 |
26 namespace browser_sync { | 29 namespace browser_sync { |
27 | 30 |
28 class ChangeProcessor; | 31 class ChangeProcessor; |
29 class UIModelWorker; | 32 class UIModelWorker; |
30 | 33 |
31 // A class that keep track of the workers, change processors, and | 34 // A class that keep track of the workers, change processors, and |
32 // routing info for the enabled sync types, and also routes change | 35 // routing info for the enabled sync types, and also routes change |
33 // events to the right processors. | 36 // events to the right processors. |
34 class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate { | 37 class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate { |
35 public: | 38 public: |
36 // |name| is used for debugging. Does not take ownership of |profile| or | 39 // |name| is used for debugging. Does not take ownership of |profile| or |
37 // |sync_loop|. Must be created on the UI thread. | 40 // |sync_loop|. Must be created on the UI thread. |
38 SyncBackendRegistrar(const std::string& name, | 41 SyncBackendRegistrar(const std::string& name, |
39 Profile* profile, | 42 Profile* profile, |
40 MessageLoop* sync_loop); | 43 base::MessageLoop* sync_loop); |
41 | 44 |
42 // Informs the SyncBackendRegistrar of the currently enabled set of types. | 45 // Informs the SyncBackendRegistrar of the currently enabled set of types. |
43 // These types will be placed in the passive group. This function should be | 46 // These types will be placed in the passive group. This function should be |
44 // called exactly once during startup. | 47 // called exactly once during startup. |
45 void SetInitialTypes(syncer::ModelTypeSet initial_types); | 48 void SetInitialTypes(syncer::ModelTypeSet initial_types); |
46 | 49 |
47 // SyncBackendRegistrar must be destroyed as follows: | 50 // SyncBackendRegistrar must be destroyed as follows: |
48 // | 51 // |
49 // 1) On the sync thread, call OnSyncerShutdownComplete() after | 52 // 1) On the sync thread, call OnSyncerShutdownComplete() after |
50 // the syncer is shutdown. | 53 // the syncer is shutdown. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // Return true if |model_type| lives on the current thread. Must be | 124 // Return true if |model_type| lives on the current thread. Must be |
122 // called with |lock_| held. May be called on any thread. | 125 // called with |lock_| held. May be called on any thread. |
123 bool IsCurrentThreadSafeForModel( | 126 bool IsCurrentThreadSafeForModel( |
124 syncer::ModelType model_type) const; | 127 syncer::ModelType model_type) const; |
125 | 128 |
126 // Name used for debugging. | 129 // Name used for debugging. |
127 const std::string name_; | 130 const std::string name_; |
128 | 131 |
129 Profile* const profile_; | 132 Profile* const profile_; |
130 | 133 |
131 MessageLoop* const sync_loop_; | 134 base::MessageLoop* const sync_loop_; |
132 | 135 |
133 const scoped_refptr<UIModelWorker> ui_worker_; | 136 const scoped_refptr<UIModelWorker> ui_worker_; |
134 | 137 |
135 bool stopped_on_ui_thread_; | 138 bool stopped_on_ui_thread_; |
136 | 139 |
137 // Protects all variables below. | 140 // Protects all variables below. |
138 mutable base::Lock lock_; | 141 mutable base::Lock lock_; |
139 | 142 |
140 // We maintain ownership of all workers. In some cases, we need to | 143 // We maintain ownership of all workers. In some cases, we need to |
141 // ensure shutdown occurs in an expected sequence by Stop()ing | 144 // ensure shutdown occurs in an expected sequence by Stop()ing |
(...skipping 10 matching lines...) Expand all Loading... |
152 | 155 |
153 // The change processors that handle the different data types. | 156 // The change processors that handle the different data types. |
154 std::map<syncer::ModelType, ChangeProcessor*> processors_; | 157 std::map<syncer::ModelType, ChangeProcessor*> processors_; |
155 | 158 |
156 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 159 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
157 }; | 160 }; |
158 | 161 |
159 } // namespace browser_sync | 162 } // namespace browser_sync |
160 | 163 |
161 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 164 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
OLD | NEW |