OLD | NEW |
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 "sync/api/model_type_service.h" | 5 #include "sync/api/model_type_service.h" |
| 6 #include "sync/internal_api/public/shared_model_type_processor.h" |
6 | 7 |
7 namespace syncer_v2 { | 8 namespace syncer_v2 { |
8 | 9 |
9 ModelTypeService::ModelTypeService() {} | 10 ModelTypeService::ModelTypeService() {} |
10 | 11 |
11 ModelTypeService::~ModelTypeService() {} | 12 ModelTypeService::~ModelTypeService() {} |
12 | 13 |
13 ModelTypeChangeProcessor* ModelTypeService::change_processor() const { | 14 ModelTypeChangeProcessor* ModelTypeService::change_processor() const { |
14 return change_processor_.get(); | 15 return change_processor_.get(); |
15 } | 16 } |
16 | 17 |
17 void ModelTypeService::set_change_processor( | 18 void ModelTypeService::InitializeProcessor(syncer::ModelType type) { |
18 scoped_ptr<ModelTypeChangeProcessor> change_processor) { | 19 DCHECK(!change_processor_.get()); |
19 DCHECK(!change_processor_); | 20 change_processor_.reset(CreateSharedModelTypeProcessor(type).release()); |
20 change_processor_.swap(change_processor); | |
21 OnChangeProcessorSet(); | 21 OnChangeProcessorSet(); |
22 } | 22 } |
23 | 23 |
| 24 scoped_ptr<SharedModelTypeProcessor> |
| 25 ModelTypeService::CreateSharedModelTypeProcessor(syncer::ModelType type) { |
| 26 return make_scoped_ptr(new syncer_v2::SharedModelTypeProcessor(type, this)); |
| 27 } |
| 28 |
24 void ModelTypeService::clear_change_processor() { | 29 void ModelTypeService::clear_change_processor() { |
25 change_processor_.reset(); | 30 change_processor_.reset(); |
26 } | 31 } |
27 | 32 |
28 } // namespace syncer_v2 | 33 } // namespace syncer_v2 |
OLD | NEW |