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

Unified Diff: components/rappor/rappor_service.cc

Issue 1090683003: Alternative Multi-dimensional Rappor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: components/rappor/rappor_service.cc
diff --git a/components/rappor/rappor_service.cc b/components/rappor/rappor_service.cc
index 7fc4fce7fb4e86f94b330d1e6a94df7927960137..98e532f7f34a1c37390394ad654309cad03e6d3b 100644
--- a/components/rappor/rappor_service.cc
+++ b/components/rappor/rappor_service.cc
@@ -52,6 +52,7 @@ const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = {
{128 /* Num cohorts */,
16 /* Bloom filter size bytes */,
2 /* Bloom filter hash count */,
+ 0 /* Flag bytes */,
rappor::PROBABILITY_50 /* Fake data probability */,
rappor::PROBABILITY_50 /* Fake one probability */,
rappor::PROBABILITY_75 /* One coin probability */,
@@ -61,6 +62,7 @@ const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = {
{128 /* Num cohorts */,
1 /* Bloom filter size bytes */,
2 /* Bloom filter hash count */,
+ 0 /* Flag bytes */,
rappor::PROBABILITY_50 /* Fake data probability */,
rappor::PROBABILITY_50 /* Fake one probability */,
rappor::PROBABILITY_75 /* One coin probability */,
@@ -259,4 +261,27 @@ RapporMetric* RapporService::LookUpMetric(const std::string& metric_name,
return new_metric;
}
+scoped_ptr<Sample> RapporService::MakeSampleObj(RapporType type) {
+ DCHECK(IsInitialized());
+ return scoped_ptr<Sample>(
+ new Sample(cohort_, kRapporParametersForType[type]));
+}
+
+void RapporService::RecordSampleObj(const std::string& metric_name,
+ scoped_ptr<Sample> sample) {
+ if (is_incognito_callback_.Run()) {
+ DVLOG(2) << "Metric not logged due to incognito mode.";
+ return;
+ }
+ // Skip this metric if it's reporting level is less than the enabled
+ // reporting level.
+ if (recording_level_ < sample->parameters().recording_level) {
+ DVLOG(2) << "Metric not logged due to recording_level "
+ << recording_level_ << " < "
+ << sample->parameters().recording_level;
+ return;
+ }
+ sampler_.AddSample(metric_name, sample.Pass());
+}
+
} // namespace rappor

Powered by Google App Engine
This is Rietveld 408576698