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

Side by Side Diff: components/rappor/sample.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
« no previous file with comments | « components/rappor/rappor_service_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/sample.h" 5 #include "components/rappor/sample.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "components/metrics/metrics_hashes.h" 11 #include "base/metrics/metrics_hashes.h"
12 #include "components/rappor/bloom_filter.h" 12 #include "components/rappor/bloom_filter.h"
13 #include "components/rappor/byte_vector_utils.h" 13 #include "components/rappor/byte_vector_utils.h"
14 #include "components/rappor/proto/rappor_metric.pb.h" 14 #include "components/rappor/proto/rappor_metric.pb.h"
15 #include "components/rappor/reports.h" 15 #include "components/rappor/reports.h"
16 16
17 namespace rappor { 17 namespace rappor {
18 18
19 Sample::Sample(int32_t cohort_seed, const RapporParameters& parameters) 19 Sample::Sample(int32_t cohort_seed, const RapporParameters& parameters)
20 : parameters_(parameters), 20 : parameters_(parameters),
21 bloom_offset_((cohort_seed % parameters_.num_cohorts) * 21 bloom_offset_((cohort_seed % parameters_.num_cohorts) *
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 uint64_t value = kv.second; 60 uint64_t value = kv.second;
61 const auto it = sizes_.find(kv.first); 61 const auto it = sizes_.find(kv.first);
62 DCHECK(it != sizes_.end()); 62 DCHECK(it != sizes_.end());
63 size_t size = it->second; 63 size_t size = it->second;
64 ByteVector value_bytes(size); 64 ByteVector value_bytes(size);
65 Uint64ToByteVector(value, size, &value_bytes); 65 Uint64ToByteVector(value, size, &value_bytes);
66 ByteVector report_bytes = internal::GenerateReport( 66 ByteVector report_bytes = internal::GenerateReport(
67 secret, parameters_, value_bytes); 67 secret, parameters_, value_bytes);
68 68
69 RapporReports::Report* report = reports->add_report(); 69 RapporReports::Report* report = reports->add_report();
70 report->set_name_hash(metrics::HashMetricName( 70 report->set_name_hash(base::HashMetricName(
71 metric_name + "." + kv.first)); 71 metric_name + "." + kv.first));
72 report->set_bits(std::string(report_bytes.begin(), report_bytes.end())); 72 report->set_bits(std::string(report_bytes.begin(), report_bytes.end()));
73 DVLOG(2) << "Exporting sample " << metric_name << "." << kv.first; 73 DVLOG(2) << "Exporting sample " << metric_name << "." << kv.first;
74 } 74 }
75 } 75 }
76 76
77 } // namespace rappor 77 } // namespace rappor
OLDNEW
« no previous file with comments | « components/rappor/rappor_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698