OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Various utilities for dealing with invalidation data types. | 5 // Various utilities for dealing with invalidation data types. |
6 | 6 |
7 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_ | 7 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_ |
8 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_ | 8 #define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_ |
9 | 9 |
10 #include <iosfwd> | |
11 #include <map> | 10 #include <map> |
12 #include <set> | 11 #include <set> |
13 #include <string> | 12 #include <string> |
14 | 13 |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "sync/base/sync_export.h" | 15 #include "sync/base/sync_export.h" |
17 #include "sync/internal_api/public/base/model_type.h" | |
18 | 16 |
19 namespace base { | 17 namespace base { |
20 class DictionaryValue; | 18 class DictionaryValue; |
21 } // namespace | 19 } // namespace |
22 | 20 |
23 namespace invalidation { | 21 namespace invalidation { |
24 | 22 |
25 class Invalidation; | 23 class Invalidation; |
26 class ObjectId; | 24 class ObjectId; |
27 | 25 |
28 // Gmock print helper | |
29 SYNC_EXPORT_PRIVATE void PrintTo(const invalidation::ObjectId& id, | |
30 std::ostream* os); | |
31 | |
32 } // namespace invalidation | 26 } // namespace invalidation |
33 | 27 |
34 namespace syncer { | 28 namespace syncer { |
35 | 29 |
36 class Invalidation; | 30 class Invalidation; |
37 | 31 |
38 struct SYNC_EXPORT ObjectIdLessThan { | 32 struct SYNC_EXPORT ObjectIdLessThan { |
39 bool operator()(const invalidation::ObjectId& lhs, | 33 bool operator()(const invalidation::ObjectId& lhs, |
40 const invalidation::ObjectId& rhs) const; | 34 const invalidation::ObjectId& rhs) const; |
41 }; | 35 }; |
42 | 36 |
43 struct SYNC_EXPORT InvalidationVersionLessThan { | 37 struct SYNC_EXPORT InvalidationVersionLessThan { |
44 bool operator()(const syncer::Invalidation& a, | 38 bool operator()(const syncer::Invalidation& a, |
45 const syncer::Invalidation& b) const; | 39 const syncer::Invalidation& b) const; |
46 }; | 40 }; |
47 | 41 |
48 typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet; | 42 typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet; |
49 | 43 |
50 typedef std::map<invalidation::ObjectId, int, ObjectIdLessThan> | 44 typedef std::map<invalidation::ObjectId, int, ObjectIdLessThan> |
51 ObjectIdCountMap; | 45 ObjectIdCountMap; |
52 | 46 |
53 SYNC_EXPORT bool RealModelTypeToObjectId(ModelType model_type, | |
54 invalidation::ObjectId* object_id); | |
55 | |
56 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, | |
57 ModelType* model_type); | |
58 | |
59 // Caller owns the returned DictionaryValue. | 47 // Caller owns the returned DictionaryValue. |
60 scoped_ptr<base::DictionaryValue> ObjectIdToValue( | 48 scoped_ptr<base::DictionaryValue> ObjectIdToValue( |
61 const invalidation::ObjectId& object_id); | 49 const invalidation::ObjectId& object_id); |
62 | 50 |
63 bool ObjectIdFromValue(const base::DictionaryValue& value, | 51 bool ObjectIdFromValue(const base::DictionaryValue& value, |
64 invalidation::ObjectId* out); | 52 invalidation::ObjectId* out); |
65 | 53 |
66 SYNC_EXPORT_PRIVATE std::string ObjectIdToString( | 54 SYNC_EXPORT_PRIVATE std::string ObjectIdToString( |
67 const invalidation::ObjectId& object_id); | 55 const invalidation::ObjectId& object_id); |
68 | 56 |
69 SYNC_EXPORT_PRIVATE ObjectIdSet ModelTypeSetToObjectIdSet(ModelTypeSet models); | |
70 ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids); | |
71 | |
72 std::string InvalidationToString( | |
73 const invalidation::Invalidation& invalidation); | |
74 | |
75 } // namespace syncer | 57 } // namespace syncer |
76 | 58 |
77 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_ | 59 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_UTIL_H_ |
OLD | NEW |