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

Side by Side Diff: components/sync/api/model_type_service.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/api/model_type_service.h" 5 #include "components/sync/api/model_type_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 namespace syncer_v2 { 9 namespace syncer {
10 10
11 ModelTypeService::ModelTypeService( 11 ModelTypeService::ModelTypeService(
12 const ChangeProcessorFactory& change_processor_factory, 12 const ChangeProcessorFactory& change_processor_factory,
13 syncer::ModelType type) 13 ModelType type)
14 : change_processor_factory_(change_processor_factory), type_(type) {} 14 : change_processor_factory_(change_processor_factory), type_(type) {}
15 15
16 ModelTypeService::~ModelTypeService() {} 16 ModelTypeService::~ModelTypeService() {}
17 17
18 ConflictResolution ModelTypeService::ResolveConflict( 18 ConflictResolution ModelTypeService::ResolveConflict(
19 const EntityData& local_data, 19 const EntityData& local_data,
20 const EntityData& remote_data) const { 20 const EntityData& remote_data) const {
21 // TODO(maxbogue): Add tests once a file exists for them (crbug.com/543407). 21 // TODO(maxbogue): Add tests once a file exists for them (crbug.com/543407).
22 if (remote_data.is_deleted()) { 22 if (remote_data.is_deleted()) {
23 DCHECK(!local_data.is_deleted()); 23 DCHECK(!local_data.is_deleted());
24 return ConflictResolution::UseLocal(); 24 return ConflictResolution::UseLocal();
25 } 25 }
26 return ConflictResolution::UseRemote(); 26 return ConflictResolution::UseRemote();
27 } 27 }
28 28
29 void ModelTypeService::OnSyncStarting( 29 void ModelTypeService::OnSyncStarting(
30 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler, 30 std::unique_ptr<DataTypeErrorHandler> error_handler,
31 const ModelTypeChangeProcessor::StartCallback& start_callback) { 31 const ModelTypeChangeProcessor::StartCallback& start_callback) {
32 CreateChangeProcessor(); 32 CreateChangeProcessor();
33 change_processor_->OnSyncStarting(std::move(error_handler), start_callback); 33 change_processor_->OnSyncStarting(std::move(error_handler), start_callback);
34 } 34 }
35 35
36 void ModelTypeService::DisableSync() { 36 void ModelTypeService::DisableSync() {
37 DCHECK(change_processor_); 37 DCHECK(change_processor_);
38 change_processor_->DisableSync(); 38 change_processor_->DisableSync();
39 change_processor_.reset(); 39 change_processor_.reset();
40 } 40 }
41 41
42 void ModelTypeService::CreateChangeProcessor() { 42 void ModelTypeService::CreateChangeProcessor() {
43 if (!change_processor_) { 43 if (!change_processor_) {
44 change_processor_ = change_processor_factory_.Run(type_, this); 44 change_processor_ = change_processor_factory_.Run(type_, this);
45 DCHECK(change_processor_); 45 DCHECK(change_processor_);
46 OnChangeProcessorSet(); 46 OnChangeProcessorSet();
47 } 47 }
48 } 48 }
49 49
50 ModelTypeChangeProcessor* ModelTypeService::change_processor() const { 50 ModelTypeChangeProcessor* ModelTypeService::change_processor() const {
51 return change_processor_.get(); 51 return change_processor_.get();
52 } 52 }
53 53
54 void ModelTypeService::clear_change_processor() { 54 void ModelTypeService::clear_change_processor() {
55 change_processor_.reset(); 55 change_processor_.reset();
56 } 56 }
57 57
58 } // namespace syncer_v2 58 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/api/model_type_service.h ('k') | components/sync/api/model_type_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698