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