OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
18 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
19 #include "sync/internal_api/public/engine/model_safe_worker.h" | 20 #include "sync/internal_api/public/engine/model_safe_worker.h" |
20 #include "sync/internal_api/public/sync_manager.h" | 21 #include "sync/internal_api/public/sync_manager.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // 2) UI posts task to shut down syncer on sync thread. | 61 // 2) UI posts task to shut down syncer on sync thread. |
61 // 3) If sync is disabled, call ReleaseSyncThread() on the UI thread. | 62 // 3) If sync is disabled, call ReleaseSyncThread() on the UI thread. |
62 // 3) UI posts SyncBackendRegistrar::ShutDown() on sync thread to | 63 // 3) UI posts SyncBackendRegistrar::ShutDown() on sync thread to |
63 // unregister workers from observing destruction of their working loops. | 64 // unregister workers from observing destruction of their working loops. |
64 // 4) Workers notify registrar when unregistration finishes or working | 65 // 4) Workers notify registrar when unregistration finishes or working |
65 // loops are destroyed. Registrar destroys itself on last worker | 66 // loops are destroyed. Registrar destroys itself on last worker |
66 // notification. Sync thread will be stopped if ownership was not | 67 // notification. Sync thread will be stopped if ownership was not |
67 // released. | 68 // released. |
68 ~SyncBackendRegistrar() override; | 69 ~SyncBackendRegistrar() override; |
69 | 70 |
| 71 // Adds |type| to set of non-blocking types. These types are assigned to |
| 72 // GROUP_NON_BLOCKING model safe group and will be treated differently in |
| 73 // ModelTypeRegistry. Unlike directory types, non-blocking types always stay |
| 74 // assigned to GROUP_NON_BLOCKING group. |
| 75 void RegisterNonBlockingType(syncer::ModelType type); |
| 76 |
70 // Informs the SyncBackendRegistrar of the currently enabled set of types. | 77 // Informs the SyncBackendRegistrar of the currently enabled set of types. |
71 // These types will be placed in the passive group. This function should be | 78 // These types will be placed in the passive group. This function should be |
72 // called exactly once during startup. | 79 // called exactly once during startup. |
73 void SetInitialTypes(syncer::ModelTypeSet initial_types); | 80 void SetInitialTypes(syncer::ModelTypeSet initial_types); |
74 | 81 |
75 // Returns whether or not we are currently syncing encryption keys. | 82 // Returns whether or not we are currently syncing encryption keys. |
76 // Must be called on the UI thread. | 83 // Must be called on the UI thread. |
77 bool IsNigoriEnabled() const; | 84 bool IsNigoriEnabled() const; |
78 | 85 |
79 // Removes all types in |types_to_remove| from the routing info and | 86 // Removes all types in |types_to_remove| from the routing info and |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 166 |
160 // Return true if |model_type| lives on the current thread. Must be | 167 // Return true if |model_type| lives on the current thread. Must be |
161 // called with |lock_| held. May be called on any thread. | 168 // called with |lock_| held. May be called on any thread. |
162 bool IsCurrentThreadSafeForModel(syncer::ModelType model_type) const; | 169 bool IsCurrentThreadSafeForModel(syncer::ModelType model_type) const; |
163 | 170 |
164 // Returns true if the current thread is the native thread for the | 171 // Returns true if the current thread is the native thread for the |
165 // given group (or if it is undeterminable). | 172 // given group (or if it is undeterminable). |
166 bool IsOnThreadForGroup(syncer::ModelType type, | 173 bool IsOnThreadForGroup(syncer::ModelType type, |
167 syncer::ModelSafeGroup group) const; | 174 syncer::ModelSafeGroup group) const; |
168 | 175 |
| 176 // Returns model safe group that should be assigned to type when it is first |
| 177 // configured (before activation). Returns GROUP_PASSIVE for directory types |
| 178 // and GROUP_NON_BLOCKING for non-blocking types. |
| 179 syncer::ModelSafeGroup GetInitialGroupForType(syncer::ModelType type) const; |
| 180 |
169 // Name used for debugging. | 181 // Name used for debugging. |
170 const std::string name_; | 182 const std::string name_; |
171 | 183 |
172 // A pointer to the sync client. | 184 // A pointer to the sync client. |
173 sync_driver::SyncClient* const sync_client_; | 185 sync_driver::SyncClient* const sync_client_; |
174 | 186 |
175 // Protects all variables below. | 187 // Protects all variables below. |
176 mutable base::Lock lock_; | 188 mutable base::Lock lock_; |
177 | 189 |
178 // We maintain ownership of all workers. In some cases, we need to | 190 // We maintain ownership of all workers. In some cases, we need to |
(...skipping 23 matching lines...) Expand all Loading... |
202 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; | 214 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; |
203 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 215 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
204 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; | 216 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; |
205 | 217 |
206 // Declare |sync_thread_| at the end so that it will be destroyed before | 218 // Declare |sync_thread_| at the end so that it will be destroyed before |
207 // objects above because tasks on sync thread depend on those objects, | 219 // objects above because tasks on sync thread depend on those objects, |
208 // e.g. Shutdown() depends on |lock_|, SyncManager::Init() depends on | 220 // e.g. Shutdown() depends on |lock_|, SyncManager::Init() depends on |
209 // workers, etc. | 221 // workers, etc. |
210 scoped_ptr<base::Thread> sync_thread_; | 222 scoped_ptr<base::Thread> sync_thread_; |
211 | 223 |
| 224 // Set of types with non-blocking implementation (as opposed to directory |
| 225 // based). |
| 226 syncer::ModelTypeSet non_blocking_types_; |
| 227 |
212 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 228 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
213 }; | 229 }; |
214 | 230 |
215 } // namespace browser_sync | 231 } // namespace browser_sync |
216 | 232 |
217 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 233 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
OLD | NEW |