blob: 61bd3171d462e23e77ad9e3acd308391ff330b79 [file] [log] [blame]
[email protected]b5d1f3f322012-01-20 09:51:421// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]85164712010-06-23 01:13:562// 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]b7fe4b52012-04-19 14:21:097#ifndef SYNC_NOTIFIER_INVALIDATION_UTIL_H_
8#define SYNC_NOTIFIER_INVALIDATION_UTIL_H_
[email protected]85164712010-06-23 01:13:569
[email protected]bd6007e2012-08-24 04:29:4410#include <iosfwd>
[email protected]8e4c88872012-06-28 04:34:3511#include <set>
[email protected]85164712010-06-23 01:13:5612#include <string>
13
[email protected]33596da2012-08-31 23:39:2514#include "base/memory/scoped_ptr.h"
[email protected]002d39192012-07-03 01:30:5615#include "sync/internal_api/public/base/model_type.h"
[email protected]d49f46332011-07-15 21:31:0716
[email protected]33596da2012-08-31 23:39:2517namespace base {
18class DictionaryValue;
19} // namespace
20
[email protected]d49f46332011-07-15 21:31:0721namespace invalidation {
22
23class Invalidation;
24class ObjectId;
25
[email protected]bd6007e2012-08-24 04:29:4426// Gmock print helper
27void PrintTo(const invalidation::ObjectId& id, std::ostream* os);
28
[email protected]d49f46332011-07-15 21:31:0729} // namespace invalidation
[email protected]85164712010-06-23 01:13:5630
[email protected]65f173552012-06-28 22:43:5831namespace syncer {
[email protected]85164712010-06-23 01:13:5632
[email protected]739cee32012-06-20 20:37:2833struct ObjectIdLessThan {
34 bool operator()(const invalidation::ObjectId& lhs,
35 const invalidation::ObjectId& rhs) const;
36};
[email protected]85164712010-06-23 01:13:5637
[email protected]8e4c88872012-06-28 04:34:3538typedef std::set<invalidation::ObjectId, ObjectIdLessThan> ObjectIdSet;
39
[email protected]d45f0d92012-07-20 17:25:4140bool RealModelTypeToObjectId(ModelType model_type,
[email protected]6a1d0f52010-06-30 05:11:5341 invalidation::ObjectId* object_id);
42
43bool ObjectIdToRealModelType(const invalidation::ObjectId& object_id,
[email protected]d45f0d92012-07-20 17:25:4144 ModelType* model_type);
[email protected]6a1d0f52010-06-30 05:11:5345
[email protected]33596da2012-08-31 23:39:2546// Caller owns the returned DictionaryValue.
47scoped_ptr<base::DictionaryValue> ObjectIdToValue(
48 const invalidation::ObjectId& object_id);
49
50bool ObjectIdFromValue(const base::DictionaryValue& value,
51 invalidation::ObjectId* out);
[email protected]d914f022012-07-27 02:02:0052
[email protected]85164712010-06-23 01:13:5653std::string ObjectIdToString(const invalidation::ObjectId& object_id);
54
[email protected]33596da2012-08-31 23:39:2555ObjectIdSet ModelTypeSetToObjectIdSet(const ModelTypeSet& models);
56ModelTypeSet ObjectIdSetToModelTypeSet(const ObjectIdSet& ids);
57
[email protected]85164712010-06-23 01:13:5658std::string InvalidationToString(
59 const invalidation::Invalidation& invalidation);
60
[email protected]65f173552012-06-28 22:43:5861} // namespace syncer
[email protected]85164712010-06-23 01:13:5662
[email protected]b7fe4b52012-04-19 14:21:0963#endif // SYNC_NOTIFIER_INVALIDATION_UTIL_H_