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

Unified Diff: components/rappor/rappor_metric.h

Issue 1058333002: Multi-dimension rappor metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and add xml support 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/bloom_filter_unittest.cc ('k') | components/rappor/rappor_metric.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/rappor_metric.h
diff --git a/components/rappor/rappor_metric.h b/components/rappor/rappor_metric.h
index b36252d6c32e31257184c29e3c2222bbe4975758..a9af474b0781e1295e6a667c637b9f2b651e3373 100644
--- a/components/rappor/rappor_metric.h
+++ b/components/rappor/rappor_metric.h
@@ -9,13 +9,24 @@
#include "base/basictypes.h"
#include "base/macros.h"
-#include "components/rappor/bloom_filter.h"
#include "components/rappor/byte_vector_utils.h"
#include "components/rappor/rappor_parameters.h"
namespace rappor {
-// A RapporMetric is an object that collects string samples into a Bloom filter,
+namespace internal {
+
+// Use byte vectors to store samples.
+typedef ByteVector Sample;
+
+// Given a string and flags, pack a bloom filter representing the string
+// and the flags directly into a single sample that supports seperable
+// analysis. |parameters| will determine how many bytes are used for each
+// part of the sample.
+void SetSampleBits(const RapporParameters& parameters, int32_t cohort_seed,
+ const std::string& str, uint64_t flags, Sample* output);
+
+// A RapporMetric is an object that collects samples of a metric
// and generates randomized reports about the collected data.
//
// This class should not be used directly by metrics clients. Record metrics
@@ -27,20 +38,18 @@ class RapporMetric {
public:
// Takes the |metric_name| that this will be reported to the server with,
// a |parameters| describing size and probability weights used in recording
- // this metric, and a |cohort| value, which determines the hash functions
- // used in the Bloom filter.
+ // this metric.
RapporMetric(const std::string& metric_name,
- const RapporParameters& parameters,
- int32_t cohort);
+ const RapporParameters& parameters);
~RapporMetric();
- // Records an additional sample in the Bloom filter.
+ // Records an additional sample.
// A random sample will be used when reporting this metric when more than one
// sample is collected in the same reporting interval.
- void AddSample(const std::string& str);
+ void AddSample(const Sample& str);
- // Retrieves the current Bloom filter bits.
- const ByteVector& bytes() const { return bloom_filter_.bytes(); }
+ // Retrieves the current Sample.
+ const Sample& bytes() const { return sample_; }
// Gets the parameter values this metric was constructed with.
const RapporParameters& parameters() const { return parameters_; }
@@ -50,18 +59,20 @@ class RapporMetric {
// final report bits.
ByteVector GetReport(const std::string& secret) const;
- // Specify the bytes to generate a report from, for testing purposes.
- void SetBytesForTesting(const ByteVector& bytes);
+ // Specify the Sample to generate a report from, for testing purposes.
+ void SetSampleForTesting(const Sample& bytes);
private:
const std::string metric_name_;
const RapporParameters parameters_;
uint32_t sample_count_;
- BloomFilter bloom_filter_;
+ Sample sample_;
DISALLOW_COPY_AND_ASSIGN(RapporMetric);
};
+} // namespace internal
+
} // namespace rappor
#endif // COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
« no previous file with comments | « components/rappor/bloom_filter_unittest.cc ('k') | components/rappor/rappor_metric.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698