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_ |