Index: sync/api/model_type_service.cc |
diff --git a/sync/api/model_type_service.cc b/sync/api/model_type_service.cc |
index 87df14bf6011dc559b98e90082d0e2d29f1235d7..a95b531f539570dd981bafcdf9f3b114dc433cd3 100644 |
--- a/sync/api/model_type_service.cc |
+++ b/sync/api/model_type_service.cc |
@@ -4,25 +4,40 @@ |
#include "sync/api/model_type_service.h" |
+#include "sync/internal_api/public/shared_model_type_processor.h" |
+ |
namespace syncer_v2 { |
-ModelTypeService::ModelTypeService() {} |
+ModelTypeService::ModelTypeService( |
+ const SharedProcessorFactory& shared_processor_factory) |
+ : shared_processor_factory_(shared_processor_factory) {} |
ModelTypeService::~ModelTypeService() {} |
-ModelTypeChangeProcessor* ModelTypeService::change_processor() const { |
+ModelTypeChangeProcessor* ModelTypeService::change_processor() { |
return change_processor_.get(); |
} |
-void ModelTypeService::set_change_processor( |
- scoped_ptr<ModelTypeChangeProcessor> change_processor) { |
- DCHECK(!change_processor_); |
- change_processor_.swap(change_processor); |
- OnChangeProcessorSet(); |
+ModelTypeChangeProcessor* ModelTypeService::create_change_processor() { |
+ if (!change_processor_.get()) { |
+ change_processor_.reset( |
+ shared_processor_factory_.Run(type(), this).release()); |
+ if (!change_processor_.get()) { |
+ LOG(WARNING) << "Cannot initalize ModelTypeChangeProcessor."; |
+ } |
+ OnChangeProcessorSet(); |
+ } |
+ return change_processor_.get(); |
} |
void ModelTypeService::clear_change_processor() { |
change_processor_.reset(); |
} |
+void ModelTypeService::OnSyncStarting(StartCallback start_callback) { |
+ // 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
|
+ static_cast<SharedModelTypeProcessor*>(create_change_processor()) |
+ ->OnSyncStarting(start_callback); |
+} |
+ |
} // namespace syncer_v2 |