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.h

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/mock_model_type_store.cc ('k') | components/sync/model/model_type_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/model/model_type_store.h
diff --git a/components/sync/model/model_type_store.h b/components/sync/model/model_type_store.h
index 3352225808b95af1020e42ecfdeafc1fd551e72a..fcaa7adc98fc75903c915cdcf73c12f33747d7e7 100644
--- a/components/sync/model/model_type_store.h
+++ b/components/sync/model/model_type_store.h
@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "components/sync/base/model_type.h"
+#include "components/sync/model/metadata_change_list.h"
namespace base {
class SequencedTaskRunner;
@@ -66,11 +67,34 @@ class ModelTypeStore {
// WriteBatch object is used in all modification operations.
class WriteBatch {
public:
+ // Creates a MetadataChangeList that will accumulate metadata changes and
+ // can later pass them to a WriteBatch via TransferChanges. Use this when
+ // you need a MetadataChangeList and do not have a WriteBatch in scope.
+ static std::unique_ptr<MetadataChangeList> CreateMetadataChangeList();
+
virtual ~WriteBatch();
+ // Provides access to a MetadataChangeList that will pass its changes
+ // directly into this WriteBatch. Use this when you need a
+ // MetadataChangeList and already have a WriteBatch in scope.
+ MetadataChangeList* GetMetadataChangeList();
+
+ // Transfers the changes from a MetadataChangeList into this WriteBatch.
+ // |mcl| must have previously been created by CreateMetadataChangeList().
+ void TransferMetadataChanges(std::unique_ptr<MetadataChangeList> mcl);
+
protected:
friend class MockModelTypeStore;
- WriteBatch();
+ explicit WriteBatch(ModelTypeStore* store);
+
+ private:
+ // A pointer to the store that generated this WriteBatch.
+ ModelTypeStore* store_;
+
+ // A MetadataChangeList that is being used to pass changes directly into the
+ // WriteBatch. Only accessible via GetMetadataChangeList(), and not created
+ // unless necessary.
+ std::unique_ptr<MetadataChangeList> metadata_change_list_;
};
typedef std::vector<Record> RecordList;
« no previous file with comments | « components/sync/model/mock_model_type_store.cc ('k') | components/sync/model/model_type_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698