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

Unified Diff: components/sync/model_impl/sync_metadata_store_change_list.cc

Issue 2794413002: [USS] Add SyncMetadataStore interface (Closed)
Patch Set: update names Created 3 years, 8 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 | « components/sync/model_impl/sync_metadata_store_change_list.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/model_impl/sync_metadata_store_change_list.cc
diff --git a/components/sync/model_impl/sync_metadata_store_change_list.cc b/components/sync/model_impl/sync_metadata_store_change_list.cc
new file mode 100644
index 0000000000000000000000000000000000000000..59f1e89ae256f26b176b416f6b432ad6924db856
--- /dev/null
+++ b/components/sync/model_impl/sync_metadata_store_change_list.cc
@@ -0,0 +1,75 @@
+// Copyright 2017 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/sync_metadata_store_change_list.h"
+
+#include "base/location.h"
+
+using base::Optional;
+using syncer::ModelError;
+
+namespace syncer {
+
+SyncMetadataStoreChangeList::SyncMetadataStoreChangeList(
+ SyncMetadataStore* store,
+ syncer::ModelType type)
+ : store_(store), type_(type) {
+ DCHECK(store_);
+}
+
+SyncMetadataStoreChangeList::~SyncMetadataStoreChangeList() {
+ DCHECK(!error_);
+}
+
+void SyncMetadataStoreChangeList::UpdateModelTypeState(
+ const sync_pb::ModelTypeState& model_type_state) {
+ if (error_) {
+ return;
+ }
+
+ if (!store_->UpdateModelTypeState(type_, model_type_state)) {
+ error_ = ModelError(FROM_HERE, "Failed to update ModelTypeState.");
+ }
+}
+
+void SyncMetadataStoreChangeList::ClearModelTypeState() {
+ if (error_) {
+ return;
+ }
+
+ if (!store_->ClearModelTypeState(type_)) {
+ error_ = ModelError(FROM_HERE, "Failed to clear ModelTypeState.");
+ }
+}
+
+void SyncMetadataStoreChangeList::UpdateMetadata(
+ const std::string& storage_key,
+ const sync_pb::EntityMetadata& metadata) {
+ if (error_) {
+ return;
+ }
+
+ if (!store_->UpdateSyncMetadata(type_, storage_key, metadata)) {
+ error_ = ModelError(FROM_HERE, "Failed to update entity metadata.");
+ }
+}
+
+void SyncMetadataStoreChangeList::ClearMetadata(
+ const std::string& storage_key) {
+ if (error_) {
+ return;
+ }
+
+ if (!store_->ClearSyncMetadata(type_, storage_key)) {
+ error_ = ModelError(FROM_HERE, "Failed to clear entity metadata.");
+ }
+}
+
+Optional<ModelError> SyncMetadataStoreChangeList::TakeError() {
+ Optional<ModelError> temp = error_;
+ error_.reset();
+ return temp;
+}
+
+} // namespace syncer
« no previous file with comments | « components/sync/model_impl/sync_metadata_store_change_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698