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_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ | 5 #ifndef COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ |
6 #define COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ | 6 #define COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Registers pref keys used by this class in the Local State pref registry. | 32 // Registers pref keys used by this class in the Local State pref registry. |
33 static void RegisterPrefs(PrefRegistrySimple* registry); | 33 static void RegisterPrefs(PrefRegistrySimple* registry); |
34 | 34 |
35 // Clears the cache in local state. Should be called when the low entropy | 35 // Clears the cache in local state. Should be called when the low entropy |
36 // source value gets reset. | 36 // source value gets reset. |
37 static void ClearCache(PrefService* local_state); | 37 static void ClearCache(PrefService* local_state); |
38 | 38 |
39 private: | 39 private: |
40 // PermutedEntropyProvider overrides: | 40 // PermutedEntropyProvider overrides: |
41 virtual uint16 GetPermutedValue(uint32 randomization_seed) const OVERRIDE; | 41 virtual uint16 GetPermutedValue(uint32 randomization_seed) const override; |
42 | 42 |
43 // Reads the cache from local state. | 43 // Reads the cache from local state. |
44 void ReadFromLocalState() const; | 44 void ReadFromLocalState() const; |
45 | 45 |
46 // Updates local state with the state of the cache. | 46 // Updates local state with the state of the cache. |
47 void UpdateLocalState() const; | 47 void UpdateLocalState() const; |
48 | 48 |
49 // Adds |randomization_seed| -> |value| to the cache. | 49 // Adds |randomization_seed| -> |value| to the cache. |
50 void AddToCache(uint32 randomization_seed, uint16 value) const; | 50 void AddToCache(uint32 randomization_seed, uint16 value) const; |
51 | 51 |
52 // Finds the value corresponding to |randomization_seed|, setting |value| and | 52 // Finds the value corresponding to |randomization_seed|, setting |value| and |
53 // returning true if found. | 53 // returning true if found. |
54 bool FindValue(uint32 randomization_seed, uint16* value) const; | 54 bool FindValue(uint32 randomization_seed, uint16* value) const; |
55 | 55 |
56 base::ThreadChecker thread_checker_; | 56 base::ThreadChecker thread_checker_; |
57 PrefService* local_state_; | 57 PrefService* local_state_; |
58 mutable PermutedEntropyCache cache_; | 58 mutable PermutedEntropyCache cache_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(CachingPermutedEntropyProvider); | 60 DISALLOW_COPY_AND_ASSIGN(CachingPermutedEntropyProvider); |
61 }; | 61 }; |
62 | 62 |
63 } // namespace metrics | 63 } // namespace metrics |
64 | 64 |
65 #endif // COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ | 65 #endif // COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ |
OLD | NEW |