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