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