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