Chromium Code Reviews| Index: components/rappor/rappor_metric.h |
| diff --git a/components/rappor/rappor_metric.h b/components/rappor/rappor_metric.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..affe4bd1b4cea90e5bdd4d2069c303fcc951cb91 |
| --- /dev/null |
| +++ b/components/rappor/rappor_metric.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_RAPPOR_RAPPOR_H_ |
| +#define COMPONENTS_RAPPOR_RAPPOR_H_ |
| + |
| +#include <string> |
| + |
| +#include "components/rappor/bloom_filter.h" |
| +#include "components/rappor/byte_vector_utils.h" |
| +#include "components/rappor/rappor_parameters.h" |
| + |
| +namespace rappor { |
| + |
| +// A RapporMetric is an object that collects string samples into a Bloom filter, |
| +// and generates randomized reports about the collected data. |
| +// |
| +// For a full description of the rappor metrics, see |
| +// http://www.chromium.org/developers/design-documents/rappor |
| +class RapporMetric { |
| + public: |
| + explicit RapporMetric(const std::string& metric_name, |
| + const RapporParameters& parameters, |
| + 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.
|
| + ~RapporMetric(); |
| + |
| + // 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.
|
| + void AddSample(const std::string& str); |
| + |
| + // 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.
|
| + const ByteVector& bytes() const { return bloom_.bytes(); } |
| + |
| + // Gets the parameter values this metric was constructed with. |
| + const RapporParameters& parameters() const { return parameters_; } |
| + |
| + // Generates the bits to report for this metric. Using the secret as a seed, |
| + // randomly selects bits for redaction. Then flips coins to generate the |
| + // final report bits. |
| + ByteVector GetReport(const std::string& secret) const; |
| + |
| + private: |
| + const std::string metric_name_; |
| + const RapporParameters parameters_; |
| + 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.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(RapporMetric); |
| +}; |
| + |
| +} // namespace rappor |
| + |
| +#endif // COMPONENTS_RAPPOR_RAPPOR_H_ |