[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / components / invalidation / invalidation_state_tracker.h
blob6e03dabc68f48c92e38d87f4e9bc2942dde926ad
1 // Copyright 2014 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.
4 //
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 COMPONENTS_INVALIDATION_INVALIDATION_STATE_TRACKER_H_
13 #define COMPONENTS_INVALIDATION_INVALIDATION_STATE_TRACKER_H_
15 #include <map>
16 #include <string>
18 #include "base/basictypes.h"
19 #include "base/callback_forward.h"
20 #include "base/memory/ref_counted.h"
21 #include "components/invalidation/invalidation.h"
22 #include "components/invalidation/invalidation_export.h"
23 #include "components/invalidation/invalidation_util.h"
24 #include "components/invalidation/unacked_invalidation_set.h"
25 #include "google/cacheinvalidation/include/types.h"
27 namespace base {
28 class TaskRunner;
29 } // namespace base
31 namespace syncer {
33 class INVALIDATION_EXPORT InvalidationStateTracker {
34 public:
35 InvalidationStateTracker();
36 virtual ~InvalidationStateTracker();
38 // The per-client unique ID used to register the invalidation client with the
39 // server. This is used to squelch invalidation notifications that originate
40 // from changes made by this client. Setting the client ID clears all other
41 // state.
42 virtual void ClearAndSetNewClientId(const std::string& data) = 0;
43 virtual std::string GetInvalidatorClientId() const = 0;
45 // Used by invalidation::InvalidationClient for persistence. |data| is an
46 // opaque blob that an invalidation client can use after a restart to
47 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls,
48 // etc).
49 virtual void SetBootstrapData(const std::string& data) = 0;
50 virtual std::string GetBootstrapData() const = 0;
52 // Used to store invalidations that have been acked to the server, but not yet
53 // handled by our clients. We store these invalidations on disk so we won't
54 // lose them if we need to restart.
55 virtual void SetSavedInvalidations(const UnackedInvalidationsMap& states) = 0;
56 virtual UnackedInvalidationsMap GetSavedInvalidations() const = 0;
58 // Erases invalidation versions, client ID, and state stored on disk.
59 virtual void Clear() = 0;
62 } // namespace syncer
64 #endif // COMPONENTS_INVALIDATION_INVALIDATION_STATE_TRACKER_H_