Chromium Code Reviews| 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_RAPPOR_RAPPOR_PARAMETERS_H_ | 5 #ifndef COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_ |
| 6 #define COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_ | 6 #define COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 namespace rappor { | 10 namespace rappor { |
| 11 | 11 |
| 12 // Levels of noise added to a sample. | 12 // Levels of noise added to a sample. |
| 13 enum NoiseLevel { | 13 enum NoiseLevel { |
| 14 NO_NOISE = 0, | 14 NO_NOISE = 0, |
| 15 NORMAL_NOISE, | 15 NORMAL_NOISE, |
| 16 SPARSE_NOISE, | |
| 16 NUM_NOISE_LEVELS, | 17 NUM_NOISE_LEVELS, |
| 17 }; | 18 }; |
| 18 | 19 |
| 19 // The type of data stored in a metric. | 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. | |
| 20 enum RapporType { | 23 enum RapporType { |
| 21 // Generic metrics from UMA opt-in users. | 24 // Generic metrics from UMA opt-in users. |
| 22 UMA_RAPPOR_TYPE = 0, | 25 UMA_RAPPOR_TYPE = 0, |
| 23 // Generic metrics for SafeBrowsing users. | 26 // Generic metrics for SafeBrowsing users. |
| 24 SAFEBROWSING_RAPPOR_TYPE, | 27 SAFEBROWSING_RAPPOR_TYPE, |
|
Nathan Parker
2016/04/28 20:43:44
Can you mark this one as deprecated in the comment
dominickn
2016/04/29 07:14:45
Done.
| |
| 25 // Deprecated: Use UMA_RAPPOR_TYPE for new metrics | 28 // Deprecated: Use UMA_RAPPOR_TYPE for new metrics |
| 26 ETLD_PLUS_ONE_RAPPOR_TYPE, | 29 ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 30 // Type for low-frequency metrics from UMA opt-in users. | |
| 31 LOW_FREQUENCY_UMA_RAPPOR_TYPE, | |
| 32 // Type for low-frequency metrics from SafeBrowsing users. | |
| 33 LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE, | |
| 34 // Type for low-frequency metrics from UMA opt-in users. Do not use for new | |
| 35 // metrics. | |
| 36 LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE, | |
| 27 NUM_RAPPOR_TYPES, | 37 NUM_RAPPOR_TYPES, |
| 28 COARSE_RAPPOR_TYPE = SAFEBROWSING_RAPPOR_TYPE, | 38 COARSE_RAPPOR_TYPE = SAFEBROWSING_RAPPOR_TYPE, |
| 29 }; | 39 }; |
| 30 | 40 |
| 31 enum Probability { | 41 enum Probability { |
| 32 PROBABILITY_100, // 100% | 42 PROBABILITY_100, // 100% |
| 33 PROBABILITY_75, // 75% | 43 PROBABILITY_75, // 75% |
| 34 PROBABILITY_50, // 50% | 44 PROBABILITY_50, // 50% |
| 35 PROBABILITY_25, // 25% | 45 PROBABILITY_25, // 25% |
| 36 PROBABILITY_0, // 0% | 46 PROBABILITY_0, // 0% |
| 37 }; | 47 }; |
| 38 | 48 |
| 39 | 49 |
| 40 // A metric is reported when its reporting group is in the set of groups | 50 // A metric is reported when its reporting group is in the set of groups |
| 41 // passed in to RapporService::Start() | 51 // passed in to RapporService::Start() |
| 42 enum RecordingGroup { | 52 enum RecordingGroup { |
| 43 // Metrics for UMA users. | 53 // Metrics for UMA users. |
| 44 UMA_RAPPOR_GROUP = 1 << 0, | 54 UMA_RAPPOR_GROUP = 1 << 0, |
| 45 // Metrics related to SafeBrowsing, for SafeBrowsing users. | 55 // Metrics related to SafeBrowsing, for SafeBrowsing users. |
| 46 SAFEBROWSING_RAPPOR_GROUP = 1 << 1, | 56 SAFEBROWSING_RAPPOR_GROUP = 1 << 1, |
| 47 }; | 57 }; |
| 48 | 58 |
| 49 | 59 |
| 50 // An object describing noise probabilities for a noise level | 60 // An object describing noise probabilities for a noise level |
| 51 struct NoiseParameters { | 61 struct NoiseParameters { |
| 52 // The probability that a bit will be redacted with fake data. | 62 // The probability that a bit will be redacted with fake data. This |
| 63 // corresponds to the F privacy parameter. | |
| 53 Probability fake_prob; | 64 Probability fake_prob; |
| 54 // The probability that a fake bit will be a one. | 65 // The probability that a fake bit will be a one. |
| 55 Probability fake_one_prob; | 66 Probability fake_one_prob; |
| 56 // The probability that a one bit in the redacted data reports as one. | 67 // The probability that a one bit in the redacted data reports as one. This |
| 68 // corresponds to the Q privacy parameter | |
| 57 Probability one_coin_prob; | 69 Probability one_coin_prob; |
| 58 // The probability that a zero bit in the redacted data reports as one. | 70 // The probability that a zero bit in the redacted data reports as one. This |
| 71 // corresponds to the P privacy parameter. | |
| 59 Probability zero_coin_prob; | 72 Probability zero_coin_prob; |
| 60 }; | 73 }; |
| 61 | 74 |
| 62 // An object describing a rappor metric and the parameters used to generate it. | 75 // An object describing a rappor metric and the parameters used to generate it. |
| 63 // | 76 // |
| 64 // For a full description of the rappor metrics, see | 77 // For a full description of the rappor metrics, see |
| 65 // http://www.chromium.org/developers/design-documents/rappor | 78 // http://www.chromium.org/developers/design-documents/rappor |
| 66 struct RapporParameters { | 79 struct RapporParameters { |
| 67 // Get a string representing the parameters, for DCHECK_EQ. | 80 // Get a string representing the parameters, for DCHECK_EQ. |
| 68 std::string ToString() const; | 81 std::string ToString() const; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 97 rappor::PROBABILITY_100 /* One coin probability */, | 110 rappor::PROBABILITY_100 /* One coin probability */, |
| 98 rappor::PROBABILITY_0 /* Zero coin probability */, | 111 rappor::PROBABILITY_0 /* Zero coin probability */, |
| 99 }, | 112 }, |
| 100 // NORMAL_NOISE | 113 // NORMAL_NOISE |
| 101 { | 114 { |
| 102 rappor::PROBABILITY_50 /* Fake data probability */, | 115 rappor::PROBABILITY_50 /* Fake data probability */, |
| 103 rappor::PROBABILITY_50 /* Fake one probability */, | 116 rappor::PROBABILITY_50 /* Fake one probability */, |
| 104 rappor::PROBABILITY_75 /* One coin probability */, | 117 rappor::PROBABILITY_75 /* One coin probability */, |
| 105 rappor::PROBABILITY_25 /* Zero coin probability */, | 118 rappor::PROBABILITY_25 /* Zero coin probability */, |
| 106 }, | 119 }, |
| 120 // SPARSE_NOISE | |
| 121 { | |
| 122 rappor::PROBABILITY_25 /* Fake data probability */, | |
| 123 rappor::PROBABILITY_50 /* Fake one probability */, | |
| 124 rappor::PROBABILITY_75 /* One coin probability */, | |
| 125 rappor::PROBABILITY_25 /* Zero coin probability */, | |
| 126 }, | |
| 107 }; | 127 }; |
| 108 | 128 |
| 109 const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { | 129 const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { |
| 110 // UMA_RAPPOR_TYPE | 130 // UMA_RAPPOR_TYPE |
| 111 {128 /* Num cohorts */, | 131 {128 /* Num cohorts */, |
| 112 4 /* Bloom filter size bytes */, | 132 4 /* Bloom filter size bytes */, |
| 113 2 /* Bloom filter hash count */, | 133 2 /* Bloom filter hash count */, |
| 114 rappor::NORMAL_NOISE /* Noise level */, | 134 rappor::NORMAL_NOISE /* Noise level */, |
| 115 UMA_RAPPOR_GROUP /* Recording group */}, | 135 UMA_RAPPOR_GROUP /* Recording group */}, |
| 116 // SAFEBROWSING_RAPPOR_TYPE | 136 // SAFEBROWSING_RAPPOR_TYPE |
| 117 {128 /* Num cohorts */, | 137 {128 /* Num cohorts */, |
| 118 1 /* Bloom filter size bytes */, | 138 1 /* Bloom filter size bytes */, |
| 119 2 /* Bloom filter hash count */, | 139 2 /* Bloom filter hash count */, |
| 120 rappor::NORMAL_NOISE /* Noise level */, | 140 rappor::NORMAL_NOISE /* Noise level */, |
| 121 SAFEBROWSING_RAPPOR_GROUP /* Recording group */}, | 141 SAFEBROWSING_RAPPOR_GROUP /* Recording group */}, |
| 122 // ETLD_PLUS_ONE_RAPPOR_TYPE | 142 // ETLD_PLUS_ONE_RAPPOR_TYPE |
| 123 {128 /* Num cohorts */, | 143 {128 /* Num cohorts */, |
| 124 16 /* Bloom filter size bytes */, | 144 16 /* Bloom filter size bytes */, |
| 125 2 /* Bloom filter hash count */, | 145 2 /* Bloom filter hash count */, |
| 126 rappor::NORMAL_NOISE /* Noise level */, | 146 rappor::NORMAL_NOISE /* Noise level */, |
| 127 UMA_RAPPOR_GROUP /* Recording group */}, | 147 UMA_RAPPOR_GROUP /* Recording group */}, |
| 148 // LOW_FREQUENCY_UMA_RAPPOR_TYPE | |
| 149 {128 /* Num cohorts */, | |
| 150 4 /* Bloom filter size bytes */, | |
| 151 2 /* Bloom filter hash count */, | |
| 152 rappor::SPARSE_NOISE /* Noise level */, | |
| 153 UMA_RAPPOR_GROUP /* Recording group */}, | |
| 154 // LOW_FREQUENCY_SAFEBROWSING_RAPPOR_TYPE | |
| 155 {128 /* Num cohorts */, | |
| 156 1 /* Bloom filter size bytes */, | |
| 157 2 /* Bloom filter hash count */, | |
| 158 rappor::SPARSE_NOISE /* Noise level */, | |
| 159 SAFEBROWSING_RAPPOR_GROUP /* Recording group */}, | |
| 160 // LOW_FREQUENCY_ETLD_PLUS_ONE_RAPPOR_TYPE | |
| 161 {128 /* Num cohorts */, | |
| 162 16 /* Bloom filter size bytes */, | |
| 163 2 /* Bloom filter hash count */, | |
| 164 rappor::SPARSE_NOISE /* Noise level */, | |
| 165 UMA_RAPPOR_GROUP /* Recording group */}, | |
| 128 }; | 166 }; |
| 129 | 167 |
| 130 } // namespace internal | 168 } // namespace internal |
| 131 | 169 |
| 132 } // namespace rappor | 170 } // namespace rappor |
| 133 | 171 |
| 134 #endif // COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_ | 172 #endif // COMPONENTS_RAPPOR_RAPPOR_PARAMETERS_H_ |
| OLD | NEW |