Chromium Code Reviews| 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 // 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 "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
| 15 | 15 |
| 16 namespace base { | |
| 17 class DictionaryValue; | |
| 18 } // namespace | |
| 19 | |
| 16 namespace invalidation { | 20 namespace invalidation { |
| 17 | 21 |
| 18 class Invalidation; | 22 class Invalidation; |
| 19 class ObjectId; | 23 class ObjectId; |
| 20 | 24 |
| 21 // Gmock print helper | 25 // Gmock print helper |
| 22 void PrintTo(const invalidation::ObjectId& id, std::ostream* os); | 26 void PrintTo(const invalidation::ObjectId& id, std::ostream* os); |
| 23 | 27 |
| 24 } // namespace invalidation | 28 } // namespace invalidation |
| 25 | 29 |
| 26 namespace syncer { | 30 namespace syncer { |
| 27 | 31 |
| 28 struct ObjectIdLessThan { | 32 struct ObjectIdLessThan { |
| 29 bool operator()(const invalidation::ObjectId& lhs, | 33 bool operator()(const invalidation::ObjectId& lhs, |
| 30 const invalidation::ObjectId& rhs) const; | 34 const invalidation::ObjectId& rhs) const; |
| 31 }; | 35 }; |
| 32 | 36 |
| 33 typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet; | 37 typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet; |
| 34 | 38 |
| 35 bool RealModelTypeToObjectId(ModelType model_type, | 39 bool RealModelTypeToObjectId(ModelType model_type, |
| 36 invalidation::ObjectId* object_id); | 40 invalidation::ObjectId* object_id); |
| 37 | 41 |
| 38 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, | 42 bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, |
| 39 ModelType* model_type); | 43 ModelType* model_type); |
| 40 | 44 |
| 45 // Caller owns the returned DictionaryValue. | |
| 46 base::DictionaryValue* ObjectIdToValue( | |
|
Nicolas Zea
2012/08/29 23:41:05
return scoped ptr?
akalin
2012/08/30 22:20:38
Done.
| |
| 47 const invalidation::ObjectId& object_id); | |
| 48 | |
| 49 bool ObjectIdFromValue(const base::DictionaryValue& value, | |
| 50 invalidation::ObjectId* out); | |
| 51 | |
| 52 std::string ObjectIdToString(const invalidation::ObjectId& object_id); | |
| 53 | |
| 41 ObjectIdSet ModelTypeSetToObjectIdSet(const ModelTypeSet& models); | 54 ObjectIdSet ModelTypeSetToObjectIdSet(const ModelTypeSet& models); |
| 42 ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids); | 55 ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids); |
| 43 | 56 |
| 44 std::string ObjectIdToString(const invalidation::ObjectId& object_id); | |
| 45 | |
| 46 std::string InvalidationToString( | 57 std::string InvalidationToString( |
| 47 const invalidation::Invalidation& invalidation); | 58 const invalidation::Invalidation& invalidation); |
| 48 | 59 |
| 49 } // namespace syncer | 60 } // namespace syncer |
| 50 | 61 |
| 51 #endif // SYNC_NOTIFIER_INVALIDATION_UTIL_H_ | 62 #endif // SYNC_NOTIFIER_INVALIDATION_UTIL_H_ |
| OLD | NEW |