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

Side by Side Diff: components/rappor/rappor_parameters.h

Issue 2510803003: Pass RapporService to content/browser/ (Closed)
Patch Set: Fix an Android compile error Created 4 years 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
(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_RAPPOR_RAPPOR_PARAMETERS_H_
6 #define COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_
7
8 #include <string>
9
10 namespace rappor {
11
12 // Levels of noise added to a sample.
13 enum NoiseLevel {
14 NO_NOISE = 0,
15 NORMAL_NOISE,
16 SPARSE_NOISE,
17 NUM_NOISE_LEVELS,
18 };
19
20 // The type of data stored in a metric.
21 // Any use of the LOW_FREQUENCY types must be approved by Chrome Privacy and
22 // the rappor-dev team.
23 enum RapporType {
24 // Generic metrics from UMA opt-in users.
25 UMA_RAPPOR_TYPE = 0,
26 // Generic metrics for SafeBrowsing users. Deprecated, replaced by
27 // LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE.
28 SAFEBROWSING_RAPPOR_TYPE,
29 // Deprecated: Use UMA_RAPPOR_TYPE for new metrics
30 ETLD_PLUS_ONE_RAPPOR_TYPE,
31 // Type for low-frequency metrics from UMA opt-in users.
32 LOW_FREQUENCY_UMA_RAPPOR_TYPE,
33 // Type for low-frequency metrics from SafeBrowsing users.
34 LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE,
35 // Type for low-frequency metrics from UMA opt-in users. Do not use for new
36 // metrics.
37 LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE,
38 NUM_RAPPOR_TYPES,
39 COARSE_RAPPOR_TYPE = SAFEBROWSING_RAPPOR_TYPE,
40 };
41
42 enum Probability {
43 PROBABILITY_100, // 100%
44 PROBABILITY_75, // 75%
45 PROBABILITY_50, // 50%
46 PROBABILITY_25, // 25%
47 PROBABILITY_0, // 0%
48 };
49
50
51 // A metric is reported when its reporting group is in the set of groups
52 // passed in to RapporService::Start()
53 enum RecordingGroup {
54 // Metrics for UMA users.
55 UMA_RAPPOR_GROUP = 1 << 0,
56 // Metrics related to SafeBrowsing, for SafeBrowsing users.
57 SAFEBROWSING_RAPPOR_GROUP = 1 << 1,
58 };
59
60
61 // An object describing noise probabilities for a noise level
62 struct NoiseParameters {
63 // The probability that a bit will be redacted with fake data. This
64 // corresponds to the F privacy parameter.
65 Probability fake_prob;
66 // The probability that a fake bit will be a one.
67 Probability fake_one_prob;
68 // The probability that a one bit in the redacted data reports as one. This
69 // corresponds to the Q privacy parameter
70 Probability one_coin_prob;
71 // The probability that a zero bit in the redacted data reports as one. This
72 // corresponds to the P privacy parameter.
73 Probability zero_coin_prob;
74 };
75
76 // An object describing a rappor metric and the parameters used to generate it.
77 //
78 // For a full description of the rappor metrics, see
79 // http://www.chromium.org/developers/design-documents/rappor
80 struct RapporParameters {
81 // Get a string representing the parameters, for DCHECK_EQ.
82 std::string ToString() const;
83
84 // The maximum number of cohorts we divide clients into.
85 static const int kMaxCohorts;
86
87 // The number of cohorts to divide the reports for this metric into.
88 // This should divide kMaxCohorts evenly so that each cohort has an equal
89 // probability of being assigned users.
90 int num_cohorts;
91
92 // The number of bytes stored in the Bloom filter.
93 size_t bloom_filter_size_bytes;
94 // The number of hash functions used in the Bloom filter.
95 int bloom_filter_hash_function_count;
96
97 // The level of noise to use.
98 NoiseLevel noise_level;
99
100 // The reporting level this metric is reported at.
101 RecordingGroup recording_group;
102 };
103
104 namespace internal {
105
106 const NoiseParameters kNoiseParametersForLevel[NUM_NOISE_LEVELS] = {
107 // NO_NOISE
108 {
109 rappor::PROBABILITY_0 /* Fake data probability */,
110 rappor::PROBABILITY_0 /* Fake one probability */,
111 rappor::PROBABILITY_100 /* One coin probability */,
112 rappor::PROBABILITY_0 /* Zero coin probability */,
113 },
114 // NORMAL_NOISE
115 {
116 rappor::PROBABILITY_50 /* Fake data probability */,
117 rappor::PROBABILITY_50 /* Fake one probability */,
118 rappor::PROBABILITY_75 /* One coin probability */,
119 rappor::PROBABILITY_25 /* Zero coin probability */,
120 },
121 // SPARSE_NOISE
122 {
123 rappor::PROBABILITY_25 /* Fake data probability */,
124 rappor::PROBABILITY_50 /* Fake one probability */,
125 rappor::PROBABILITY_75 /* One coin probability */,
126 rappor::PROBABILITY_25 /* Zero coin probability */,
127 },
128 };
129
130 const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = {
131 // UMA_RAPPOR_TYPE
132 {128 /* Num cohorts */,
133 4 /* Bloom filter size bytes */,
134 2 /* Bloom filter hash count */,
135 rappor::NORMAL_NOISE /* Noise level */,
136 UMA_RAPPOR_GROUP /* Recording group */},
137 // SAFEBROWSING_RAPPOR_TYPE
138 {128 /* Num cohorts */,
139 1 /* Bloom filter size bytes */,
140 2 /* Bloom filter hash count */,
141 rappor::NORMAL_NOISE /* Noise level */,
142 SAFEBROWSING_RAPPOR_GROUP /* Recording group */},
143 // ETLD_PLUS_ONE_RAPPOR_TYPE
144 {128 /* Num cohorts */,
145 16 /* Bloom filter size bytes */,
146 2 /* Bloom filter hash count */,
147 rappor::NORMAL_NOISE /* Noise level */,
148 UMA_RAPPOR_GROUP /* Recording group */},
149 // LOW_FREQUENCY_UMA_RAPPOR_TYPE
150 {128 /* Num cohorts */,
151 4 /* Bloom filter size bytes */,
152 2 /* Bloom filter hash count */,
153 rappor::SPARSE_NOISE /* Noise level */,
154 UMA_RAPPOR_GROUP /* Recording group */},
155 // LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE
156 {128 /* Num cohorts */,
157 1 /* Bloom filter size bytes */,
158 2 /* Bloom filter hash count */,
159 rappor::SPARSE_NOISE /* Noise level */,
160 SAFEBROWSING_RAPPOR_GROUP /* Recording group */},
161 // LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE
162 {128 /* Num cohorts */,
163 16 /* Bloom filter size bytes */,
164 2 /* Bloom filter hash count */,
165 rappor::SPARSE_NOISE /* Noise level */,
166 UMA_RAPPOR_GROUP /* Recording group */},
167 };
168
169 } // namespace internal
170
171 } // namespace rappor
172
173 #endif // COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698