| 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 15 matching lines...) Expand all Loading... |
| 26 namespace browser_sync { | 26 namespace browser_sync { |
| 27 | 27 |
| 28 // TODO(tim): Bug 124137. We may want to move this outside of sync/ into a | 28 // TODO(tim): Bug 124137. We may want to move this outside of sync/ into a |
| 29 // browser/invalidations directory, or re-organize to have a browser | 29 // browser/invalidations directory, or re-organize to have a browser |
| 30 // subdirectory that contains signin/ sync/ invalidations/ and other cloud | 30 // subdirectory that contains signin/ sync/ invalidations/ and other cloud |
| 31 // services. For now this is still tied to sync while we refactor, so minimize | 31 // services. For now this is still tied to sync while we refactor, so minimize |
| 32 // churn and keep it here. | 32 // churn and keep it here. |
| 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); |
| 37 |
| 36 // |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 |
| 37 // methods should be called. Does not own |pref_service|. | 39 // methods should be called. Does not own |pref_service|. |
| 38 explicit InvalidatorStorage(PrefService* pref_service, | 40 explicit InvalidatorStorage(PrefService* pref_service); |
| 39 PrefRegistrySyncable* registry); | |
| 40 virtual ~InvalidatorStorage(); | 41 virtual ~InvalidatorStorage(); |
| 41 | 42 |
| 42 // Erases invalidation versions and state stored on disk. | 43 // Erases invalidation versions and state stored on disk. |
| 43 void Clear(); | 44 void Clear(); |
| 44 | 45 |
| 45 // InvalidationStateTracker implementation. | 46 // InvalidationStateTracker implementation. |
| 46 virtual syncer::InvalidationStateMap GetAllInvalidationStates() const | 47 virtual syncer::InvalidationStateMap GetAllInvalidationStates() const |
| 47 OVERRIDE; | 48 OVERRIDE; |
| 48 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id, | 49 virtual void SetMaxVersionAndPayload(const invalidation::ObjectId& id, |
| 49 int64 max_version, | 50 int64 max_version, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Helpers to convert between InvalidationStateMap <--> ListValue. | 86 // Helpers to convert between InvalidationStateMap <--> ListValue. |
| 86 static void DeserializeFromList( | 87 static void DeserializeFromList( |
| 87 const base::ListValue& state_map_list, | 88 const base::ListValue& state_map_list, |
| 88 syncer::InvalidationStateMap* state_map); | 89 syncer::InvalidationStateMap* state_map); |
| 89 static void SerializeToList( | 90 static void SerializeToList( |
| 90 const syncer::InvalidationStateMap& state_map, | 91 const syncer::InvalidationStateMap& state_map, |
| 91 base::ListValue* state_map_list); | 92 base::ListValue* state_map_list); |
| 92 | 93 |
| 93 // Code for migrating from old MaxInvalidationVersions pref, which was a map | 94 // Code for migrating from old MaxInvalidationVersions pref, which was a map |
| 94 // from sync types to max invalidation versions. | 95 // from sync types to max invalidation versions. |
| 95 void MigrateMaxInvalidationVersionsPref(PrefRegistrySyncable* registry); | 96 void MigrateMaxInvalidationVersionsPref(); |
| 96 static void DeserializeMap(const base::DictionaryValue* max_versions_dict, | 97 static void DeserializeMap(const base::DictionaryValue* max_versions_dict, |
| 97 syncer::InvalidationStateMap* map); | 98 syncer::InvalidationStateMap* map); |
| 98 | 99 |
| 99 // May be NULL. | 100 // May be NULL. |
| 100 PrefService* const pref_service_; | 101 PrefService* const pref_service_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); | 103 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 } // namespace browser_sync | 106 } // namespace browser_sync |
| 106 | 107 |
| 107 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ | 108 #endif // CHROME_BROWSER_SYNC_INVALIDATIONS_INVALIDATOR_STORAGE_H_ |
| OLD | NEW |