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

Unified Diff: sync/api/model_type_service.cc

Issue 1763953002: [USS] Change the place where SharedModelTypeProcessor got created (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698