| 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_API_METADATA_BATCH_H_ | 5 #ifndef SYNC_API_METADATA_BATCH_H_ |
| 6 #define SYNC_API_METADATA_BATCH_H_ | 6 #define SYNC_API_METADATA_BATCH_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> |
| 9 | 10 |
| 10 #include "sync/base/sync_export.h" | 11 #include "sync/base/sync_export.h" |
| 11 #include "sync/internal_api/public/non_blocking_sync_common.h" | 12 #include "sync/protocol/data_type_state.pb.h" |
| 12 #include "sync/protocol/entity_metadata.pb.h" | 13 #include "sync/protocol/entity_metadata.pb.h" |
| 13 | 14 |
| 14 namespace syncer_v2 { | 15 namespace syncer_v2 { |
| 15 | 16 |
| 16 // Map of client tag to EntityMetadata proto. | 17 // Map of client tag to EntityMetadata proto. |
| 17 typedef std::map<std::string, sync_pb::EntityMetadata> EntityMetadataMap; | 18 typedef std::map<std::string, sync_pb::EntityMetadata> EntityMetadataMap; |
| 18 | 19 |
| 19 // Container used to pass sync metadata from services to their processor. | 20 // Container used to pass sync metadata from services to their processor. |
| 20 class SYNC_EXPORT MetadataBatch { | 21 class SYNC_EXPORT MetadataBatch { |
| 21 public: | 22 public: |
| 22 MetadataBatch(); | 23 MetadataBatch(); |
| 23 virtual ~MetadataBatch(); | 24 virtual ~MetadataBatch(); |
| 24 | 25 |
| 25 // Allows the caller to take ownership of the entire metadata map. This is | 26 // Allows the caller to take ownership of the entire metadata map. This is |
| 26 // done because the caller will probably swap out all the EntityMetadata | 27 // done because the caller will probably swap out all the EntityMetadata |
| 27 // protos from the map for performance reasons. | 28 // protos from the map for performance reasons. |
| 28 EntityMetadataMap&& TakeAllMetadata(); | 29 EntityMetadataMap&& TakeAllMetadata(); |
| 29 | 30 |
| 30 // Add |metadata| for |client_tag| to the batch. | 31 // Add |metadata| for |client_tag| to the batch. |
| 31 void AddMetadata(const std::string& client_tag, | 32 void AddMetadata(const std::string& client_tag, |
| 32 const sync_pb::EntityMetadata& metadata); | 33 const sync_pb::EntityMetadata& metadata); |
| 33 | 34 |
| 34 // Get the DataTypeState for this batch. | 35 // Get the DataTypeState for this batch. |
| 35 const DataTypeState& GetDataTypeState() const; | 36 const sync_pb::DataTypeState& GetDataTypeState() const; |
| 36 | 37 |
| 37 // Set the DataTypeState for this batch. | 38 // Set the DataTypeState for this batch. |
| 38 void SetDataTypeState(const DataTypeState& state); | 39 void SetDataTypeState(const sync_pb::DataTypeState& state); |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 EntityMetadataMap metadata_map_; | 42 EntityMetadataMap metadata_map_; |
| 42 DataTypeState state_; | 43 sync_pb::DataTypeState state_; |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 } // namespace syncer_v2 | 46 } // namespace syncer_v2 |
| 46 | 47 |
| 47 #endif // SYNC_API_METADATA_BATCH_H_ | 48 #endif // SYNC_API_METADATA_BATCH_H_ |
| OLD | NEW |