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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_metadata_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
OLDNEW
(Empty)
1 // Copyright 2016 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/autofill/core/browser/webdata/autofill_metadata_change_list .h"
6
7 #include "base/location.h"
8
9 using base::Optional;
10 using syncer::ModelError;
11
12 namespace autofill {
13
14 AutofillMetadataChangeList::AutofillMetadataChangeList(AutofillTable* table,
15 syncer::ModelType type)
16 : table_(table), type_(type) {
17 DCHECK(table_);
18 // This should be changed as new autofill types are converted to USS.
19 DCHECK_EQ(syncer::AUTOFILL, type_);
20 }
21
22 AutofillMetadataChangeList::~AutofillMetadataChangeList() {
23 DCHECK(!error_);
24 }
25
26 void AutofillMetadataChangeList::UpdateModelTypeState(
27 const sync_pb::ModelTypeState& model_type_state) {
28 if (error_) {
29 return;
30 }
31
32 if (!table_->UpdateModelTypeState(type_, model_type_state)) {
33 error_ = ModelError(FROM_HERE, "Failed to update ModelTypeState.");
34 }
35 }
36
37 void AutofillMetadataChangeList::ClearModelTypeState() {
38 if (error_) {
39 return;
40 }
41
42 if (!table_->ClearModelTypeState(type_)) {
43 error_ = ModelError(FROM_HERE, "Failed to clear ModelTypeState.");
44 }
45 }
46
47 void AutofillMetadataChangeList::UpdateMetadata(
48 const std::string& storage_key,
49 const sync_pb::EntityMetadata& metadata) {
50 if (error_) {
51 return;
52 }
53
54 if (!table_->UpdateSyncMetadata(type_, storage_key, metadata)) {
55 error_ = ModelError(FROM_HERE, "Failed to update entity metadata.");
56 }
57 }
58
59 void AutofillMetadataChangeList::ClearMetadata(const std::string& storage_key) {
60 if (error_) {
61 return;
62 }
63
64 if (!table_->ClearSyncMetadata(type_, storage_key)) {
65 error_ = ModelError(FROM_HERE, "Failed to clear entity metadata.");
66 }
67 }
68
69 Optional<ModelError> AutofillMetadataChangeList::TakeError() {
70 Optional<ModelError> temp = error_;
71 error_.reset();
72 return temp;
73 }
74
75 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698