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 | 6 |
7 #include "sync/internal_api/public/shared_model_type_processor.h" | |
8 | |
7 namespace syncer_v2 { | 9 namespace syncer_v2 { |
8 | 10 |
9 ModelTypeService::ModelTypeService() {} | 11 ModelTypeService::ModelTypeService( |
12 const SharedProcessorFactory& shared_processor_factory) | |
13 : shared_processor_factory_(shared_processor_factory) {} | |
10 | 14 |
11 ModelTypeService::~ModelTypeService() {} | 15 ModelTypeService::~ModelTypeService() {} |
12 | 16 |
13 ModelTypeChangeProcessor* ModelTypeService::change_processor() const { | 17 ModelTypeChangeProcessor* ModelTypeService::change_processor() { |
14 return change_processor_.get(); | 18 return change_processor_.get(); |
15 } | 19 } |
16 | 20 |
17 void ModelTypeService::set_change_processor( | 21 ModelTypeChangeProcessor* ModelTypeService::create_change_processor() { |
18 scoped_ptr<ModelTypeChangeProcessor> change_processor) { | 22 if (!change_processor_.get()) { |
19 DCHECK(!change_processor_); | 23 change_processor_.reset( |
20 change_processor_.swap(change_processor); | 24 shared_processor_factory_.Run(type(), this).release()); |
21 OnChangeProcessorSet(); | 25 if (!change_processor_.get()) { |
26 LOG(WARNING) << "Cannot initalize ModelTypeChangeProcessor."; | |
27 } | |
28 OnChangeProcessorSet(); | |
29 } | |
30 return change_processor_.get(); | |
22 } | 31 } |
23 | 32 |
24 void ModelTypeService::clear_change_processor() { | 33 void ModelTypeService::clear_change_processor() { |
25 change_processor_.reset(); | 34 change_processor_.reset(); |
26 } | 35 } |
27 | 36 |
37 void ModelTypeService::OnSyncStarting(StartCallback start_callback) { | |
38 // TODO(gangwu): should not cast here, find a better way to call. | |
skym
2016/03/22 15:56:26
Ooooh yeah I didn't realize we were going to have
Gang Wu
2016/03/22 17:47:51
put this method into ModelTypeChangeProcessor is w
| |
39 static_cast<SharedModelTypeProcessor*>(create_change_processor()) | |
40 ->OnSyncStarting(start_callback); | |
41 } | |
42 | |
28 } // namespace syncer_v2 | 43 } // namespace syncer_v2 |
OLD | NEW |