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

Unified Diff: components/rappor/byte_vector_utils.cc

Issue 264123004: Modify rappor parameters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
Index: components/rappor/byte_vector_utils.cc
diff --git a/components/rappor/byte_vector_utils.cc b/components/rappor/byte_vector_utils.cc
index 57f25744566d19056f3b1cd511789f467a773e2a..69abcd4dffd8e3c8cfb55061c8aa2cc58c61cedf 100644
--- a/components/rappor/byte_vector_utils.cc
+++ b/components/rappor/byte_vector_utils.cc
@@ -78,9 +78,17 @@ bool HMAC_DRBG_Update(const std::string& provided_data,
} // namespace
+ByteVector* ByteVectorAnd(const ByteVector& lhs, ByteVector* rhs) {
+ DCHECK_EQ(lhs.size(), rhs->size());
+ for (size_t i = 0; i < lhs.size(); ++i) {
+ (*rhs)[i] = lhs[i] & (*rhs)[i];
+ }
+ return rhs;
+}
+
ByteVector* ByteVectorOr(const ByteVector& lhs, ByteVector* rhs) {
DCHECK_EQ(lhs.size(), rhs->size());
- for (size_t i = 0, len = lhs.size(); i < len; ++i) {
+ for (size_t i = 0; i < lhs.size(); ++i) {
(*rhs)[i] = lhs[i] | (*rhs)[i];
}
return rhs;
@@ -90,7 +98,7 @@ ByteVector* ByteVectorMerge(const ByteVector& mask,
const ByteVector& lhs,
ByteVector* rhs) {
DCHECK_EQ(lhs.size(), rhs->size());
- for (size_t i = 0, len = lhs.size(); i < len; ++i) {
+ for (size_t i = 0; i < lhs.size(); ++i) {
(*rhs)[i] = (lhs[i] & ~mask[i]) | ((*rhs)[i] & mask[i]);
}
return rhs;
@@ -127,6 +135,8 @@ ByteVector ByteVectorGenerator::GetWeightedRandomByteVector(
return *ByteVectorOr(GetRandomByteVector(), &bytes);
case PROBABILITY_50:
return bytes;
+ case PROBABILITY_25:
+ return *ByteVectorAnd(GetRandomByteVector(), &bytes);
}
NOTREACHED();
return bytes;

Powered by Google App Engine
This is Rietveld 408576698