Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_H_ | |
| 6 #define COMPONENTS_RAPPOR_RAPPOR_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "components/rappor/bloom_filter.h" | |
| 11 #include "components/rappor/byte_vector_utils.h" | |
| 12 #include "components/rappor/rappor_parameters.h" | |
| 13 | |
| 14 namespace rappor { | |
| 15 | |
| 16 // A RapporMetric is an object that collects string samples into a Bloom filter, | |
| 17 // and generates randomized reports about the collected data. | |
| 18 // | |
| 19 // For a full description of the rappor metrics, see | |
| 20 // http://www.chromium.org/developers/design-documents/rappor | |
| 21 class RapporMetric { | |
| 22 public: | |
| 23 explicit RapporMetric(const std::string& metric_name, | |
| 24 const RapporParameters& parameters, | |
| 25 int32_t cohort); | |
|
Ilya Sherman
2014/02/13 01:39:03
nit: Please document the parameters, or at least d
Steven Holte
2014/02/13 05:11:12
Done.
| |
| 26 ~RapporMetric(); | |
| 27 | |
| 28 // Record additional samples in the Bloom filter. | |
|
Ilya Sherman
2014/02/13 01:39:03
nit: "Record additional samples" -> "Records an ad
Steven Holte
2014/02/13 05:11:12
Done.
| |
| 29 void AddSample(const std::string& str); | |
| 30 | |
| 31 // Retrieves the current Bloom filter bits. | |
|
Ilya Sherman
2014/02/13 01:39:03
nit: It's a little confusing throughout this CL th
Steven Holte
2014/02/13 05:11:12
Bits are the content, bytes are the format.
| |
| 32 const ByteVector& bytes() const { return bloom_.bytes(); } | |
| 33 | |
| 34 // Gets the parameter values this metric was constructed with. | |
| 35 const RapporParameters& parameters() const { return parameters_; } | |
| 36 | |
| 37 // Generates the bits to report for this metric. Using the secret as a seed, | |
| 38 // randomly selects bits for redaction. Then flips coins to generate the | |
| 39 // final report bits. | |
| 40 ByteVector GetReport(const std::string& secret) const; | |
| 41 | |
| 42 private: | |
| 43 const std::string metric_name_; | |
| 44 const RapporParameters parameters_; | |
| 45 BloomFilter bloom_; | |
|
Ilya Sherman
2014/02/13 01:39:03
nit: IMO "bloom_filter_" is a clearer, more descri
Steven Holte
2014/02/13 05:11:12
Done.
| |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(RapporMetric); | |
| 48 }; | |
| 49 | |
| 50 } // namespace rappor | |
| 51 | |
| 52 #endif // COMPONENTS_RAPPOR_RAPPOR_H_ | |
| OLD | NEW |