OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 ModelTypePayloadMap and various utility functions. | |
6 | |
7 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_PAYLOAD_MAP_H_ | |
8 #define CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_PAYLOAD_MAP_H_ | |
9 #pragma once | |
10 | |
11 #include <map> | |
12 #include <string> | |
13 | |
14 #include "chrome/browser/sync/engine/model_safe_worker.h" | |
15 #include "chrome/browser/sync/syncable/model_type.h" | |
16 | |
17 namespace base { | |
18 class DictionaryValue; | |
19 } | |
20 | |
21 namespace syncable { | |
22 | |
23 // A container that contains a set of datatypes with possible string | |
24 // payloads. | |
25 typedef std::map<ModelType, std::string> ModelTypePayloadMap; | |
26 | |
27 // Helper functions for building ModelTypePayloadMaps. | |
28 | |
29 // Make a TypePayloadMap from all the types in a ModelTypeSet using a | |
30 // default payload. | |
31 ModelTypePayloadMap ModelTypePayloadMapFromEnumSet( | |
32 ModelTypeSet model_types, const std::string& payload); | |
33 | |
34 ModelTypeSet ModelTypePayloadMapToEnumSet( | |
35 const ModelTypePayloadMap& payload_map); | |
36 | |
37 // Make a TypePayloadMap for all the enabled types in a | |
38 // ModelSafeRoutingInfo using a default payload. | |
39 ModelTypePayloadMap ModelTypePayloadMapFromRoutingInfo( | |
40 const browser_sync::ModelSafeRoutingInfo& routes, | |
41 const std::string& payload); | |
42 | |
43 std::string ModelTypePayloadMapToString( | |
44 const ModelTypePayloadMap& model_type_payloads); | |
45 | |
46 // Caller takes ownership of the returned dictionary. | |
47 base::DictionaryValue* ModelTypePayloadMapToValue( | |
48 const ModelTypePayloadMap& model_type_payloads); | |
49 | |
50 // Coalesce |update| into |original|, overwriting only when |update| has | |
51 // a non-empty payload. | |
52 void CoalescePayloads(ModelTypePayloadMap* original, | |
53 const ModelTypePayloadMap& update); | |
54 | |
55 void PurgeStalePayload(ModelTypePayloadMap* original, | |
56 const browser_sync::ModelSafeRoutingInfo& routing_info); | |
57 | |
58 } // namespace syncable | |
59 | |
60 #endif // CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_PAYLOAD_MAP_H_ | |
OLD | NEW |