OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_SAMPLE_H_ | |
6 #define COMPONENTS_RAPPOR_SAMPLE_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "components/rappor/rappor_parameters.h" | |
13 | |
14 namespace rappor { | |
15 | |
16 class RapporReports; | |
17 class RapporService; | |
18 class TestSamplerFactory; | |
19 | |
20 // Sample is a container for information about a single instance of some event | |
21 // we are sending Rappor data about. It may contain multiple different fields, | |
22 // which describe different details of the event, and they will be sent in the | |
23 // same Rappor report, enabling analysis of correlations between those fields. | |
24 class Sample { | |
25 public: | |
26 ~Sample(); | |
27 | |
28 // Sets a string value field in this sample. | |
29 void SetStringField(const std::string& field_name, const std::string& value); | |
30 | |
31 // Sets a group of boolean flags as a field in this sample. | |
32 // |flags| should be a set of boolean flags stored in the lowest |num_flags| | |
33 // bits of |flags|. | |
34 void SetFlagsField(const std::string& field_name, | |
35 uint64_t flags, | |
36 size_t num_flags); | |
37 | |
38 // Generate randomized reports and store them in |reports|. | |
39 void ExportMetrics(const std::string& secret, | |
40 const std::string& metric_name, | |
41 RapporReports* reports) const; | |
42 | |
43 const RapporParameters& parameters() { return parameters_; } | |
44 | |
45 private: | |
46 friend class TestSamplerFactory; | |
47 friend class RapporService; | |
48 | |
49 // Constructs a sample. Instead of calling this directly, call | |
50 // RapporService::MakeSampleObj to create a sample. | |
51 Sample(int32_t cohort_seed, const RapporParameters& parameters); | |
Alexei Svitkine (slow)
2015/04/24 18:10:01
Nit: Add an empty line after this.
Steven Holte
2015/04/24 18:39:57
Done.
| |
52 const RapporParameters parameters_; | |
53 | |
54 // Offset used for bloom filter hash functions. | |
55 uint32_t bloom_offset_; | |
56 | |
57 // Size of each of the different fields, in bytes. | |
58 std::map<std::string, size_t> sizes_; | |
59 | |
60 // The non-randomized report values for each field. | |
61 std::map<std::string, uint64_t> fields_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(Sample); | |
64 }; | |
65 | |
66 } // namespace rappor | |
67 | |
68 #endif // COMPONENTS_RAPPOR_SAMPLE_H_ | |
OLD | NEW |