Index: components/rappor/rappor_service.cc |
diff --git a/components/rappor/rappor_service.cc b/components/rappor/rappor_service.cc |
index 7fc4fce7fb4e86f94b330d1e6a94df7927960137..819d428249884aaf200670ba7f5db8c86767f6eb 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, |
rappor::PROBABILITY_50 /* Fake data probability */, |
rappor::PROBABILITY_50 /* Fake one probability */, |
rappor::PROBABILITY_75 /* One coin probability */, |
@@ -61,6 +62,17 @@ const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { |
{128 /* Num cohorts */, |
1 /* Bloom filter size bytes */, |
2 /* Bloom filter hash count */, |
+ 0, |
+ rappor::PROBABILITY_50 /* Fake data probability */, |
+ rappor::PROBABILITY_50 /* Fake one probability */, |
+ rappor::PROBABILITY_75 /* One coin probability */, |
+ rappor::PROBABILITY_25 /* Zero coin probability */, |
+ COARSE_LEVEL /* Recording level */}, |
+ // STRING_W_FLAGS_SB_RAPPOR_TYPE |
+ {128 /* Num cohorts */, |
+ 1 /* Bloom filter size bytes */, |
+ 2 /* Bloom filter hash count */, |
+ 1, |
rappor::PROBABILITY_50 /* Fake data probability */, |
rappor::PROBABILITY_50 /* Fake one probability */, |
rappor::PROBABILITY_75 /* One coin probability */, |
@@ -212,21 +224,41 @@ bool RapporService::IsInitialized() const { |
void RapporService::RecordSample(const std::string& metric_name, |
RapporType type, |
- const std::string& sample) { |
+ const std::string& str) { |
// Ignore the sample if the service hasn't started yet. |
if (!IsInitialized()) |
return; |
DCHECK_LT(type, NUM_RAPPOR_TYPES); |
const RapporParameters& parameters = kRapporParametersForType[type]; |
- DVLOG(2) << "Recording sample \"" << sample |
+ DVLOG(2) << "Recording sample \"" << str |
<< "\" for metric \"" << metric_name |
<< "\" of type: " << type; |
+ Sample sample; |
+ DCHECK_EQ(0, parameters.flag_bytes); |
+ SetSampleBits(parameters, cohort_, str, 0, &sample); |
+ RecordSampleInternal(metric_name, parameters, sample); |
+} |
+ |
+void RapporService::RecordStringAndFlags(const std::string& metric_name, |
+ RapporType type, |
+ const std::string& str, |
+ uint64_t flags) { |
+ // Ignore the sample if the service hasn't started yet. |
+ if (!IsInitialized()) |
+ return; |
+ DCHECK_LT(type, NUM_RAPPOR_TYPES); |
+ const RapporParameters& parameters = kRapporParametersForType[type]; |
+ DVLOG(2) << "Recording sample \"" << str << "\"," << flags |
+ << " for metric \"" << metric_name |
+ << "\" of type: " << type; |
+ Sample sample; |
+ SetSampleBits(parameters, cohort_, str, flags, &sample); |
RecordSampleInternal(metric_name, parameters, sample); |
} |
void RapporService::RecordSampleInternal(const std::string& metric_name, |
const RapporParameters& parameters, |
- const std::string& sample) { |
+ const Sample& sample) { |
DCHECK(IsInitialized()); |
if (is_incognito_callback_.Run()) { |
DVLOG(2) << "Metric not logged due to incognito mode."; |
@@ -254,7 +286,7 @@ RapporMetric* RapporService::LookUpMetric(const std::string& metric_name, |
return metric; |
} |
- RapporMetric* new_metric = new RapporMetric(metric_name, parameters, cohort_); |
+ RapporMetric* new_metric = new RapporMetric(metric_name, parameters); |
metrics_map_[metric_name] = new_metric; |
return new_metric; |
} |