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
3 // found in the LICENSE file.
5 // An InvalidationStateTracker is an interface that handles persisting state
6 // needed for invalidations. Currently, it is responsible for managing the
7 // following information:
8 // - Max version seen from the invalidation server to help dedupe invalidations.
9 // - Bootstrap data for the invalidation client.
10 // - Payloads and locally generated ack handles, to support local acking.
12 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
13 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
18 #include "base/basictypes.h"
19 #include "base/callback_forward.h"
20 #include "base/memory/ref_counted.h"
21 #include "google/cacheinvalidation/include/types.h"
22 #include "sync/base/sync_export.h"
23 #include "sync/internal_api/public/base/invalidation.h"
24 #include "sync/notifier/invalidation_util.h"
25 #include "sync/notifier/unacked_invalidation_set.h"
33 class InvalidationStateTracker {
35 InvalidationStateTracker() {}
37 // The per-client unique ID used to register the invalidation client with the
38 // server. This is used to squelch invalidation notifications that originate
39 // from changes made by this client.
40 virtual void SetInvalidatorClientId(const std::string& data) = 0;
41 virtual std::string GetInvalidatorClientId() const = 0;
43 // Used by invalidation::InvalidationClient for persistence. |data| is an
44 // opaque blob that an invalidation client can use after a restart to
45 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls,
47 virtual void SetBootstrapData(const std::string& data) = 0;
48 virtual std::string GetBootstrapData() const = 0;
50 // Used to store invalidations that have been acked to the server, but not yet
51 // handled by our clients. We store these invalidations on disk so we won't
52 // lose them if we need to restart.
53 virtual void SetSavedInvalidations(const UnackedInvalidationsMap& states) = 0;
54 virtual UnackedInvalidationsMap GetSavedInvalidations() const = 0;
56 // Erases invalidation versions, client ID, and state stored on disk.
57 virtual void Clear() = 0;
60 virtual ~InvalidationStateTracker() {}
65 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_