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