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

Unified Diff: components/sync/model/model_type_store.cc

Issue 2473553003: [Sync] Improve MetadataChangeList usage for types using ModelTypeStore. (Closed)
Patch Set: Fix comments + protected constructor. Created 4 years, 1 month 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 | « components/sync/model/model_type_store.h ('k') | components/sync/model/simple_metadata_change_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/model/model_type_store.cc
diff --git a/components/sync/model/model_type_store.cc b/components/sync/model/model_type_store.cc
index ba9969ee44c546e8818adc23a77e5f0ee7c428ef..df673a79d308449193bbc0e3c2b1d7f82162d2cc 100644
--- a/components/sync/model/model_type_store.cc
+++ b/components/sync/model/model_type_store.cc
@@ -4,7 +4,10 @@
#include "components/sync/model/model_type_store.h"
+#include "base/memory/ptr_util.h"
+#include "components/sync/model_impl/accumulating_metadata_change_list.h"
#include "components/sync/model_impl/model_type_store_impl.h"
+#include "components/sync/model_impl/passthrough_metadata_change_list.h"
namespace syncer {
@@ -24,8 +27,28 @@ void ModelTypeStore::CreateStore(
ModelTypeStore::~ModelTypeStore() {}
-ModelTypeStore::WriteBatch::WriteBatch() {}
+// static
+std::unique_ptr<MetadataChangeList>
+ModelTypeStore::WriteBatch::CreateMetadataChangeList() {
+ return base::MakeUnique<AccumulatingMetadataChangeList>();
+}
+
+ModelTypeStore::WriteBatch::WriteBatch(ModelTypeStore* store) : store_(store) {}
ModelTypeStore::WriteBatch::~WriteBatch() {}
+MetadataChangeList* ModelTypeStore::WriteBatch::GetMetadataChangeList() {
+ if (!metadata_change_list_) {
+ metadata_change_list_ =
+ base::MakeUnique<PassthroughMetadataChangeList>(store_, this);
+ }
+ return metadata_change_list_.get();
+}
+
+void ModelTypeStore::WriteBatch::TransferMetadataChanges(
+ std::unique_ptr<MetadataChangeList> mcl) {
+ static_cast<AccumulatingMetadataChangeList*>(mcl.get())->TransferChanges(
+ store_, this);
+}
+
} // namespace syncer
« no previous file with comments | « components/sync/model/model_type_store.h ('k') | components/sync/model/simple_metadata_change_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698