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