OLD | NEW |
| (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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_METADATA_CHANGE_LIST_H
_ | |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_METADATA_CHANGE_LIST_H
_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/optional.h" | |
11 #include "components/autofill/core/browser/webdata/autofill_table.h" | |
12 #include "components/sync/base/model_type.h" | |
13 #include "components/sync/model/metadata_change_list.h" | |
14 #include "components/sync/model/model_error.h" | |
15 #include "components/sync/model/sync_error.h" | |
16 #include "components/sync/protocol/entity_metadata.pb.h" | |
17 #include "components/sync/protocol/model_type_state.pb.h" | |
18 | |
19 namespace autofill { | |
20 | |
21 // A thin wrapper around an AutofillTable that implements sync's | |
22 // MetadataChangeList interface. Changes are passed directly into the table and | |
23 // not stored inside this object. Since the table calls can fail, |TakeError()| | |
24 // must be called before this object is destroyed to check whether any | |
25 // operations failed. | |
26 class AutofillMetadataChangeList : public syncer::MetadataChangeList { | |
27 public: | |
28 AutofillMetadataChangeList(AutofillTable* table, syncer::ModelType type); | |
29 ~AutofillMetadataChangeList() override; | |
30 | |
31 // syncer::MetadataChangeList implementation. | |
32 void UpdateModelTypeState( | |
33 const sync_pb::ModelTypeState& model_type_state) override; | |
34 void ClearModelTypeState() override; | |
35 void UpdateMetadata(const std::string& storage_key, | |
36 const sync_pb::EntityMetadata& metadata) override; | |
37 void ClearMetadata(const std::string& storage_key) override; | |
38 | |
39 // Returns the value of |error_| and unsets it. | |
40 base::Optional<syncer::ModelError> TakeError(); | |
41 | |
42 private: | |
43 // The autofill table to store metadata in; always outlives |this|. | |
44 AutofillTable* table_; | |
45 | |
46 // The sync model type for this metadata. | |
47 syncer::ModelType type_; | |
48 | |
49 // The first error encountered by this object, if any. | |
50 base::Optional<syncer::ModelError> error_; | |
51 }; | |
52 | |
53 } // namespace autofill | |
54 | |
55 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_METADATA_CHANGE_LIS
T_H_ | |
OLD | NEW |