Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: components/variations/caching_permuted_entropy_provider.h

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h>
9 #include <stdint.h>
10
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
10 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
11 #include "components/variations/entropy_provider.h" 14 #include "components/variations/entropy_provider.h"
12 #include "components/variations/proto/permuted_entropy_cache.pb.h" 15 #include "components/variations/proto/permuted_entropy_cache.pb.h"
13 16
14 class PrefService; 17 class PrefService;
15 class PrefRegistrySimple; 18 class PrefRegistrySimple;
16 19
17 namespace metrics { 20 namespace metrics {
18 21
19 // CachingPermutedEntropyProvider is an entropy provider that uses the same 22 // CachingPermutedEntropyProvider is an entropy provider that uses the same
20 // algorithm as the PermutedEntropyProvider, but caches the results in Local 23 // algorithm as the PermutedEntropyProvider, but caches the results in Local
21 // State between runs. 24 // State between runs.
22 class CachingPermutedEntropyProvider : public PermutedEntropyProvider { 25 class CachingPermutedEntropyProvider : public PermutedEntropyProvider {
23 public: 26 public:
24 // Creates a CachingPermutedEntropyProvider using the given |local_state| 27 // Creates a CachingPermutedEntropyProvider using the given |local_state|
25 // prefs service with the specified |low_entropy_source|, which should have a 28 // prefs service with the specified |low_entropy_source|, which should have a
26 // value in the range of [0, low_entropy_source_max). 29 // value in the range of [0, low_entropy_source_max).
27 CachingPermutedEntropyProvider(PrefService* local_state, 30 CachingPermutedEntropyProvider(PrefService* local_state,
28 uint16 low_entropy_source, 31 uint16_t low_entropy_source,
29 size_t low_entropy_source_max); 32 size_t low_entropy_source_max);
30 ~CachingPermutedEntropyProvider() override; 33 ~CachingPermutedEntropyProvider() override;
31 34
32 // Registers pref keys used by this class in the Local State pref registry. 35 // Registers pref keys used by this class in the Local State pref registry.
33 static void RegisterPrefs(PrefRegistrySimple* registry); 36 static void RegisterPrefs(PrefRegistrySimple* registry);
34 37
35 // Clears the cache in local state. Should be called when the low entropy 38 // Clears the cache in local state. Should be called when the low entropy
36 // source value gets reset. 39 // source value gets reset.
37 static void ClearCache(PrefService* local_state); 40 static void ClearCache(PrefService* local_state);
38 41
39 private: 42 private:
40 // PermutedEntropyProvider overrides: 43 // PermutedEntropyProvider overrides:
41 uint16 GetPermutedValue(uint32 randomization_seed) const override; 44 uint16_t GetPermutedValue(uint32_t randomization_seed) const override;
42 45
43 // Reads the cache from local state. 46 // Reads the cache from local state.
44 void ReadFromLocalState() const; 47 void ReadFromLocalState() const;
45 48
46 // Updates local state with the state of the cache. 49 // Updates local state with the state of the cache.
47 void UpdateLocalState() const; 50 void UpdateLocalState() const;
48 51
49 // Adds |randomization_seed| -> |value| to the cache. 52 // Adds |randomization_seed| -> |value| to the cache.
50 void AddToCache(uint32 randomization_seed, uint16 value) const; 53 void AddToCache(uint32_t randomization_seed, uint16_t value) const;
51 54
52 // Finds the value corresponding to |randomization_seed|, setting |value| and 55 // Finds the value corresponding to |randomization_seed|, setting |value| and
53 // returning true if found. 56 // returning true if found.
54 bool FindValue(uint32 randomization_seed, uint16* value) const; 57 bool FindValue(uint32_t randomization_seed, uint16_t* value) const;
55 58
56 base::ThreadChecker thread_checker_; 59 base::ThreadChecker thread_checker_;
57 PrefService* local_state_; 60 PrefService* local_state_;
58 mutable PermutedEntropyCache cache_; 61 mutable PermutedEntropyCache cache_;
59 62
60 DISALLOW_COPY_AND_ASSIGN(CachingPermutedEntropyProvider); 63 DISALLOW_COPY_AND_ASSIGN(CachingPermutedEntropyProvider);
61 }; 64 };
62 65
63 } // namespace metrics 66 } // namespace metrics
64 67
65 #endif // COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_ 68 #endif // COMPONENTS_VARIATIONS_CACHING_PERMUTED_ENTROPY_PROVIDER_H_
OLDNEW
« no previous file with comments | « components/variations/android/variations_seed_bridge.cc ('k') | components/variations/caching_permuted_entropy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698