| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/rappor/rappor_service.h" | 5 #include "components/rappor/rappor_service.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/metrics/metrics_hashes.h" |
| 8 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 10 #include "components/metrics/metrics_hashes.h" | |
| 11 #include "components/rappor/log_uploader.h" | 11 #include "components/rappor/log_uploader.h" |
| 12 #include "components/rappor/proto/rappor_metric.pb.h" | 12 #include "components/rappor/proto/rappor_metric.pb.h" |
| 13 #include "components/rappor/rappor_metric.h" | 13 #include "components/rappor/rappor_metric.h" |
| 14 #include "components/rappor/rappor_pref_names.h" | 14 #include "components/rappor/rappor_pref_names.h" |
| 15 #include "components/rappor/rappor_prefs.h" | 15 #include "components/rappor/rappor_prefs.h" |
| 16 #include "components/variations/variations_associated_data.h" | 16 #include "components/variations/variations_associated_data.h" |
| 17 | 17 |
| 18 namespace rappor { | 18 namespace rappor { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool RapporService::ExportMetrics(RapporReports* reports) { | 166 bool RapporService::ExportMetrics(RapporReports* reports) { |
| 167 DCHECK(thread_checker_.CalledOnValidThread()); | 167 DCHECK(thread_checker_.CalledOnValidThread()); |
| 168 DCHECK_GE(cohort_, 0); | 168 DCHECK_GE(cohort_, 0); |
| 169 reports->set_cohort(cohort_); | 169 reports->set_cohort(cohort_); |
| 170 | 170 |
| 171 for (const auto& kv : metrics_map_) { | 171 for (const auto& kv : metrics_map_) { |
| 172 const RapporMetric* metric = kv.second; | 172 const RapporMetric* metric = kv.second; |
| 173 RapporReports::Report* report = reports->add_report(); | 173 RapporReports::Report* report = reports->add_report(); |
| 174 report->set_name_hash(metrics::HashMetricName(kv.first)); | 174 report->set_name_hash(base::HashMetricName(kv.first)); |
| 175 ByteVector bytes = metric->GetReport(secret_); | 175 ByteVector bytes = metric->GetReport(secret_); |
| 176 report->set_bits(std::string(bytes.begin(), bytes.end())); | 176 report->set_bits(std::string(bytes.begin(), bytes.end())); |
| 177 DVLOG(2) << "Exporting metric " << kv.first; | 177 DVLOG(2) << "Exporting metric " << kv.first; |
| 178 } | 178 } |
| 179 STLDeleteValues(&metrics_map_); | 179 STLDeleteValues(&metrics_map_); |
| 180 | 180 |
| 181 sampler_.ExportMetrics(secret_, reports); | 181 sampler_.ExportMetrics(secret_, reports); |
| 182 | 182 |
| 183 DVLOG(2) << "Generated a report with " << reports->report_size() | 183 DVLOG(2) << "Generated a report with " << reports->report_size() |
| 184 << " metrics."; | 184 << " metrics."; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void RapporService::RecordSampleObj(const std::string& metric_name, | 257 void RapporService::RecordSampleObj(const std::string& metric_name, |
| 258 scoped_ptr<Sample> sample) { | 258 scoped_ptr<Sample> sample) { |
| 259 DCHECK(thread_checker_.CalledOnValidThread()); | 259 DCHECK(thread_checker_.CalledOnValidThread()); |
| 260 if (!RecordingAllowed(sample->parameters())) | 260 if (!RecordingAllowed(sample->parameters())) |
| 261 return; | 261 return; |
| 262 DVLOG(1) << "Recording sample of metric \"" << metric_name << "\""; | 262 DVLOG(1) << "Recording sample of metric \"" << metric_name << "\""; |
| 263 sampler_.AddSample(metric_name, sample.Pass()); | 263 sampler_.AddSample(metric_name, sample.Pass()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace rappor | 266 } // namespace rappor |
| OLD | NEW |