| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Definition of ModelTypePayloadMap and various utility functions. | 5 // Definition of ModelTypePayloadMap and various utility functions. |
| 6 | 6 |
| 7 #ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_ | 7 #ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_ |
| 8 #define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_ | 8 #define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "sync/base/sync_export.h" |
| 13 #include "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
| 14 | 15 |
| 16 // TODO(akalin): Move the non-exported functions in this file to a |
| 17 // private header. |
| 18 |
| 15 namespace base { | 19 namespace base { |
| 16 class DictionaryValue; | 20 class DictionaryValue; |
| 17 } | 21 } |
| 18 | 22 |
| 19 namespace syncer { | 23 namespace syncer { |
| 20 | 24 |
| 21 // A container that contains a set of datatypes with possible string | 25 // A container that contains a set of datatypes with possible string |
| 22 // payloads. | 26 // payloads. |
| 23 typedef std::map<ModelType, std::string> ModelTypePayloadMap; | 27 typedef std::map<ModelType, std::string> ModelTypePayloadMap; |
| 24 | 28 |
| 25 // Helper functions for building ModelTypePayloadMaps. | 29 // Helper functions for building ModelTypePayloadMaps. |
| 26 | 30 |
| 27 // Make a TypePayloadMap from all the types in a ModelTypeSet using a | 31 // Make a TypePayloadMap from all the types in a ModelTypeSet using a |
| 28 // default payload. | 32 // default payload. |
| 29 ModelTypePayloadMap ModelTypePayloadMapFromEnumSet( | 33 SYNC_EXPORT ModelTypePayloadMap ModelTypePayloadMapFromEnumSet( |
| 30 ModelTypeSet model_types, const std::string& payload); | 34 ModelTypeSet model_types, const std::string& payload); |
| 31 | 35 |
| 32 ModelTypeSet ModelTypePayloadMapToEnumSet( | 36 ModelTypeSet ModelTypePayloadMapToEnumSet( |
| 33 const ModelTypePayloadMap& payload_map); | 37 const ModelTypePayloadMap& payload_map); |
| 34 | 38 |
| 35 std::string ModelTypePayloadMapToString( | 39 std::string ModelTypePayloadMapToString( |
| 36 const ModelTypePayloadMap& model_type_payloads); | 40 const ModelTypePayloadMap& model_type_payloads); |
| 37 | 41 |
| 38 // Caller takes ownership of the returned dictionary. | 42 // Caller takes ownership of the returned dictionary. |
| 39 base::DictionaryValue* ModelTypePayloadMapToValue( | 43 base::DictionaryValue* ModelTypePayloadMapToValue( |
| 40 const ModelTypePayloadMap& model_type_payloads); | 44 const ModelTypePayloadMap& model_type_payloads); |
| 41 | 45 |
| 42 // Coalesce |update| into |original|, overwriting only when |update| has | 46 // Coalesce |update| into |original|, overwriting only when |update| has |
| 43 // a non-empty payload. | 47 // a non-empty payload. |
| 44 void CoalescePayloads(ModelTypePayloadMap* original, | 48 void CoalescePayloads(ModelTypePayloadMap* original, |
| 45 const ModelTypePayloadMap& update); | 49 const ModelTypePayloadMap& update); |
| 46 | 50 |
| 47 } // namespace syncer | 51 } // namespace syncer |
| 48 | 52 |
| 49 #endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_ | 53 #endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_PAYLOAD_MAP_H_ |
| OLD | NEW |