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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... | |
27 namespace browser_sync { | 27 namespace browser_sync { |
28 | 28 |
29 class ChangeProcessor; | 29 class ChangeProcessor; |
30 class UIModelWorker; | 30 class UIModelWorker; |
31 | 31 |
32 // A class that keep track of the workers, change processors, and | 32 // A class that keep track of the workers, change processors, and |
33 // routing info for the enabled sync types, and also routes change | 33 // routing info for the enabled sync types, and also routes change |
34 // events to the right processors. | 34 // events to the right processors. |
35 class SyncBackendRegistrar : public sync_api::SyncManager::ChangeDelegate { | 35 class SyncBackendRegistrar : public sync_api::SyncManager::ChangeDelegate { |
36 public: | 36 public: |
37 // |initial_types| contains the initial set of types to sync | 37 // |name| is used for debugging. Does not take ownership of |profile| or |
38 // (initially put in the passive group). |name| is used for | 38 // |sync_loop|. Must be created on the UI thread. |
39 // debugging. Does not take ownership of |profile| or |sync_loop|. | 39 SyncBackendRegistrar(const std::string& name, |
40 // Must be created on the UI thread. | |
41 SyncBackendRegistrar(syncable::ModelTypeSet initial_types, | |
42 const std::string& name, | |
43 Profile* profile, | 40 Profile* profile, |
44 MessageLoop* sync_loop); | 41 MessageLoop* sync_loop); |
45 | 42 |
46 // SyncBackendRegistrar must be destroyed as follows: | 43 // SyncBackendRegistrar must be destroyed as follows: |
47 // | 44 // |
48 // 1) On the sync thread, call OnSyncerShutdownComplete() after | 45 // 1) On the sync thread, call OnSyncerShutdownComplete() after |
49 // the syncer is shutdown. | 46 // the syncer is shutdown. |
50 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which | 47 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which |
51 // blocks until OnSyncerShutdownComplete() is called. | 48 // blocks until OnSyncerShutdownComplete() is called. |
52 // 3) Destroy the SyncBackendRegistrar. | 49 // 3) Destroy the SyncBackendRegistrar. |
53 // | 50 // |
54 // This is to handle the complicated shutdown requirements of the | 51 // This is to handle the complicated shutdown requirements of the |
55 // UIModelWorker (since the UI thread is both the main thread and a | 52 // UIModelWorker (since the UI thread is both the main thread and a |
56 // thread which the syncer pushes changes to). | 53 // thread which the syncer pushes changes to). |
57 virtual ~SyncBackendRegistrar(); | 54 virtual ~SyncBackendRegistrar(); |
58 | 55 |
56 // Informs the SyncBackendRegistrar of the currently enabled set of types. | |
57 // These types will be placed in the passive group. This function should be | |
58 // called exactly once during startup. | |
59 void SetInitialTypes(syncable::ModelTypeSet initial_types); | |
rlarocque
2012/06/04 20:07:09
I'm not a fan of this two-stage init. It may be p
| |
60 | |
59 // Returns whether or not we are currently syncing encryption keys. | 61 // Returns whether or not we are currently syncing encryption keys. |
60 // Must be called on the UI thread. | 62 // Must be called on the UI thread. |
61 bool IsNigoriEnabled() const; | 63 bool IsNigoriEnabled() const; |
62 | 64 |
63 // Removes all types in |types_to_remove| from the routing info and | 65 // Removes all types in |types_to_remove| from the routing info and |
64 // adds all the types in |types_to_add| to the routing info that are | 66 // adds all the types in |types_to_add| to the routing info that are |
65 // not already there (initially put in the passive group). | 67 // not already there (initially put in the passive group). |
66 // |types_to_remove| and |types_to_add| must be disjoint. Returns | 68 // |types_to_remove| and |types_to_add| must be disjoint. Returns |
67 // the set of newly-added types. Must be called on the UI thread. | 69 // the set of newly-added types. Must be called on the UI thread. |
68 syncable::ModelTypeSet ConfigureDataTypes( | 70 syncable::ModelTypeSet ConfigureDataTypes( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 | 152 |
151 // The change processors that handle the different data types. | 153 // The change processors that handle the different data types. |
152 std::map<syncable::ModelType, ChangeProcessor*> processors_; | 154 std::map<syncable::ModelType, ChangeProcessor*> processors_; |
153 | 155 |
154 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 156 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
155 }; | 157 }; |
156 | 158 |
157 } // namespace browser_sync | 159 } // namespace browser_sync |
158 | 160 |
159 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 161 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
OLD | NEW |