Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "sync/api/metadata_change_list.h" | 11 #include "sync/api/metadata_change_list.h" |
| 11 #include "sync/api/model_type_store.h" | 12 #include "sync/api/model_type_store.h" |
| 12 #include "sync/base/sync_export.h" | 13 #include "sync/base/sync_export.h" |
| 14 #include "sync/internal_api/public/non_blocking_sync_common.h" | |
| 15 #include "sync/protocol/data_type_state.pb.h" | |
| 16 #include "sync/protocol/entity_metadata.pb.h" | |
| 13 | 17 |
| 14 namespace syncer_v2 { | 18 namespace syncer_v2 { |
| 15 | 19 |
| 16 // A MetadataChangeList implementation that is meant to be used in combination | 20 // A MetadataChangeList implementation that is meant to be used in combination |
|
maxbogue
2016/02/12 18:06:57
I'm leaving this comment as-is for now until we sp
| |
| 17 // with a ModelTypeStore. It accumulates changes in member fields, and then when | 21 // with a ModelTypeStore. It accumulates changes in member fields, and then when |
| 18 // requested transfers them to the store/write batch. | 22 // requested transfers them to the store/write batch. |
| 19 class SYNC_EXPORT SimpleMetadataChangeList : public MetadataChangeList { | 23 class SYNC_EXPORT SimpleMetadataChangeList : public MetadataChangeList { |
| 20 public: | 24 public: |
| 25 enum ChangeType { UPDATE, CLEAR }; | |
| 26 | |
| 27 struct MetadataChange { | |
| 28 ChangeType type; | |
| 29 sync_pb::EntityMetadata metadata; | |
| 30 }; | |
| 31 | |
| 32 struct DataTypeStateChange { | |
| 33 ChangeType type; | |
| 34 sync_pb::DataTypeState state; | |
| 35 }; | |
| 36 | |
| 37 typedef std::map<std::string, MetadataChange> MetadataChanges; | |
| 38 | |
| 21 SimpleMetadataChangeList(); | 39 SimpleMetadataChangeList(); |
| 22 ~SimpleMetadataChangeList() override; | 40 ~SimpleMetadataChangeList() override; |
| 23 | 41 |
| 24 void UpdateDataTypeState( | 42 void UpdateDataTypeState( |
| 25 const sync_pb::DataTypeState& data_type_state) override; | 43 const sync_pb::DataTypeState& data_type_state) override; |
| 26 void ClearDataTypeState() override; | 44 void ClearDataTypeState() override; |
| 27 void UpdateMetadata(const std::string& client_tag, | 45 void UpdateMetadata(const std::string& client_tag, |
| 28 const sync_pb::EntityMetadata& metadata) override; | 46 const sync_pb::EntityMetadata& metadata) override; |
| 29 void ClearMetadata(const std::string& client_tag) override; | 47 void ClearMetadata(const std::string& client_tag) override; |
| 30 | 48 |
| 49 const MetadataChanges& GetMetadataChanges() const; | |
|
pavely
2016/02/17 00:56:40
Do you plan to call these functions from outside o
maxbogue
2016/02/17 19:31:42
They're gonna be called in tests, yes. TransferCha
| |
| 50 bool HasDataTypeStateChange() const; | |
| 51 const DataTypeStateChange& GetDataTypeStateChange() const; | |
| 52 | |
| 31 // Moves all currently accumulated changes into the write batch, clear out | 53 // Moves all currently accumulated changes into the write batch, clear out |
| 32 // local copies. Calling this multiple times will work, but should not be | 54 // local copies. Calling this multiple times will work, but should not be |
| 33 // necessary. | 55 // necessary. |
| 34 void TranfserChanges(ModelTypeStore* store, | 56 void TransferChanges(ModelTypeStore* store, |
| 35 ModelTypeStore::WriteBatch* write_batch); | 57 ModelTypeStore::WriteBatch* write_batch); |
| 58 | |
| 59 private: | |
| 60 MetadataChanges metadata_changes_; | |
| 61 scoped_ptr<DataTypeStateChange> state_change_; | |
| 36 }; | 62 }; |
| 37 | 63 |
| 38 } // namespace syncer_v2 | 64 } // namespace syncer_v2 |
| 39 | 65 |
| 40 #endif // SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_ | 66 #endif // SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_ |
| OLD | NEW |