summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/public/base/invalidation.h
blob: fc8c361c65086da59befa034ddbfe1c72a7f1764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_
#define SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_

#include <string>

#include "base/memory/scoped_ptr.h"

namespace base {
class DictionaryValue;
class Value;
}  // namespace

namespace syncer {

// Opaque class that represents an ack handle.
// TODO(dcheng): This is just a refactoring change, so the class is empty for
// the moment. It will be filled once we start implementing 'reminders'.
class AckHandle {
 public:
  bool Equals(const AckHandle& other) const;

  scoped_ptr<base::Value> ToValue() const;

  bool ResetFromValue(const base::Value& value);
};

// Represents a local invalidation, and is roughly analogous to
// invalidation::Invalidation. It contains a payload (which may be empty) and an
// associated ack handle that an InvalidationHandler implementation can use to
// acknowledge receipt of the invalidation. It does not embed the object ID,
// since it is typically associated with it through ObjectIdInvalidationMap.
struct Invalidation {
  std::string payload;
  AckHandle ack_handle;

  bool Equals(const Invalidation& other) const;

  // Caller owns the returned DictionaryValue.
  scoped_ptr<base::DictionaryValue> ToValue() const;

  bool ResetFromValue(const base::DictionaryValue& value);
};

}  // namespace syncer

#endif  // SYNC_INTERNAL_API_PUBLIC_BASE_INVALIDATION_H_