[email protected] | b5d1f3f32 | 2012-01-20 09:51:42 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | // | ||||
5 | // Various utilities for dealing with invalidation data types. | ||||
6 | |||||
[email protected] | b7fe4b5 | 2012-04-19 14:21:09 | [diff] [blame] | 7 | #ifndef SYNC_NOTIFIER_INVALIDATION_UTIL_H_ |
8 | #define SYNC_NOTIFIER_INVALIDATION_UTIL_H_ | ||||
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 9 | |
[email protected] | bd6007e | 2012-08-24 04:29:44 | [diff] [blame] | 10 | #include <iosfwd> |
[email protected] | 8e4c8887 | 2012-06-28 04:34:35 | [diff] [blame] | 11 | #include <set> |
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 12 | #include <string> |
13 | |||||
[email protected] | 33596da | 2012-08-31 23:39:25 | [diff] [blame^] | 14 | #include "base/memory/scoped_ptr.h" |
[email protected] | 002d3919 | 2012-07-03 01:30:56 | [diff] [blame] | 15 | #include "sync/internal_api/public/base/model_type.h" |
[email protected] | d49f4633 | 2011-07-15 21:31:07 | [diff] [blame] | 16 | |
[email protected] | 33596da | 2012-08-31 23:39:25 | [diff] [blame^] | 17 | namespace base { |
18 | class DictionaryValue; | ||||
19 | } // namespace | ||||
20 | |||||
[email protected] | d49f4633 | 2011-07-15 21:31:07 | [diff] [blame] | 21 | namespace invalidation { |
22 | |||||
23 | class Invalidation; | ||||
24 | class ObjectId; | ||||
25 | |||||
[email protected] | bd6007e | 2012-08-24 04:29:44 | [diff] [blame] | 26 | // Gmock print helper |
27 | void PrintTo(const invalidation::ObjectId& id, std::ostream* os); | ||||
28 | |||||
[email protected] | d49f4633 | 2011-07-15 21:31:07 | [diff] [blame] | 29 | } // namespace invalidation |
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 30 | |
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 31 | namespace syncer { |
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 32 | |
[email protected] | 739cee3 | 2012-06-20 20:37:28 | [diff] [blame] | 33 | struct ObjectIdLessThan { |
34 | bool operator()(const invalidation::ObjectId& lhs, | ||||
35 | const invalidation::ObjectId& rhs) const; | ||||
36 | }; | ||||
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 37 | |
[email protected] | 8e4c8887 | 2012-06-28 04:34:35 | [diff] [blame] | 38 | typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet; |
39 | |||||
[email protected] | d45f0d9 | 2012-07-20 17:25:41 | [diff] [blame] | 40 | bool RealModelTypeToObjectId(ModelType model_type, |
[email protected] | 6a1d0f5 | 2010-06-30 05:11:53 | [diff] [blame] | 41 | invalidation::ObjectId* object_id); |
42 | |||||
43 | bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id, | ||||
[email protected] | d45f0d9 | 2012-07-20 17:25:41 | [diff] [blame] | 44 | ModelType* model_type); |
[email protected] | 6a1d0f5 | 2010-06-30 05:11:53 | [diff] [blame] | 45 | |
[email protected] | 33596da | 2012-08-31 23:39:25 | [diff] [blame^] | 46 | // Caller owns the returned DictionaryValue. |
47 | scoped_ptr<base::DictionaryValue> ObjectIdToValue( | ||||
48 | const invalidation::ObjectId& object_id); | ||||
49 | |||||
50 | bool ObjectIdFromValue(const base::DictionaryValue& value, | ||||
51 | invalidation::ObjectId* out); | ||||
[email protected] | d914f02 | 2012-07-27 02:02:00 | [diff] [blame] | 52 | |
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 53 | std::string ObjectIdToString(const invalidation::ObjectId& object_id); |
54 | |||||
[email protected] | 33596da | 2012-08-31 23:39:25 | [diff] [blame^] | 55 | ObjectIdSet ModelTypeSetToObjectIdSet(const ModelTypeSet& models); |
56 | ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids); | ||||
57 | |||||
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 58 | std::string InvalidationToString( |
59 | const invalidation::Invalidation& invalidation); | ||||
60 | |||||
[email protected] | 65f17355 | 2012-06-28 22:43:58 | [diff] [blame] | 61 | } // namespace syncer |
[email protected] | 8516471 | 2010-06-23 01:13:56 | [diff] [blame] | 62 | |
[email protected] | b7fe4b5 | 2012-04-19 14:21:09 | [diff] [blame] | 63 | #endif // SYNC_NOTIFIER_INVALIDATION_UTIL_H_ |