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