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

Unified Diff: components/sync/model_impl/accumulating_metadata_change_list.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
Index: components/sync/model_impl/accumulating_metadata_change_list.cc
diff --git a/components/sync/model_impl/accumulating_metadata_change_list.cc b/components/sync/model_impl/accumulating_metadata_change_list.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d1c348842a6f7e81728d5e01c4294012217b5665
--- /dev/null
+++ b/components/sync/model_impl/accumulating_metadata_change_list.cc
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/sync/model_impl/accumulating_metadata_change_list.h"
+
+namespace syncer {
+
+AccumulatingMetadataChangeList::AccumulatingMetadataChangeList() {}
+AccumulatingMetadataChangeList::~AccumulatingMetadataChangeList() {}
+
+void AccumulatingMetadataChangeList::TransferChanges(
+ ModelTypeStore* store,
+ ModelTypeStore::WriteBatch* write_batch) {
+ DCHECK(write_batch);
+ DCHECK(store);
+ for (const auto& pair : metadata_changes_) {
+ const std::string& storage_key = pair.first;
+ const MetadataChange& change = pair.second;
+ switch (change.type) {
+ case UPDATE:
+ store->WriteMetadata(write_batch, storage_key,
+ change.metadata.SerializeAsString());
+ break;
+ case CLEAR:
+ store->DeleteMetadata(write_batch, storage_key);
+ break;
+ }
+ }
+ metadata_changes_.clear();
+ if (state_change_) {
+ switch (state_change_->type) {
+ case UPDATE:
+ store->WriteGlobalMetadata(write_batch,
+ state_change_->state.SerializeAsString());
+ break;
+ case CLEAR:
+ store->DeleteGlobalMetadata(write_batch);
+ break;
+ }
+ state_change_.reset();
+ }
+}
+
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698