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 #include <vector> |
| 10 |
| 11 #include "components/rappor/bloom_filter.h" |
| 12 #include "components/rappor/byte_vector_utils.h" |
| 13 #include "components/rappor/rappor_parameters.h" |
| 14 |
| 15 namespace rappor { |
| 16 |
| 17 // A RapporMetric is an object that collects string samples into a Bloom filter, |
| 18 // and generates randomized reports about the collected data. |
| 19 // |
| 20 // For a full description of the rappor metrics, see |
| 21 // http://www.chromium.org/developers/design-documents/rappor |
| 22 class RapporMetric { |
| 23 public: |
| 24 explicit RapporMetric(const RapporParameters& parameters, int32_t cohort); |
| 25 ~RapporMetric(); |
| 26 |
| 27 // Record additional samples in the Bloom filter. |
| 28 void AddSample(const std::string& str); |
| 29 |
| 30 // Retrieves the current Bloom filter bits. |
| 31 const ByteVector& bytes() const { return bloom_.bytes(); } |
| 32 |
| 33 // Gets the parameter values this metric was constructed with. |
| 34 const RapporParameters* parameters() const { return ¶meters_; } |
| 35 |
| 36 // Generates the bits to report for this metric. Using the secret as a seed, |
| 37 // randomly selects bits for redaction. Then flips coins to generate the |
| 38 // final report bits. |
| 39 ByteVector GetReport(const std::string& secret) const; |
| 40 |
| 41 private: |
| 42 const RapporParameters parameters_; |
| 43 BloomFilter bloom_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(RapporMetric); |
| 46 }; |
| 47 |
| 48 } // namespace rappor |
| 49 |
| 50 #endif // COMPONENTS_RAPPOR_RAPPOR_H_ |
OLD | NEW |