Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: components/rappor/sample.h

Issue 1090683003: Alternative Multi-dimensional Rappor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use 64-bit shift Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/rappor/reports.cc ('k') | components/rappor/sample.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/basictypes.h"
12 #include "base/macros.h"
13 #include "components/rappor/rappor_parameters.h"
14
15 namespace rappor {
16
17 class RapporReports;
18 class RapporService;
19 class TestSamplerFactory;
20
21 // Sample is a container for information about a single instance of some event
22 // we are sending Rappor data about. It may contain multiple different fields,
23 // which describe different details of the event, and they will be sent in the
24 // same Rappor report, enabling analysis of correlations between those fields.
25 class Sample {
26 public:
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 friend class TestSamplerFactory;
48 friend class RapporService;
49
50 // Constructs a sample. Instead of calling this directly, call
51 // RapporService::MakeSampleObj to create a sample.
52 Sample(int32_t cohort_seed, const RapporParameters& parameters);
53
54 const RapporParameters parameters_;
55
56 // Offset used for bloom filter hash functions.
57 uint32_t bloom_offset_;
58
59 // Size of each of the different fields, in bytes.
60 std::map<std::string, size_t> sizes_;
61
62 // The non-randomized report values for each field.
63 std::map<std::string, uint64_t> fields_;
64
65 DISALLOW_COPY_AND_ASSIGN(Sample);
66 };
67
68 } // namespace rappor
69
70 #endif // COMPONENTS_RAPPOR_SAMPLE_H_
OLDNEW
« no previous file with comments | « components/rappor/reports.cc ('k') | components/rappor/sample.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698