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

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

Issue 419683014: Randomly select a single rappor sample when more than one is collected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « components/rappor/bloom_filter_unittest.cc ('k') | components/rappor/rappor_metric.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_METRIC_H_ 5 #ifndef COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
6 #define COMPONENTS_RAPPOR_RAPPOR_METRIC_H_ 6 #define COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 17 matching lines...) Expand all
28 // Takes the |metric_name| that this will be reported to the server with, 28 // Takes the |metric_name| that this will be reported to the server with,
29 // a |parameters| describing size and probability weights used in recording 29 // a |parameters| describing size and probability weights used in recording
30 // this metric, and a |cohort| value, which determines the hash functions 30 // this metric, and a |cohort| value, which determines the hash functions
31 // used in the Bloom filter. 31 // used in the Bloom filter.
32 RapporMetric(const std::string& metric_name, 32 RapporMetric(const std::string& metric_name,
33 const RapporParameters& parameters, 33 const RapporParameters& parameters,
34 int32_t cohort); 34 int32_t cohort);
35 ~RapporMetric(); 35 ~RapporMetric();
36 36
37 // Records an additional sample in the Bloom filter. 37 // Records an additional sample in the Bloom filter.
38 // A random sample will be used when reporting this metric.
Alexei Svitkine (slow) 2014/08/05 13:22:05 Nit: expand comment to mention "when more than one
Steven Holte 2014/08/05 20:32:32 Done.
38 void AddSample(const std::string& str); 39 void AddSample(const std::string& str);
39 40
40 // Retrieves the current Bloom filter bits. 41 // Retrieves the current Bloom filter bits.
41 const ByteVector& bytes() const { return bloom_filter_.bytes(); } 42 const ByteVector& bytes() const { return bloom_filter_.bytes(); }
42 43
43 // Gets the parameter values this metric was constructed with. 44 // Gets the parameter values this metric was constructed with.
44 const RapporParameters& parameters() const { return parameters_; } 45 const RapporParameters& parameters() const { return parameters_; }
45 46
46 // Generates the bits to report for this metric. Using the secret as a seed, 47 // Generates the bits to report for this metric. Using the secret as a seed,
47 // randomly selects bits for redaction. Then flips coins to generate the 48 // randomly selects bits for redaction. Then flips coins to generate the
48 // final report bits. 49 // final report bits.
49 ByteVector GetReport(const std::string& secret) const; 50 ByteVector GetReport(const std::string& secret) const;
50 51
52 // Specify the bytes to generate a report from, for testing purposes.
53 void SetBytesForTesting(const ByteVector& bytes);
54
51 private: 55 private:
52 const std::string metric_name_; 56 const std::string metric_name_;
53 const RapporParameters parameters_; 57 const RapporParameters parameters_;
58 uint32_t sample_count_;
54 BloomFilter bloom_filter_; 59 BloomFilter bloom_filter_;
55 60
56 DISALLOW_COPY_AND_ASSIGN(RapporMetric); 61 DISALLOW_COPY_AND_ASSIGN(RapporMetric);
57 }; 62 };
58 63
59 } // namespace rappor 64 } // namespace rappor
60 65
61 #endif // COMPONENTS_RAPPOR_RAPPOR_METRIC_H_ 66 #endif // COMPONENTS_RAPPOR_RAPPOR_METRIC_H_
OLDNEW
« no previous file with comments | « components/rappor/bloom_filter_unittest.cc ('k') | components/rappor/rappor_metric.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698