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

Side by Side Diff: components/rappor/rappor_service.cc

Issue 1476633003: Move HashMetricName to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed unittest Created 5 years 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 unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/metrics/profiler/profiler_metrics_provider_unittest.cc ('k') | components/rappor/rappor_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698