Index: components/rappor/rappor_service.cc |
diff --git a/components/rappor/rappor_service.cc b/components/rappor/rappor_service.cc |
index 11419f5baaf583af9995ba352ec41b326d73a041..ca9dd4f8501cf32b90228a6c30e6e197af4e01b8 100644 |
--- a/components/rappor/rappor_service.cc |
+++ b/components/rappor/rappor_service.cc |
@@ -43,12 +43,7 @@ const char kRapporRolloutRequireUmaParam[] = "RequireUma"; |
// The rappor server's URL. |
const char kDefaultServerUrl[] = "https://clients4.google.com/rappor"; |
-GURL GetServerUrl(bool metrics_enabled) { |
- bool require_uma = variations::GetVariationParamValue( |
- kRapporRolloutFieldTrialName, |
- kRapporRolloutRequireUmaParam) != "False"; |
- if (!metrics_enabled && require_uma) |
- return GURL(); // Invalid URL disables Rappor. |
+GURL GetServerUrl() { |
std::string server_url = variations::GetVariationParamValue( |
kRapporRolloutFieldTrialName, |
kRapporRolloutServerUrlParam); |
@@ -58,6 +53,13 @@ GURL GetServerUrl(bool metrics_enabled) { |
return GURL(kDefaultServerUrl); |
} |
+bool ShouldEnableAllMetrics(bool metrics_enabled) { |
+ bool require_uma = variations::GetVariationParamValue( |
+ kRapporRolloutFieldTrialName, |
+ kRapporRolloutRequireUmaParam) != "False"; |
+ return metrics_enabled || !require_uma; |
+} |
+ |
const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { |
// ETLD_PLUS_ONE_RAPPOR_TYPE |
{128 /* Num cohorts */, |
@@ -66,7 +68,17 @@ const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { |
rappor::PROBABILITY_50 /* Fake data probability */, |
rappor::PROBABILITY_50 /* Fake one probability */, |
rappor::PROBABILITY_75 /* One coin probability */, |
- rappor::PROBABILITY_25 /* Zero coin probability */}, |
+ rappor::PROBABILITY_25 /* Zero coin probability */, |
+ false /* Require UMA */}, |
+ // SAFE_BROWSING_PATTERN_RAPPOR_TYPE |
+ {128 /* Num cohorts */, |
+ 1 /* Bloom filter size bytes */, |
+ 2 /* Bloom filter hash count */, |
+ rappor::PROBABILITY_50 /* Fake data probability */, |
+ rappor::PROBABILITY_50 /* Fake one probability */, |
+ rappor::PROBABILITY_75 /* One coin probability */, |
+ rappor::PROBABILITY_25 /* Zero coin probability */, |
+ true /* Don't require UMA */}, |
}; |
} // namespace |
@@ -90,12 +102,14 @@ void RapporService::AddDailyObserver( |
void RapporService::Start(net::URLRequestContextGetter* request_context, |
bool metrics_enabled) { |
- const GURL server_url = GetServerUrl(metrics_enabled); |
+ const GURL server_url = GetServerUrl(); |
if (!server_url.is_valid()) { |
DVLOG(1) << server_url.spec() << " is invalid. " |
<< "RapporService not started."; |
return; |
} |
+ all_metrics_enabled_ = ShouldEnableAllMetrics(metrics_enabled); |
+ DVLOG(1) << "RapporService all_metrics_enabled_? " << all_metrics_enabled_; |
DVLOG(1) << "RapporService started. Reporting to " << server_url.spec(); |
DCHECK(!uploader_); |
LoadSecret(); |
@@ -203,10 +217,15 @@ void RapporService::RecordSample(const std::string& metric_name, |
if (!IsInitialized()) |
return; |
DCHECK_LT(type, NUM_RAPPOR_TYPES); |
+ const RapporParameters& parameters = kRapporParametersForType[type]; |
+ // Skip this metric if all metrics aren't enabled and this isn't a |
+ // whitelisted metric. |
+ if (!all_metrics_enabled_ && !parameters.always_enabled) |
+ return; |
DVLOG(2) << "Recording sample \"" << sample |
<< "\" for metric \"" << metric_name |
<< "\" of type: " << type; |
- RecordSampleInternal(metric_name, kRapporParametersForType[type], sample); |
+ RecordSampleInternal(metric_name, parameters, sample); |
} |
void RapporService::RecordSampleInternal(const std::string& metric_name, |