Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: components/sync/driver/glue/sync_backend_registrar.cc

Issue 2507913002: [Sync] Remove some unnecessary typedefs in SyncBackendRegistrar. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sync/driver/glue/sync_backend_registrar.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/sync/driver/glue/sync_backend_registrar.h" 5 #include "components/sync/driver/glue/sync_backend_registrar.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstddef> 8 #include <cstddef>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return newly_added_types; 135 return newly_added_types;
136 } 136 }
137 137
138 ModelTypeSet SyncBackendRegistrar::GetLastConfiguredTypes() const { 138 ModelTypeSet SyncBackendRegistrar::GetLastConfiguredTypes() const {
139 return last_configured_types_; 139 return last_configured_types_;
140 } 140 }
141 141
142 void SyncBackendRegistrar::RequestWorkerStopOnUIThread() { 142 void SyncBackendRegistrar::RequestWorkerStopOnUIThread() {
143 DCHECK(ui_thread_checker_.CalledOnValidThread()); 143 DCHECK(ui_thread_checker_.CalledOnValidThread());
144 base::AutoLock lock(lock_); 144 base::AutoLock lock(lock_);
145 for (WorkerMap::const_iterator it = workers_.begin(); it != workers_.end(); 145 for (const auto& kv : workers_) {
146 ++it) { 146 kv.second->RequestStop();
147 it->second->RequestStop();
148 } 147 }
149 } 148 }
150 149
151 void SyncBackendRegistrar::ActivateDataType(ModelType type, 150 void SyncBackendRegistrar::ActivateDataType(ModelType type,
152 ModelSafeGroup group, 151 ModelSafeGroup group,
153 ChangeProcessor* change_processor, 152 ChangeProcessor* change_processor,
154 UserShare* user_share) { 153 UserShare* user_share) {
155 DVLOG(1) << "Activate: " << ModelTypeToString(type); 154 DVLOG(1) << "Activate: " << ModelTypeToString(type);
156 155
157 base::AutoLock lock(lock_); 156 base::AutoLock lock(lock_);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // This call just notifies the processor that it can commit; it 205 // This call just notifies the processor that it can commit; it
207 // already buffered any changes it plans to makes so needs no 206 // already buffered any changes it plans to makes so needs no
208 // further information. 207 // further information.
209 processor->CommitChangesFromSyncModel(); 208 processor->CommitChangesFromSyncModel();
210 } 209 }
211 210
212 void SyncBackendRegistrar::GetWorkers( 211 void SyncBackendRegistrar::GetWorkers(
213 std::vector<scoped_refptr<ModelSafeWorker>>* out) { 212 std::vector<scoped_refptr<ModelSafeWorker>>* out) {
214 base::AutoLock lock(lock_); 213 base::AutoLock lock(lock_);
215 out->clear(); 214 out->clear();
216 for (WorkerMap::const_iterator it = workers_.begin(); it != workers_.end(); 215 for (const auto& kv : workers_) {
217 ++it) { 216 out->push_back(kv.second.get());
218 out->push_back(it->second.get());
219 } 217 }
220 } 218 }
221 219
222 void SyncBackendRegistrar::GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { 220 void SyncBackendRegistrar::GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
223 base::AutoLock lock(lock_); 221 base::AutoLock lock(lock_);
224 ModelSafeRoutingInfo copy(routing_info_); 222 ModelSafeRoutingInfo copy(routing_info_);
225 out->swap(copy); 223 out->swap(copy);
226 } 224 }
227 225
228 ChangeProcessor* SyncBackendRegistrar::GetProcessor(ModelType type) const { 226 ChangeProcessor* SyncBackendRegistrar::GetProcessor(ModelType type) const {
229 base::AutoLock lock(lock_); 227 base::AutoLock lock(lock_);
230 ChangeProcessor* processor = GetProcessorUnsafe(type); 228 ChangeProcessor* processor = GetProcessorUnsafe(type);
231 if (!processor) 229 if (!processor)
232 return nullptr; 230 return nullptr;
233 231
234 // We can only check if |processor| exists, as otherwise the type is 232 // We can only check if |processor| exists, as otherwise the type is
235 // mapped to GROUP_PASSIVE. 233 // mapped to GROUP_PASSIVE.
236 CHECK(IsCurrentThreadSafeForModel(type)); 234 CHECK(IsCurrentThreadSafeForModel(type));
237 return processor; 235 return processor;
238 } 236 }
239 237
240 ChangeProcessor* SyncBackendRegistrar::GetProcessorUnsafe( 238 ChangeProcessor* SyncBackendRegistrar::GetProcessorUnsafe(
241 ModelType type) const { 239 ModelType type) const {
242 lock_.AssertAcquired(); 240 lock_.AssertAcquired();
243 std::map<ModelType, ChangeProcessor*>::const_iterator it = 241 auto it = processors_.find(type);
244 processors_.find(type);
245 242
246 // Until model association happens for a datatype, it will not 243 // Until model association happens for a datatype, it will not
247 // appear in the processors list. During this time, it is OK to 244 // appear in the processors list. During this time, it is OK to
248 // drop changes on the floor (since model association has not 245 // drop changes on the floor (since model association has not
249 // happened yet). When the data type is activated, model 246 // happened yet). When the data type is activated, model
250 // association takes place then the change processor is added to the 247 // association takes place then the change processor is added to the
251 // |processors_| list. 248 // |processors_| list.
252 if (it == processors_.end()) 249 if (it == processors_.end())
253 return nullptr; 250 return nullptr;
254 251
(...skipping 28 matching lines...) Expand all
283 workers_[group] = worker; 280 workers_[group] = worker;
284 } 281 }
285 } 282 }
286 283
287 ModelSafeGroup SyncBackendRegistrar::GetInitialGroupForType( 284 ModelSafeGroup SyncBackendRegistrar::GetInitialGroupForType(
288 ModelType type) const { 285 ModelType type) const {
289 return non_blocking_types_.Has(type) ? GROUP_NON_BLOCKING : GROUP_PASSIVE; 286 return non_blocking_types_.Has(type) ? GROUP_NON_BLOCKING : GROUP_PASSIVE;
290 } 287 }
291 288
292 } // namespace syncer 289 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_registrar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698