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

Side by Side Diff: components/rappor/rappor_metric.h

Issue 188103004: C++ Readability review for holte (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 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 #ifndef COMPONENTS_RAPPOR_RAPPOR_H_ 5 // Change for readability
6 #define COMPONENTS_RAPPOR_RAPPOR_H_ 6
7 #ifndef COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
8 #define COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
7 9
8 #include <string> 10 #include <string>
9 11
12 #include "base/basictypes.h"
13 #include "base/macros.h"
10 #include "components/rappor/bloom_filter.h" 14 #include "components/rappor/bloom_filter.h"
11 #include "components/rappor/byte_vector_utils.h" 15 #include "components/rappor/byte_vector_utils.h"
12 #include "components/rappor/rappor_parameters.h" 16 #include "components/rappor/rappor_parameters.h"
13 17
14 namespace rappor { 18 namespace rappor {
15 19
16 // A RapporMetric is an object that collects string samples into a Bloom filter, 20 // A RapporMetric is an object that collects string samples into a Bloom filter,
17 // and generates randomized reports about the collected data. 21 // and generates randomized reports about the collected data.
18 // 22 //
23 // This class should not be used directly by metrics clients. Record metrics
24 // using RapporService::RecordSample instead.
25 //
19 // For a full description of the rappor metrics, see 26 // For a full description of the rappor metrics, see
20 // http://www.chromium.org/developers/design-documents/rappor 27 // http://www.chromium.org/developers/design-documents/rappor
21 class RapporMetric { 28 class RapporMetric {
22 public: 29 public:
23 // Takes the |metric_name| that this will be reported to the server with, 30 // Takes the |metric_name| that this will be reported to the server with,
24 // a |parameters| describing size and probability weights to be used in 31 // a |parameters| describing size and probability weights used in recording
25 // recording this metric, and cohort value, which modifies the hash 32 // this metric, and a |cohort| value, which determines the hash functions
26 // functions and used in the bloom filter. 33 // used in the Bloom filter.
27 explicit RapporMetric(const std::string& metric_name, 34 RapporMetric(const std::string& metric_name,
28 const RapporParameters& parameters, 35 const RapporParameters& parameters,
29 int32_t cohort); 36 int32_t cohort);
30 ~RapporMetric(); 37 ~RapporMetric();
31 38
32 // Records an additional sample in the Bloom filter. 39 // Records an additional sample in the Bloom filter.
33 void AddSample(const std::string& str); 40 void AddSample(const std::string& str);
34 41
35 // Retrieves the current Bloom filter bits. 42 // Retrieves the current Bloom filter bits.
36 const ByteVector& bytes() const { return bloom_filter_.bytes(); } 43 const ByteVector& bytes() const { return bloom_filter_.bytes(); }
37 44
38 // Gets the parameter values this metric was constructed with. 45 // Gets the parameter values this metric was constructed with.
39 const RapporParameters& parameters() const { return parameters_; } 46 const RapporParameters& parameters() const { return parameters_; }
40 47
41 // Generates the bits to report for this metric. Using the secret as a seed, 48 // Generates the bits to report for this metric. Using the secret as a seed,
42 // randomly selects bits for redaction. Then flips coins to generate the 49 // randomly selects bits for redaction. Then flips coins to generate the
43 // final report bits. 50 // final report bits.
44 ByteVector GetReport(const std::string& secret) const; 51 ByteVector GetReport(const std::string& secret) const;
45 52
46 private: 53 private:
47 const std::string metric_name_; 54 const std::string metric_name_;
48 const RapporParameters parameters_; 55 const RapporParameters parameters_;
49 BloomFilter bloom_filter_; 56 BloomFilter bloom_filter_;
50 57
51 DISALLOW_COPY_AND_ASSIGN(RapporMetric); 58 DISALLOW_COPY_AND_ASSIGN(RapporMetric);
52 }; 59 };
53 60
54 } // namespace rappor 61 } // namespace rappor
55 62
56 #endif // COMPONENTS_RAPPOR_RAPPOR_H_ 63 #endif // COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698