OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Wraps PrefService in an InvalidationStateTracker to allow SyncNotifiers | 5 // Wraps PrefService in an InvalidationStateTracker to allow SyncNotifiers |
6 // to use PrefService as persistence for invalidation state. It is not thread | 6 // to use PrefService as persistence for invalidation state. It is not thread |
7 // safe, and lives on the UI thread. | 7 // safe, and lives on the UI thread. |
8 | 8 |
9 #ifndef CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ | 9 #ifndef CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ |
10 #define CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ | 10 #define CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ |
(...skipping 22 matching lines...) Expand all Loading... |
33 class InvalidatorStorage : public base::SupportsWeakPtr<InvalidatorStorage>, | 33 class InvalidatorStorage : public base::SupportsWeakPtr<InvalidatorStorage>, |
34 public syncer::InvalidationStateTracker { | 34 public syncer::InvalidationStateTracker { |
35 public: | 35 public: |
36 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 36 static void RegisterUserPrefs(PrefRegistrySyncable* registry); |
37 | 37 |
38 // |pref_service| may be NULL (for unit tests), but in that case no setter | 38 // |pref_service| may be NULL (for unit tests), but in that case no setter |
39 // methods should be called. Does not own |pref_service|. | 39 // methods should be called. Does not own |pref_service|. |
40 explicit InvalidatorStorage(PrefService* pref_service); | 40 explicit InvalidatorStorage(PrefService* pref_service); |
41 virtual ~InvalidatorStorage(); | 41 virtual ~InvalidatorStorage(); |
42 | 42 |
43 // Erases invalidation versions and state stored on disk. | |
44 void Clear(); | |
45 | |
46 // InvalidationStateTracker implementation. | 43 // InvalidationStateTracker implementation. |
47 virtual syncer::InvalidationStateMap GetAllInvalidationStates() const | 44 virtual syncer::InvalidationStateMap GetAllInvalidationStates() const |
48 OVERRIDE; | 45 OVERRIDE; |
49 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id, | 46 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id, |
50 int64 max_version, | 47 int64 max_version, |
51 const std::string& payload) OVERRIDE; | 48 const std::string& payload) OVERRIDE; |
52 virtual void Forget(const syncer::ObjectIdSet& ids) OVERRIDE; | 49 virtual void Forget(const syncer::ObjectIdSet& ids) OVERRIDE; |
53 virtual void SetInvalidatorClientId(const std::string& client_id) OVERRIDE; | 50 virtual void SetInvalidatorClientId(const std::string& client_id) OVERRIDE; |
54 virtual std::string GetInvalidatorClientId() const OVERRIDE; | 51 virtual std::string GetInvalidatorClientId() const OVERRIDE; |
55 virtual void SetBootstrapData(const std::string& data) OVERRIDE; | 52 virtual void SetBootstrapData(const std::string& data) OVERRIDE; |
56 virtual std::string GetBootstrapData() const OVERRIDE; | 53 virtual std::string GetBootstrapData() const OVERRIDE; |
| 54 virtual void Clear() OVERRIDE; |
57 virtual void GenerateAckHandles( | 55 virtual void GenerateAckHandles( |
58 const syncer::ObjectIdSet& ids, | 56 const syncer::ObjectIdSet& ids, |
59 const scoped_refptr<base::TaskRunner>& task_runner, | 57 const scoped_refptr<base::TaskRunner>& task_runner, |
60 base::Callback<void(const syncer::AckHandleMap&)> callback) OVERRIDE; | 58 base::Callback<void(const syncer::AckHandleMap&)> callback) OVERRIDE; |
61 virtual void Acknowledge(const invalidation::ObjectId& id, | 59 virtual void Acknowledge(const invalidation::ObjectId& id, |
62 const syncer::AckHandle& ack_handle) OVERRIDE; | 60 const syncer::AckHandle& ack_handle) OVERRIDE; |
63 | 61 |
64 private: | 62 private: |
65 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap); | 63 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap); |
66 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | 64 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 97 |
100 // May be NULL. | 98 // May be NULL. |
101 PrefService* const pref_service_; | 99 PrefService* const pref_service_; |
102 | 100 |
103 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); | 101 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); |
104 }; | 102 }; |
105 | 103 |
106 } // namespace browser_sync | 104 } // namespace browser_sync |
107 | 105 |
108 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ | 106 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ |
OLD | NEW |