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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/rappor/reports.cc ('k') | components/rappor/sample.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/sample.h
diff --git a/components/rappor/sample.h b/components/rappor/sample.h
new file mode 100644
index 0000000000000000000000000000000000000000..5eaf1de900da943f8061d738c87b3c0ebf67cba5
--- /dev/null
+++ b/components/rappor/sample.h
@@ -0,0 +1,70 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_RAPPOR_SAMPLE_H_
+#define COMPONENTS_RAPPOR_SAMPLE_H_
+
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/macros.h"
+#include "components/rappor/rappor_parameters.h"
+
+namespace rappor {
+
+class RapporReports;
+class RapporService;
+class TestSamplerFactory;
+
+// Sample is a container for information about a single instance of some event
+// we are sending Rappor data about. It may contain multiple different fields,
+// which describe different details of the event, and they will be sent in the
+// same Rappor report, enabling analysis of correlations between those fields.
+class Sample {
+ public:
+ ~Sample();
+
+ // Sets a string value field in this sample.
+ void SetStringField(const std::string& field_name, const std::string& value);
+
+ // Sets a group of boolean flags as a field in this sample.
+ // |flags| should be a set of boolean flags stored in the lowest |num_flags|
+ // bits of |flags|.
+ void SetFlagsField(const std::string& field_name,
+ uint64_t flags,
+ size_t num_flags);
+
+ // Generate randomized reports and store them in |reports|.
+ void ExportMetrics(const std::string& secret,
+ const std::string& metric_name,
+ RapporReports* reports) const;
+
+ const RapporParameters& parameters() { return parameters_; }
+
+ private:
+ friend class TestSamplerFactory;
+ friend class RapporService;
+
+ // Constructs a sample. Instead of calling this directly, call
+ // RapporService::MakeSampleObj to create a sample.
+ Sample(int32_t cohort_seed, const RapporParameters& parameters);
+
+ const RapporParameters parameters_;
+
+ // Offset used for bloom filter hash functions.
+ uint32_t bloom_offset_;
+
+ // Size of each of the different fields, in bytes.
+ std::map<std::string, size_t> sizes_;
+
+ // The non-randomized report values for each field.
+ std::map<std::string, uint64_t> fields_;
+
+ DISALLOW_COPY_AND_ASSIGN(Sample);
+};
+
+} // namespace rappor
+
+#endif // COMPONENTS_RAPPOR_SAMPLE_H_
« 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