| 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 15 matching lines...) Expand all Loading... |
| 26 namespace browser_sync { | 26 namespace browser_sync { |
| 27 | 27 |
| 28 class ChangeProcessor; | 28 class ChangeProcessor; |
| 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). |name| is used for |
| 37 // |profile| or |sync_loop|. Must be created on the UI thread. | 37 // debugging. Does not take ownership of |profile| or |sync_loop|. |
| 38 // Must be created on the UI thread. |
| 38 SyncBackendRegistrar(const syncable::ModelTypeSet& initial_types, | 39 SyncBackendRegistrar(const syncable::ModelTypeSet& initial_types, |
| 40 const std::string& name, |
| 39 Profile* profile, | 41 Profile* profile, |
| 40 MessageLoop* sync_loop); | 42 MessageLoop* sync_loop); |
| 41 | 43 |
| 42 // SyncBackendRegistrar must be destroyed as follows: | 44 // SyncBackendRegistrar must be destroyed as follows: |
| 43 // | 45 // |
| 44 // 1) On the sync thread, call OnSyncerShutdownComplete() after | 46 // 1) On the sync thread, call OnSyncerShutdownComplete() after |
| 45 // the syncer is shutdown. | 47 // the syncer is shutdown. |
| 46 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which | 48 // 2) Meanwhile, on the UI thread, call StopOnUIThread(), which |
| 47 // blocks until OnSyncerShutdownComplete() is called. | 49 // blocks until OnSyncerShutdownComplete() is called. |
| 48 // 3) Destroy the SyncBackendRegistrar. | 50 // 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 | 103 // Must be called with |lock_| held. Simply returns the change |
| 102 // processor for the given type, if it exists. May be called from | 104 // processor for the given type, if it exists. May be called from |
| 103 // any thread. | 105 // any thread. |
| 104 ChangeProcessor* GetProcessorUnsafe(syncable::ModelType type); | 106 ChangeProcessor* GetProcessorUnsafe(syncable::ModelType type); |
| 105 | 107 |
| 106 // Return true if |model_type| lives on the current thread. Must be | 108 // Return true if |model_type| lives on the current thread. Must be |
| 107 // called with |lock_| held. May be called on any thread. | 109 // called with |lock_| held. May be called on any thread. |
| 108 bool IsCurrentThreadSafeForModel( | 110 bool IsCurrentThreadSafeForModel( |
| 109 syncable::ModelType model_type) const; | 111 syncable::ModelType model_type) const; |
| 110 | 112 |
| 113 // Name used for debugging. |
| 114 const std::string name_; |
| 115 |
| 111 Profile* const profile_; | 116 Profile* const profile_; |
| 112 | 117 |
| 113 MessageLoop* const sync_loop_; | 118 MessageLoop* const sync_loop_; |
| 114 | 119 |
| 115 const scoped_refptr<UIModelWorker> ui_worker_; | 120 const scoped_refptr<UIModelWorker> ui_worker_; |
| 116 | 121 |
| 117 bool stopped_on_ui_thread_; | 122 bool stopped_on_ui_thread_; |
| 118 | 123 |
| 119 // Protects all variables below. | 124 // Protects all variables below. |
| 120 mutable base::Lock lock_; | 125 mutable base::Lock lock_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 134 | 139 |
| 135 // The change processors that handle the different data types. | 140 // The change processors that handle the different data types. |
| 136 std::map<syncable::ModelType, ChangeProcessor*> processors_; | 141 std::map<syncable::ModelType, ChangeProcessor*> processors_; |
| 137 | 142 |
| 138 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 143 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
| 139 }; | 144 }; |
| 140 | 145 |
| 141 } // namespace browser_sync | 146 } // namespace browser_sync |
| 142 | 147 |
| 143 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 148 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
| OLD | NEW |