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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_registrar.cc

Issue 408003002: [Sync] Fix namespace for sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 base::AutoLock lock(lock_); 195 base::AutoLock lock(lock_);
196 for (WorkerMap::const_iterator it = workers_.begin(); 196 for (WorkerMap::const_iterator it = workers_.begin();
197 it != workers_.end(); ++it) { 197 it != workers_.end(); ++it) {
198 it->second->RequestStop(); 198 it->second->RequestStop();
199 } 199 }
200 } 200 }
201 201
202 void SyncBackendRegistrar::ActivateDataType( 202 void SyncBackendRegistrar::ActivateDataType(
203 syncer::ModelType type, 203 syncer::ModelType type,
204 syncer::ModelSafeGroup group, 204 syncer::ModelSafeGroup group,
205 ChangeProcessor* change_processor, 205 sync_driver::ChangeProcessor* change_processor,
206 syncer::UserShare* user_share) { 206 syncer::UserShare* user_share) {
207 DVLOG(1) << "Activate: " << syncer::ModelTypeToString(type); 207 DVLOG(1) << "Activate: " << syncer::ModelTypeToString(type);
208 208
209 base::AutoLock lock(lock_); 209 base::AutoLock lock(lock_);
210 // Ensure that the given data type is in the PASSIVE group. 210 // Ensure that the given data type is in the PASSIVE group.
211 syncer::ModelSafeRoutingInfo::iterator i = routing_info_.find(type); 211 syncer::ModelSafeRoutingInfo::iterator i = routing_info_.find(type);
212 DCHECK(i != routing_info_.end()); 212 DCHECK(i != routing_info_.end());
213 DCHECK_EQ(i->second, syncer::GROUP_PASSIVE); 213 DCHECK_EQ(i->second, syncer::GROUP_PASSIVE);
214 routing_info_[type] = group; 214 routing_info_[type] = group;
215 215
(...skipping 21 matching lines...) Expand all
237 bool SyncBackendRegistrar::IsTypeActivatedForTest( 237 bool SyncBackendRegistrar::IsTypeActivatedForTest(
238 syncer::ModelType type) const { 238 syncer::ModelType type) const {
239 return GetProcessor(type) != NULL; 239 return GetProcessor(type) != NULL;
240 } 240 }
241 241
242 void SyncBackendRegistrar::OnChangesApplied( 242 void SyncBackendRegistrar::OnChangesApplied(
243 syncer::ModelType model_type, 243 syncer::ModelType model_type,
244 int64 model_version, 244 int64 model_version,
245 const syncer::BaseTransaction* trans, 245 const syncer::BaseTransaction* trans,
246 const syncer::ImmutableChangeRecordList& changes) { 246 const syncer::ImmutableChangeRecordList& changes) {
247 ChangeProcessor* processor = GetProcessor(model_type); 247 sync_driver::ChangeProcessor* processor = GetProcessor(model_type);
248 if (!processor) 248 if (!processor)
249 return; 249 return;
250 250
251 processor->ApplyChangesFromSyncModel(trans, model_version, changes); 251 processor->ApplyChangesFromSyncModel(trans, model_version, changes);
252 } 252 }
253 253
254 void SyncBackendRegistrar::OnChangesComplete(syncer::ModelType model_type) { 254 void SyncBackendRegistrar::OnChangesComplete(syncer::ModelType model_type) {
255 ChangeProcessor* processor = GetProcessor(model_type); 255 sync_driver::ChangeProcessor* processor = GetProcessor(model_type);
256 if (!processor) 256 if (!processor)
257 return; 257 return;
258 258
259 // This call just notifies the processor that it can commit; it 259 // This call just notifies the processor that it can commit; it
260 // already buffered any changes it plans to makes so needs no 260 // already buffered any changes it plans to makes so needs no
261 // further information. 261 // further information.
262 processor->CommitChangesFromSyncModel(); 262 processor->CommitChangesFromSyncModel();
263 } 263 }
264 264
265 void SyncBackendRegistrar::GetWorkers( 265 void SyncBackendRegistrar::GetWorkers(
266 std::vector<scoped_refptr<syncer::ModelSafeWorker> >* out) { 266 std::vector<scoped_refptr<syncer::ModelSafeWorker> >* out) {
267 base::AutoLock lock(lock_); 267 base::AutoLock lock(lock_);
268 out->clear(); 268 out->clear();
269 for (WorkerMap::const_iterator it = workers_.begin(); 269 for (WorkerMap::const_iterator it = workers_.begin();
270 it != workers_.end(); ++it) { 270 it != workers_.end(); ++it) {
271 out->push_back(it->second.get()); 271 out->push_back(it->second.get());
272 } 272 }
273 } 273 }
274 274
275 void SyncBackendRegistrar::GetModelSafeRoutingInfo( 275 void SyncBackendRegistrar::GetModelSafeRoutingInfo(
276 syncer::ModelSafeRoutingInfo* out) { 276 syncer::ModelSafeRoutingInfo* out) {
277 base::AutoLock lock(lock_); 277 base::AutoLock lock(lock_);
278 syncer::ModelSafeRoutingInfo copy(routing_info_); 278 syncer::ModelSafeRoutingInfo copy(routing_info_);
279 out->swap(copy); 279 out->swap(copy);
280 } 280 }
281 281
282 ChangeProcessor* SyncBackendRegistrar::GetProcessor( 282 sync_driver::ChangeProcessor* SyncBackendRegistrar::GetProcessor(
283 syncer::ModelType type) const { 283 syncer::ModelType type) const {
284 base::AutoLock lock(lock_); 284 base::AutoLock lock(lock_);
285 ChangeProcessor* processor = GetProcessorUnsafe(type); 285 sync_driver::ChangeProcessor* processor = GetProcessorUnsafe(type);
286 if (!processor) 286 if (!processor)
287 return NULL; 287 return NULL;
288 288
289 // We can only check if |processor| exists, as otherwise the type is 289 // We can only check if |processor| exists, as otherwise the type is
290 // mapped to syncer::GROUP_PASSIVE. 290 // mapped to syncer::GROUP_PASSIVE.
291 CHECK(IsCurrentThreadSafeForModel(type)); 291 CHECK(IsCurrentThreadSafeForModel(type));
292 return processor; 292 return processor;
293 } 293 }
294 294
295 ChangeProcessor* SyncBackendRegistrar::GetProcessorUnsafe( 295 sync_driver::ChangeProcessor* SyncBackendRegistrar::GetProcessorUnsafe(
296 syncer::ModelType type) const { 296 syncer::ModelType type) const {
297 lock_.AssertAcquired(); 297 lock_.AssertAcquired();
298 std::map<syncer::ModelType, ChangeProcessor*>::const_iterator 298 std::map<syncer::ModelType, sync_driver::ChangeProcessor*>::const_iterator
299 it = processors_.find(type); 299 it = processors_.find(type);
300 300
301 // Until model association happens for a datatype, it will not 301 // Until model association happens for a datatype, it will not
302 // appear in the processors list. During this time, it is OK to 302 // appear in the processors list. During this time, it is OK to
303 // drop changes on the floor (since model association has not 303 // drop changes on the floor (since model association has not
304 // happened yet). When the data type is activated, model 304 // happened yet). When the data type is activated, model
305 // association takes place then the change processor is added to the 305 // association takes place then the change processor is added to the
306 // |processors_| list. 306 // |processors_| list.
307 if (it == processors_.end()) 307 if (it == processors_.end())
308 return NULL; 308 return NULL;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 base::Bind(&SyncBackendRegistrar::OnWorkerUnregistrationDone, 367 base::Bind(&SyncBackendRegistrar::OnWorkerUnregistrationDone,
368 base::Unretained(this))); 368 base::Unretained(this)));
369 } 369 }
370 } 370 }
371 371
372 base::Thread* SyncBackendRegistrar::sync_thread() { 372 base::Thread* SyncBackendRegistrar::sync_thread() {
373 return sync_thread_.get(); 373 return sync_thread_.get();
374 } 374 }
375 375
376 } // namespace browser_sync 376 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_registrar.h ('k') | chrome/browser/sync/glue/sync_backend_registrar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698