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

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: nit 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
« no previous file with comments | « sync/api/model_type_service.h ('k') | sync/internal_api/public/shared_model_type_processor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a8c7933d65c0cc5ba2baab20bb9a7a3d06013e2c 100644
--- a/sync/api/model_type_service.cc
+++ b/sync/api/model_type_service.cc
@@ -4,9 +4,14 @@
#include "sync/api/model_type_service.h"
+#include "sync/api/model_type_change_processor.h"
+
namespace syncer_v2 {
-ModelTypeService::ModelTypeService() {}
+ModelTypeService::ModelTypeService(
+ const ChangeProcessorFactory& change_processor_factory,
+ syncer::ModelType type)
+ : change_processor_factory_(change_processor_factory), type_(type) {}
ModelTypeService::~ModelTypeService() {}
@@ -14,15 +19,29 @@ ModelTypeChangeProcessor* ModelTypeService::change_processor() const {
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::GetOrCreateChangeProcessor() {
+ if (!change_processor_) {
+ change_processor_ = change_processor_factory_.Run(type(), this);
+ DCHECK(change_processor_);
+ OnChangeProcessorSet();
+ }
+ return change_processor_.get();
}
void ModelTypeService::clear_change_processor() {
change_processor_.reset();
}
+ModelTypeChangeProcessor* ModelTypeService::OnSyncStarting(
+ const ModelTypeChangeProcessor::StartCallback& start_callback) {
+ ModelTypeChangeProcessor* processor = GetOrCreateChangeProcessor();
+ DCHECK(processor);
+ processor->OnSyncStarting(start_callback);
+ return processor;
+}
+
+syncer::ModelType ModelTypeService::type() const {
+ return type_;
+}
+
} // namespace syncer_v2
« no previous file with comments | « sync/api/model_type_service.h ('k') | sync/internal_api/public/shared_model_type_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698