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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/sync/model_impl/sync_metadata_store_change_list.h"
6
7 #include "base/location.h"
8
9 using base::Optional;
10 using syncer::ModelError;
11
12 namespace syncer {
13
14 SyncMetadataStoreChangeList::SyncMetadataStoreChangeList(
15 SyncMetadataStore* store,
16 syncer::ModelType type)
17 : store_(store), type_(type) {
18 DCHECK(store_);
19 }
20
21 SyncMetadataStoreChangeList::~SyncMetadataStoreChangeList() {
22 DCHECK(!error_);
23 }
24
25 void SyncMetadataStoreChangeList::UpdateModelTypeState(
26 const sync_pb::ModelTypeState& model_type_state) {
27 if (error_) {
28 return;
29 }
30
31 if (!store_->UpdateModelTypeState(type_, model_type_state)) {
32 error_ = ModelError(FROM_HERE, "Failed to update ModelTypeState.");
33 }
34 }
35
36 void SyncMetadataStoreChangeList::ClearModelTypeState() {
37 if (error_) {
38 return;
39 }
40
41 if (!store_->ClearModelTypeState(type_)) {
42 error_ = ModelError(FROM_HERE, "Failed to clear ModelTypeState.");
43 }
44 }
45
46 void SyncMetadataStoreChangeList::UpdateMetadata(
47 const std::string& storage_key,
48 const sync_pb::EntityMetadata& metadata) {
49 if (error_) {
50 return;
51 }
52
53 if (!store_->UpdateSyncMetadata(type_, storage_key, metadata)) {
54 error_ = ModelError(FROM_HERE, "Failed to update entity metadata.");
55 }
56 }
57
58 void SyncMetadataStoreChangeList::ClearMetadata(
59 const std::string& storage_key) {
60 if (error_) {
61 return;
62 }
63
64 if (!store_->ClearSyncMetadata(type_, storage_key)) {
65 error_ = ModelError(FROM_HERE, "Failed to clear entity metadata.");
66 }
67 }
68
69 Optional<ModelError> SyncMetadataStoreChangeList::TakeError() {
70 Optional<ModelError> temp = error_;
71 error_.reset();
72 return temp;
73 }
74
75 } // namespace syncer
OLDNEW
« 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