Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: sync/notifier/invalidation_state_tracker.h

Issue 221963003: Reduce dependency of TiclInvalidationService on Profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass scoped_refptr as const reference. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // An InvalidationStateTracker is an interface that handles persisting state 5 // An InvalidationStateTracker is an interface that handles persisting state
6 // needed for invalidations. Currently, it is responsible for managing the 6 // needed for invalidations. Currently, it is responsible for managing the
7 // following information: 7 // following information:
8 // - Max version seen from the invalidation server to help dedupe invalidations. 8 // - Max version seen from the invalidation server to help dedupe invalidations.
9 // - Bootstrap data for the invalidation client. 9 // - Bootstrap data for the invalidation client.
10 // - Payloads and locally generated ack handles, to support local acking. 10 // - Payloads and locally generated ack handles, to support local acking.
11 11
12 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ 12 #ifndef SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
13 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ 13 #define SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
14 14
15 #include <map> 15 #include <map>
16 #include <string> 16 #include <string>
17 17
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "base/callback_forward.h" 19 #include "base/callback_forward.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h"
21 #include "google/cacheinvalidation/include/types.h" 22 #include "google/cacheinvalidation/include/types.h"
22 #include "sync/base/sync_export.h" 23 #include "sync/base/sync_export.h"
23 #include "sync/internal_api/public/base/invalidation.h" 24 #include "sync/internal_api/public/base/invalidation.h"
24 #include "sync/notifier/invalidation_util.h" 25 #include "sync/notifier/invalidation_util.h"
25 #include "sync/notifier/unacked_invalidation_set.h" 26 #include "sync/notifier/unacked_invalidation_set.h"
26 27
27 namespace base { 28 namespace base {
28 class TaskRunner; 29 class TaskRunner;
29 } // namespace base 30 } // namespace base
30 31
31 namespace syncer { 32 namespace syncer {
32 33
33 class InvalidationStateTracker { 34 class InvalidationStateTracker {
34 public: 35 public:
35 InvalidationStateTracker() {} 36 InvalidationStateTracker() : weak_factory_(this) {}
37 virtual ~InvalidationStateTracker() {}
38
39 base::WeakPtr<InvalidationStateTracker> GetWeakPtr() {
40 return weak_factory_.GetWeakPtr();
41 }
36 42
37 // The per-client unique ID used to register the invalidation client with the 43 // The per-client unique ID used to register the invalidation client with the
38 // server. This is used to squelch invalidation notifications that originate 44 // server. This is used to squelch invalidation notifications that originate
39 // from changes made by this client. 45 // from changes made by this client. Setting the client ID clears all other
46 // state.
40 virtual void SetInvalidatorClientId(const std::string& data) = 0; 47 virtual void SetInvalidatorClientId(const std::string& data) = 0;
41 virtual std::string GetInvalidatorClientId() const = 0; 48 virtual std::string GetInvalidatorClientId() const = 0;
42 49
43 // Used by invalidation::InvalidationClient for persistence. |data| is an 50 // Used by invalidation::InvalidationClient for persistence. |data| is an
44 // opaque blob that an invalidation client can use after a restart to 51 // opaque blob that an invalidation client can use after a restart to
45 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls, 52 // bootstrap itself. |data| is binary data (not valid UTF8, embedded nulls,
46 // etc). 53 // etc).
47 virtual void SetBootstrapData(const std::string& data) = 0; 54 virtual void SetBootstrapData(const std::string& data) = 0;
48 virtual std::string GetBootstrapData() const = 0; 55 virtual std::string GetBootstrapData() const = 0;
49 56
50 // Used to store invalidations that have been acked to the server, but not yet 57 // 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 58 // handled by our clients. We store these invalidations on disk so we won't
52 // lose them if we need to restart. 59 // lose them if we need to restart.
53 virtual void SetSavedInvalidations(const UnackedInvalidationsMap& states) = 0; 60 virtual void SetSavedInvalidations(const UnackedInvalidationsMap& states) = 0;
54 virtual UnackedInvalidationsMap GetSavedInvalidations() const = 0; 61 virtual UnackedInvalidationsMap GetSavedInvalidations() const = 0;
55 62
56 // Erases invalidation versions, client ID, and state stored on disk. 63 // Erases invalidation versions, client ID, and state stored on disk.
57 virtual void Clear() = 0; 64 virtual void Clear() = 0;
58 65
59 protected: 66 private:
60 virtual ~InvalidationStateTracker() {} 67 base::WeakPtrFactory<InvalidationStateTracker> weak_factory_;
61 }; 68 };
62 69
63 } // namespace syncer 70 } // namespace syncer
64 71
65 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_ 72 #endif // SYNC_NOTIFIER_INVALIDATION_STATE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698