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

Unified Diff: components/rappor/bloom_filter.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/rappor/bloom_filter.h ('k') | components/rappor/bloom_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/rappor/bloom_filter.cc
diff --git a/components/rappor/bloom_filter.cc b/components/rappor/bloom_filter.cc
index d3f9e6339328714bc301237173e4f93baee96fee..9ad8f3ca0ce9d68191e8896229dbf3d44c2e1fcc 100644
--- a/components/rappor/bloom_filter.cc
+++ b/components/rappor/bloom_filter.cc
@@ -20,7 +20,10 @@ BloomFilter::BloomFilter(uint32_t bytes_size,
BloomFilter::~BloomFilter() {}
-void BloomFilter::AddString(const std::string& str) {
+void BloomFilter::SetString(const std::string& str) {
+ for (size_t i = 0; i < bytes_.size(); ++i) {
+ bytes_[i] = 0;
+ }
for (size_t i = 0; i < hash_function_count_; ++i) {
// Using CityHash here because we have support for it in Dremel. Many hash
// functions, such as MD5, SHA1, or Murmur, would probably also work.
@@ -33,4 +36,11 @@ void BloomFilter::AddString(const std::string& str) {
}
}
+void BloomFilter::SetBytesForTesting(const ByteVector& bytes) {
+ DCHECK_EQ(bytes_.size(), bytes.size());
+ for (size_t i = 0; i < bytes_.size(); ++i) {
+ bytes_[i] = bytes[i];
+ }
+}
+
} // namespace rappor
« no previous file with comments | « components/rappor/bloom_filter.h ('k') | components/rappor/bloom_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698