OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 #ifndef COMPONENTS_INVALIDATION_INVALIDATOR_STORAGE_H_ | |
6 #define COMPONENTS_INVALIDATION_INVALIDATOR_STORAGE_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/macros.h" | |
10 #include "base/threading/thread_checker.h" | |
11 #include "components/invalidation/invalidation_state_tracker.h" | |
12 | |
13 class PrefRegistrySimple; | |
14 class PrefService; | |
15 | |
16 namespace user_prefs { | |
17 class PrefRegistrySyncable; | |
18 } | |
19 | |
20 namespace invalidation { | |
21 | |
22 // Wraps PrefService in an InvalidationStateTracker to allow SyncNotifiers | |
23 // to use PrefService as persistence for invalidation state. It is not thread | |
24 // safe, and lives on the UI thread. | |
25 class InvalidatorStorage : public syncer::InvalidationStateTracker { | |
26 public: | |
27 // |pref_service| may not be NULL and must outlive |this|. | |
28 explicit InvalidatorStorage(PrefService* pref_service); | |
29 ~InvalidatorStorage() override; | |
30 | |
31 // Register prefs to be used by per-Profile instances of this class which | |
32 // store invalidation state in Profile prefs. | |
33 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
34 | |
35 // Register prefs to be used by a device-global instance of this class which | |
36 // stores invalidation state in local state. This is used on Chrome OS only. | |
37 static void RegisterPrefs(PrefRegistrySimple* registry); | |
38 | |
39 // InvalidationStateTracker implementation. | |
40 void ClearAndSetNewClientId(const std::string& client_id) override; | |
41 std::string GetInvalidatorClientId() const override; | |
42 void SetBootstrapData(const std::string& data) override; | |
43 std::string GetBootstrapData() const override; | |
44 void SetSavedInvalidations( | |
45 const syncer::UnackedInvalidationsMap& map) override; | |
46 syncer::UnackedInvalidationsMap GetSavedInvalidations() const override; | |
47 void Clear() override; | |
48 | |
49 private: | |
50 base::ThreadChecker thread_checker_; | |
51 | |
52 PrefService* const pref_service_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(InvalidatorStorage); | |
55 }; | |
56 | |
57 } // namespace invalidation | |
58 | |
59 #endif // COMPONENTS_INVALIDATION_INVALIDATOR_STORAGE_H_ | |
OLD | NEW |