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

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..cfdf8b408dc35ee497619334ed03f1c5002abe57 100644
--- a/sync/api/model_type_service.cc
+++ b/sync/api/model_type_service.cc
@@ -4,9 +4,13 @@
#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() {}
@@ -14,15 +18,26 @@ 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::create_change_processor() {
maxbogue 2016/03/22 21:40:12 This function is doing nontrivial logic, which mea
Gang Wu 2016/03/24 15:56:26 Done.
+ if (!change_processor_.get()) {
maxbogue 2016/03/22 21:40:12 I think you should just either just DCHECK(!change
skym 2016/03/22 22:18:17 +1 to GetOrCreateChangeProcessor. Checking change_
Gang Wu 2016/03/24 15:56:26 Done.
Gang Wu 2016/03/24 15:56:26 Done.
+ change_processor_.reset(
+ shared_processor_factory_.Run(type(), this).release());
+ if (!change_processor_.get()) {
maxbogue 2016/03/22 21:40:12 Again, better to just DCHECK(change_processor_).
Gang Wu 2016/03/24 15:56:26 Done.
+ LOG(WARNING) << "Cannot initalize ModelTypeChangeProcessor.";
+ }
+ OnChangeProcessorSet();
+ }
+ return change_processor_.get();
}
void ModelTypeService::clear_change_processor() {
change_processor_.reset();
}
+void ModelTypeService::OnSyncStarting(const StartCallback& start_callback) {
+ // TODO(gangwu): should not cast here, find a better way to call.
+ static_cast<SharedModelTypeProcessor*>(create_change_processor())
maxbogue 2016/03/22 21:40:12 OnSyncStarting should just be moved into the Model
Gang Wu 2016/03/24 15:56:26 Done.
+ ->OnSyncStarting(start_callback);
+}
+
} // namespace syncer_v2

Powered by Google App Engine
This is Rietveld 408576698