Index: components/rappor/rappor_service.cc |
diff --git a/components/rappor/rappor_service.cc b/components/rappor/rappor_service.cc |
index 493e7b9d2ccafbf716306181c05f47df680c83bb..38d75a0aba4a8202f1369a0e58bc08747e1f6cf4 100644 |
--- a/components/rappor/rappor_service.cc |
+++ b/components/rappor/rappor_service.cc |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+// Change for readability |
+ |
#include "components/rappor/rappor_service.h" |
#include "base/base64.h" |
@@ -42,13 +44,13 @@ GURL GetServerUrl() { |
} |
const RapporParameters kRapporParametersForType[NUM_RAPPOR_TYPES] = { |
- { // ETLD_PLUS_ONE_RAPPOR_TYPE |
- 16 /* Bloom filter size bytes */, |
- 2 /* Bloom filter hash count */, |
- rappor::PROBABILITY_75 /* Fake data probability */, |
- rappor::PROBABILITY_50 /* Fake one probability */, |
- rappor::PROBABILITY_75 /* One coin probability */, |
- rappor::PROBABILITY_50 /* Zero coin probability */ |
+ {// ETLD_PLUS_ONE_RAPPOR_TYPE |
+ 16 /* Bloom filter size bytes */, |
+ 2 /* Bloom filter hash count */, |
+ rappor::PROBABILITY_75 /* Fake data probability */, |
+ rappor::PROBABILITY_50 /* Fake one probability */, |
+ rappor::PROBABILITY_75 /* One coin probability */, |
+ rappor::PROBABILITY_50 /* Zero coin probability */ |
}, |
}; |
@@ -98,11 +100,14 @@ void RapporService::RegisterPrefs(PrefRegistrySimple* registry) { |
} |
void RapporService::LoadCohort(PrefService* pref_service) { |
- DCHECK_EQ(cohort_, -1); |
+ DCHECK(!IsInitialized()); |
cohort_ = pref_service->GetInteger(prefs::kRapporCohort); |
+ // If the user is already assigned to a valid cohort, we're done. |
if (cohort_ >= 0 && cohort_ < kNumCohorts) |
return; |
+ // This is the first time the client has started the service (or thier |
ktl
2014/03/18 08:35:01
Spelling: their
Steven Holte
2014/03/19 23:46:55
Done.
|
+ // preferences were corrupted). Randomly assign them to a cohort. |
cohort_ = base::RandGenerator(kNumCohorts); |
pref_service->SetInteger(prefs::kRapporCohort, cohort_); |
} |
@@ -132,7 +137,8 @@ bool RapporService::ExportMetrics(RapporReports* reports) { |
DCHECK_GE(cohort_, 0); |
reports->set_cohort(cohort_); |
- for (std::map<std::string, RapporMetric*>::iterator it = metrics_map_.begin(); |
+ for (std::map<std::string, RapporMetric*>::const_iterator it = |
+ metrics_map_.begin(); |
ktl
2014/03/18 08:35:01
This would need one more space; the four space ind
Steven Holte
2014/03/19 23:46:55
Done.
|
metrics_map_.end() != it; |
ktl
2014/03/18 08:35:01
I've not seen this style (putting the variable ite
Steven Holte
2014/03/19 23:46:55
base/metrics/... seems to use that style in a few
|
++it) { |
const RapporMetric* metric = it->second; |
@@ -163,7 +169,6 @@ void RapporService::RecordSampleInternal(const std::string& metric_name, |
const RapporParameters& parameters, |
const std::string& sample) { |
DCHECK(IsInitialized()); |
- |
RapporMetric* metric = LookUpMetric(metric_name, parameters); |
metric->AddSample(sample); |
} |
@@ -171,7 +176,7 @@ void RapporService::RecordSampleInternal(const std::string& metric_name, |
RapporMetric* RapporService::LookUpMetric(const std::string& metric_name, |
const RapporParameters& parameters) { |
DCHECK(IsInitialized()); |
- std::map<std::string, RapporMetric*>::iterator it = |
+ std::map<std::string, RapporMetric*>::const_iterator it = |
metrics_map_.find(metric_name); |
if (metrics_map_.end() != it) { |
RapporMetric* metric = it->second; |