Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 18 matching lines...) Expand all Loading... | |
| 29 class UIModelWorker; | 29 class UIModelWorker; |
| 30 | 30 |
| 31 // A class to keep track of the workers and routing info for the | 31 // A class to keep track of the workers and routing info for the |
| 32 // enabled sync types. | 32 // enabled sync types. |
| 33 class SyncBackendRegistrar : public ModelSafeWorkerRegistrar { | 33 class SyncBackendRegistrar : public ModelSafeWorkerRegistrar { |
| 34 public: | 34 public: |
| 35 // |initial_types| contains the initial set of types to sync | 35 // |initial_types| contains the initial set of types to sync |
| 36 // (initially put in the passive group). Does not take ownership of | 36 // (initially put in the passive group). Does not take ownership of |
| 37 // |profile| or |sync_loop|. Must be created on the UI thread. | 37 // |profile| or |sync_loop|. Must be created on the UI thread. |
| 38 SyncBackendRegistrar(const syncable::ModelTypeSet& initial_types, | 38 SyncBackendRegistrar(const syncable::ModelTypeSet& initial_types, |
| 39 const std::string& name, | |
|
tim (not reviewing)
2011/08/31 23:18:02
Name of what?
akalin
2011/09/01 01:38:40
Added comments.
| |
| 39 Profile* profile, | 40 Profile* profile, |
| 40 MessageLoop* sync_loop); | 41 MessageLoop* sync_loop); |
| 41 | 42 |
| 42 // SyncBackendRegistrar must be destroyed as follows: | 43 // SyncBackendRegistrar must be destroyed as follows: |
| 43 // | 44 // |
| 44 // 1) On the sync thread, call OnSyncerShutdownComplete() after | 45 // 1) On the sync thread, call OnSyncerShutdownComplete() after |
| 45 // the syncer is shutdown. | 46 // the syncer is shutdown. |
| 46 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which | 47 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which |
| 47 // blocks until OnSyncerShutdownComplete() is called. | 48 // blocks until OnSyncerShutdownComplete() is called. |
| 48 // 3) Destroy the SyncBackendRegistrar. | 49 // 3) Destroy the SyncBackendRegistrar. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 // Must be called with |lock_| held. Simply returns the change | 102 // Must be called with |lock_| held. Simply returns the change |
| 102 // processor for the given type, if it exists. May be called from | 103 // processor for the given type, if it exists. May be called from |
| 103 // any thread. | 104 // any thread. |
| 104 ChangeProcessor* GetProcessorUnsafe(syncable::ModelType type); | 105 ChangeProcessor* GetProcessorUnsafe(syncable::ModelType type); |
| 105 | 106 |
| 106 // Return true if |model_type| lives on the current thread. Must be | 107 // Return true if |model_type| lives on the current thread. Must be |
| 107 // called with |lock_| held. May be called on any thread. | 108 // called with |lock_| held. May be called on any thread. |
| 108 bool IsCurrentThreadSafeForModel( | 109 bool IsCurrentThreadSafeForModel( |
| 109 syncable::ModelType model_type) const; | 110 syncable::ModelType model_type) const; |
| 110 | 111 |
| 112 const std::string name_; | |
| 113 | |
| 111 Profile* const profile_; | 114 Profile* const profile_; |
| 112 | 115 |
| 113 MessageLoop* const sync_loop_; | 116 MessageLoop* const sync_loop_; |
| 114 | 117 |
| 115 const scoped_refptr<UIModelWorker> ui_worker_; | 118 const scoped_refptr<UIModelWorker> ui_worker_; |
| 116 | 119 |
| 117 bool stopped_on_ui_thread_; | 120 bool stopped_on_ui_thread_; |
| 118 | 121 |
| 119 // Protects all variables below. | 122 // Protects all variables below. |
| 120 mutable base::Lock lock_; | 123 mutable base::Lock lock_; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 134 | 137 |
| 135 // The change processors that handle the different data types. | 138 // The change processors that handle the different data types. |
| 136 std::map<syncable::ModelType, ChangeProcessor*> processors_; | 139 std::map<syncable::ModelType, ChangeProcessor*> processors_; |
| 137 | 140 |
| 138 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 141 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
| 139 }; | 142 }; |
| 140 | 143 |
| 141 } // namespace browser_sync | 144 } // namespace browser_sync |
| 142 | 145 |
| 143 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 146 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
| OLD | NEW |