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

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

Issue 11229015: Add the InvalidationState struct to bundle local state about invalidations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/sync/invalidations/invalidator_storage.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GetAllInvalidationStates() 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 SetBootstrapData(const std::string& data) OVERRIDE; 50 virtual void SetBootstrapData(const std::string& data) OVERRIDE;
51 virtual std::string GetBootstrapData() const OVERRIDE; 51 virtual std::string GetBootstrapData() const OVERRIDE;
52 52
53 private: 53 private:
54 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap); 54 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap);
55 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 55 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
56 DeserializeFromListOutOfRange); 56 DeserializeFromListOutOfRange);
57 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 57 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
58 DeserializeFromListInvalidFormat); 58 DeserializeFromListInvalidFormat);
59 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 59 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
60 DeserializeFromListWithDuplicates); 60 DeserializeFromListWithDuplicates);
61 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 61 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
62 DeserializeFromEmptyList); 62 DeserializeFromEmptyList);
63 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeFromListBasic); 63 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeFromListBasic);
64 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapOutOfRange); 64 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapOutOfRange);
65 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapInvalidFormat); 65 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapInvalidFormat);
66 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, 66 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest,
67 DeserializeMapEmptyDictionary); 67 DeserializeMapEmptyDictionary);
68 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapBasic); 68 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapBasic);
69 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, MigrateLegacyPreferences); 69 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, MigrateLegacyPreferences);
70 70
71 base::ThreadChecker thread_checker_; 71 base::ThreadChecker thread_checker_;
72 72
73 // Helpers to convert between InvalidationVersionMap <--> ListValue. 73 // Helpers to convert between InvalidationStateMap <--> ListValue.
74 static void DeserializeFromList( 74 static void DeserializeFromList(
75 const base::ListValue& max_versions_list, 75 const base::ListValue& state_map_list,
76 syncer::InvalidationVersionMap* max_versions_map); 76 syncer::InvalidationStateMap* state_map);
77 static void SerializeToList( 77 static void SerializeToList(
78 const syncer::InvalidationVersionMap& max_versions_map, 78 const syncer::InvalidationStateMap& state_map,
79 base::ListValue* max_versions_list); 79 base::ListValue* state_map_list);
80 80
81 // Code for migrating from old MaxInvalidationVersions pref, which was a map 81 // Code for migrating from old MaxInvalidationVersions pref, which was a map
82 // from sync types to max invalidation versions. 82 // from sync types to max invalidation versions.
83 void MigrateMaxInvalidationVersionsPref(); 83 void MigrateMaxInvalidationVersionsPref();
84 static void DeserializeMap(const base::DictionaryValue* max_versions_dict, 84 static void DeserializeMap(const base::DictionaryValue* max_versions_dict,
85 syncer::InvalidationVersionMap* map); 85 syncer::InvalidationStateMap* map);
86 86
87 // May be NULL. 87 // May be NULL.
88 PrefService* const pref_service_; 88 PrefService* const pref_service_;
89 89
90 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); 90 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage);
91 }; 91 };
92 92
93 } // namespace browser_sync 93 } // namespace browser_sync
94 94
95 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ 95 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/invalidations/invalidator_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698