1 // Copyright 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 // 5 // Definition of ModelTypeInvalidationMap and various utility functions. 6 7 #ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_INVALIDATION_MAP_H_ 8 #define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_INVALIDATION_MAP_H_ 9 10 #include <map> 11 #include <string> 12 13 #include "sync/base/sync_export.h" 14 #include "sync/internal_api/public/base/invalidation.h" 15 #include "sync/internal_api/public/base/model_type.h" 16 17 // TODO(akalin): Move the non-exported functions in this file to a 18 // private header. 19 20 namespace base { 21 class DictionaryValue; 22 } 23 24 namespace syncer { 25 26 // A map between sync data types and their associated invalidation. 27 typedef std::map<ModelType, Invalidation> ModelTypeInvalidationMap; 28 29 // Helper functions for building ModelTypeInvalidationMaps. 30 31 // Make a ModelTypeInvalidationMap from all the types in a ModelTypeSet using a 32 // default payload. 33 SYNC_EXPORT ModelTypeInvalidationMap ModelTypeSetToInvalidationMap( 34 ModelTypeSet model_types, const std::string& payload); 35 36 SYNC_EXPORT_PRIVATE ModelTypeSet ModelTypeInvalidationMapToSet( 37 const ModelTypeInvalidationMap& invalidation_map); 38 39 std::string ModelTypeInvalidationMapToString( 40 const ModelTypeInvalidationMap& invalidation_map); 41 42 // Caller takes ownership of the returned dictionary. 43 SYNC_EXPORT_PRIVATE base::DictionaryValue* ModelTypeInvalidationMapToValue( 44 const ModelTypeInvalidationMap& invalidation_map); 45 46 // Coalesce |update| into |original|, overwriting only when |update| has 47 // a non-empty payload. 48 SYNC_EXPORT_PRIVATE void CoalesceStates( 49 const ModelTypeInvalidationMap& update, ModelTypeInvalidationMap* original); 50 51 } // namespace syncer 52 53 #endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_INVALIDATION_MAP_H_ 54