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

Side by Side Diff: chrome/browser/sync/invalidations/invalidator_storage.h

Issue 10911084: Implement Invalidator::Acknowledge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback from petewil Created 8 years, 3 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 (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 23 matching lines...) Expand all
34 public: 34 public:
35 // |pref_service| may be NULL (for unit tests), but in that case no setter 35 // |pref_service| may be NULL (for unit tests), but in that case no setter
36 // methods should be called. Does not own |pref_service|. 36 // methods should be called. Does not own |pref_service|.
37 explicit InvalidatorStorage(PrefService* pref_service); 37 explicit InvalidatorStorage(PrefService* pref_service);
38 virtual ~InvalidatorStorage(); 38 virtual ~InvalidatorStorage();
39 39
40 // Erases invalidation versions and state stored on disk. 40 // Erases invalidation versions and state stored on disk.
41 void Clear(); 41 void Clear();
42 42
43 // InvalidationStateTracker implementation. 43 // InvalidationStateTracker implementation.
44 virtual syncer::InvalidationVersionMap GetAllMaxVersions() const 44 virtual syncer::InvalidationStateMap GetStateMap() const
45 OVERRIDE; 45 OVERRIDE;
46 virtual void SetMaxVersion(const invalidation::ObjectId& id, 46 virtual void SetMaxVersion(const invalidation::ObjectId& id,
47 int64 max_version) OVERRIDE; 47 int64 max_version) OVERRIDE;
48 virtual void Forget(const syncer::ObjectIdSet& ids) OVERRIDE; 48 virtual void Forget(const syncer::ObjectIdSet& ids) OVERRIDE;
49 // TODO(tim): These are not yet used. Bug 124140. 49 // TODO(tim): These are not yet used. Bug 124140.
50 virtual void SetInvalidationState(const std::string& state) OVERRIDE; 50 virtual void SetInvalidationState(const std::string& state) OVERRIDE;
51 virtual std::string GetInvalidationState() const OVERRIDE; 51 virtual std::string GetInvalidationState() const OVERRIDE;
52 virtual void GenerateAckHandles(const syncer::ObjectIdSet& ids,
53 syncer::AckHandleMap* ack_handles) OVERRIDE;
54 virtual void Acknowledge(const invalidation::ObjectId& id,
55 const syncer::AckHandle& ack_handle) OVERRIDE;
56
52 57
53 private: 58 private:
54 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap); 59 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap);
55 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 60 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
56 DeserializeFromListOutOfRange); 61 DeserializeFromListOutOfRange);
57 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 62 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
58 DeserializeFromListInvalidFormat); 63 DeserializeFromListInvalidFormat);
59 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 64 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
60 DeserializeFromListWithDuplicates); 65 DeserializeFromListWithDuplicates);
61 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 66 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
62 DeserializeFromEmptyList); 67 DeserializeFromEmptyList);
63 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeFromListBasic); 68 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeFromListBasic);
64 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapOutOfRange); 69 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapOutOfRange);
65 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapInvalidFormat); 70 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapInvalidFormat);
66 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 71 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
67 DeserializeMapEmptyDictionary); 72 DeserializeMapEmptyDictionary);
68 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapBasic); 73 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapBasic);
69 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, MigrateLegacyPreferences); 74 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, MigrateLegacyPreferences);
70 75
71 base::ThreadChecker thread_checker_; 76 base::ThreadChecker thread_checker_;
72 77
73 // Helpers to convert between InvalidationVersionMap <--> ListValue. 78 // Helpers to convert between InvalidationStateMap <--> ListValue.
74 static void DeserializeFromList( 79 static void DeserializeFromList(
75 const base::ListValue& max_versions_list, 80 const base::ListValue& state_map_list,
76 syncer::InvalidationVersionMap* max_versions_map); 81 syncer::InvalidationStateMap* state_map);
77 static void SerializeToList( 82 static void SerializeToList(
78 const syncer::InvalidationVersionMap& max_versions_map, 83 const syncer::InvalidationStateMap& state_map,
79 base::ListValue* max_versions_list); 84 base::ListValue* state_map_list);
80 85
81 // Code for migrating from old MaxInvalidationVersions pref, which was a map 86 // Code for migrating from old MaxInvalidationVersions pref, which was a map
82 // from sync types to max invalidation versions. 87 // from sync types to max invalidation versions.
83 void MigrateMaxInvalidationVersionsPref(); 88 void MigrateMaxInvalidationVersionsPref();
84 static void DeserializeMap(const base::DictionaryValue* max_versions_dict, 89 static void DeserializeMap(const base::DictionaryValue* max_versions_dict,
85 syncer::InvalidationVersionMap* map); 90 syncer::InvalidationStateMap* map);
86 91
87 // May be NULL. 92 // May be NULL.
88 PrefService* const pref_service_; 93 PrefService* const pref_service_;
89 94
90 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); 95 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage);
91 }; 96 };
92 97
93 } // namespace browser_sync 98 } // namespace browser_sync
94 99
95 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ 100 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698