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

Unified Diff: components/rappor/rappor_service.cc

Issue 509203002: Create a mechanism for reporting rappor metrics from non-UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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 6ca64b70f94b8b2cf3e8924d5949d64726bacafa..fe1de4ec424afc732372e3890a85abbc1eae493e 100644
--- a/components/rappor/rappor_service.cc
+++ b/components/rappor/rappor_service.cc
@@ -41,12 +41,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);
@@ -56,6 +51,13 @@ GURL GetServerUrl(bool metrics_enabled) {
return GURL(kDefaultServerUrl);
}
+bool ShouldEnableAllMetrics(bool metrics_enabled) {
+ bool require_uma = variations::GetVariationParamValue(
+ kRapporRolloutFieldTrialName,
+ kRapporRolloutRequireUmaParam) != "False";
jwd 2014/08/29 15:45:47 Super good, awesome choice for the condition!
+ return metrics_enabled || !require_uma;
+}
+
const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = {
// ETLD_PLUS_ONE_RAPPOR_TYPE
{128 /* Num cohorts */,
@@ -64,7 +66,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
+ {64 /* Num cohorts */,
+ 16 /* 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
@@ -78,12 +90,14 @@ RapporService::~RapporService() {
void RapporService::Start(PrefService* pref_service,
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(pref_service);
@@ -188,10 +202,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,
« components/rappor/rappor_parameters.h ('K') | « components/rappor/rappor_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698