| 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> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // A class that keep track of the workers, change processors, and | 29 // A class that keep track of the workers, change processors, and |
| 30 // routing info for the enabled sync types, and also routes change | 30 // routing info for the enabled sync types, and also routes change |
| 31 // events to the right processors. | 31 // events to the right processors. |
| 32 class SyncBackendRegistrar : public SyncManager::ChangeDelegate { | 32 class SyncBackendRegistrar : public SyncManager::ChangeDelegate { |
| 33 public: | 33 public: |
| 34 // |name| is used for debugging. Must be created on the UI thread. | 34 // |name| is used for debugging. Must be created on the UI thread. |
| 35 SyncBackendRegistrar( | 35 SyncBackendRegistrar( |
| 36 const std::string& name, | 36 const std::string& name, |
| 37 SyncClient* sync_client, | 37 SyncClient* sync_client, |
| 38 std::unique_ptr<base::Thread> sync_thread, | |
| 39 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 38 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 40 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 39 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
| 41 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread); | 40 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread); |
| 42 | 41 |
| 43 // A SyncBackendRegistrar is owned by a SyncBackendHostImpl. It is destroyed | 42 // A SyncBackendRegistrar is owned by a SyncBackendHostImpl. It is destroyed |
| 44 // by SyncBackendHostImpl::Shutdown() which performs the following operations | 43 // by SyncBackendHostImpl::Shutdown() which performs the following operations |
| 45 // on the UI thread: | 44 // on the UI thread: |
| 46 // | 45 // |
| 47 // 1) Call SyncBackendRegistrar::RequestWorkerStopOnUIThread(). | 46 // 1) Call SyncBackendRegistrar::RequestWorkerStopOnUIThread(). |
| 48 // 2) Post a SyncBackendHostCore::DoShutdown() task to the sync thread. This | 47 // 2) Post a SyncBackendHostCore::DoShutdown() task to the sync thread. This |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // any thread. | 109 // any thread. |
| 111 void OnChangesApplied(ModelType model_type, | 110 void OnChangesApplied(ModelType model_type, |
| 112 int64_t model_version, | 111 int64_t model_version, |
| 113 const BaseTransaction* trans, | 112 const BaseTransaction* trans, |
| 114 const ImmutableChangeRecordList& changes) override; | 113 const ImmutableChangeRecordList& changes) override; |
| 115 void OnChangesComplete(ModelType model_type) override; | 114 void OnChangesComplete(ModelType model_type) override; |
| 116 | 115 |
| 117 void GetWorkers(std::vector<scoped_refptr<ModelSafeWorker>>* out); | 116 void GetWorkers(std::vector<scoped_refptr<ModelSafeWorker>>* out); |
| 118 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out); | 117 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out); |
| 119 | 118 |
| 120 // Release ownership of |sync_thread_|. Called when sync is disabled. | |
| 121 std::unique_ptr<base::Thread> ReleaseSyncThread(); | |
| 122 | |
| 123 base::Thread* sync_thread(); | |
| 124 | |
| 125 private: | 119 private: |
| 126 typedef std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker>> WorkerMap; | 120 typedef std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker>> WorkerMap; |
| 127 typedef std::map<ModelType, ChangeProcessor*> ProcessorMap; | 121 typedef std::map<ModelType, ChangeProcessor*> ProcessorMap; |
| 128 | 122 |
| 129 // Add a worker for |group| to the worker map if one can be created. | 123 // Add a worker for |group| to the worker map if one can be created. |
| 130 void MaybeAddWorker(ModelSafeGroup group); | 124 void MaybeAddWorker(ModelSafeGroup group); |
| 131 | 125 |
| 132 // Returns the change processor for the given model, or null if none | 126 // Returns the change processor for the given model, or null if none |
| 133 // exists. Must be called from |group|'s native thread. | 127 // exists. Must be called from |group|'s native thread. |
| 134 ChangeProcessor* GetProcessor(ModelType type) const; | 128 ChangeProcessor* GetProcessor(ModelType type) const; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 164 |
| 171 // The types that were enabled as of the last configuration. Updated on each | 165 // The types that were enabled as of the last configuration. Updated on each |
| 172 // call to ConfigureDataTypes as well as SetInitialTypes. | 166 // call to ConfigureDataTypes as well as SetInitialTypes. |
| 173 ModelTypeSet last_configured_types_; | 167 ModelTypeSet last_configured_types_; |
| 174 | 168 |
| 175 // References to the thread task runners that sync depends on. | 169 // References to the thread task runners that sync depends on. |
| 176 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; | 170 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; |
| 177 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 171 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
| 178 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; | 172 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; |
| 179 | 173 |
| 180 std::unique_ptr<base::Thread> sync_thread_; | |
| 181 | |
| 182 // Set of types with non-blocking implementation (as opposed to directory | 174 // Set of types with non-blocking implementation (as opposed to directory |
| 183 // based). | 175 // based). |
| 184 ModelTypeSet non_blocking_types_; | 176 ModelTypeSet non_blocking_types_; |
| 185 | 177 |
| 186 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); | 178 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); |
| 187 }; | 179 }; |
| 188 | 180 |
| 189 } // namespace syncer | 181 } // namespace syncer |
| 190 | 182 |
| 191 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ | 183 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ |
| OLD | NEW |