| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // Wraps PrefService in an InvalidationStateTracker to allow SyncNotifiers | |
| 6 // to use PrefService as persistence for invalidation state. It is not thread | |
| 7 // safe, and lives on the UI thread. | |
| 8 | |
| 9 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATOR_STORAGE_H_ | |
| 10 #define CHROME_BROWSER_INVALIDATION_INVALIDATOR_STORAGE_H_ | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/gtest_prod_util.h" | |
| 14 #include "base/threading/thread_checker.h" | |
| 15 #include "sync/notifier/invalidation_state_tracker.h" | |
| 16 #include "sync/notifier/unacked_invalidation_set.h" | |
| 17 | |
| 18 class PrefService; | |
| 19 | |
| 20 namespace base { | |
| 21 class DictionaryValue; | |
| 22 class ListValue; | |
| 23 } | |
| 24 | |
| 25 namespace user_prefs { | |
| 26 class PrefRegistrySyncable; | |
| 27 } | |
| 28 | |
| 29 namespace invalidation { | |
| 30 | |
| 31 class InvalidatorStorage : public syncer::InvalidationStateTracker { | |
| 32 public: | |
| 33 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
| 34 | |
| 35 // |pref_service| may not be NULL. Does not own |pref_service|. | |
| 36 explicit InvalidatorStorage(PrefService* pref_service); | |
| 37 virtual ~InvalidatorStorage(); | |
| 38 | |
| 39 // InvalidationStateTracker implementation. | |
| 40 virtual void ClearAndSetNewClientId(const std::string& client_id) OVERRIDE; | |
| 41 virtual std::string GetInvalidatorClientId() const OVERRIDE; | |
| 42 virtual void SetBootstrapData(const std::string& data) OVERRIDE; | |
| 43 virtual std::string GetBootstrapData() const OVERRIDE; | |
| 44 virtual void SetSavedInvalidations( | |
| 45 const syncer::UnackedInvalidationsMap& map) OVERRIDE; | |
| 46 virtual syncer::UnackedInvalidationsMap GetSavedInvalidations() | |
| 47 const OVERRIDE; | |
| 48 virtual void Clear() OVERRIDE; | |
| 49 | |
| 50 private: | |
| 51 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, SerializeEmptyMap); | |
| 52 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | |
| 53 DeserializeFromListOutOfRange); | |
| 54 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | |
| 55 DeserializeFromListInvalidFormat); | |
| 56 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | |
| 57 DeserializeFromListWithDuplicates); | |
| 58 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | |
| 59 DeserializeFromEmptyList); | |
| 60 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeFromListBasic); | |
| 61 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | |
| 62 DeserializeFromListMissingOptionalValues); | |
| 63 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapOutOfRange); | |
| 64 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapInvalidFormat); | |
| 65 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, | |
| 66 DeserializeMapEmptyDictionary); | |
| 67 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, DeserializeMapBasic); | |
| 68 FRIEND_TEST_ALL_PREFIXES(InvalidatorStorageTest, MigrateLegacyPreferences); | |
| 69 | |
| 70 base::ThreadChecker thread_checker_; | |
| 71 | |
| 72 PrefService* const pref_service_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); | |
| 75 }; | |
| 76 | |
| 77 } // namespace invalidation | |
| 78 | |
| 79 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATOR_STORAGE_H_ | |
| OLD | NEW |