Chromium Code Reviews| Index: components/rappor/byte_vector_utils.cc |
| diff --git a/components/rappor/byte_vector_utils.cc b/components/rappor/byte_vector_utils.cc |
| index 69abcd4dffd8e3c8cfb55061c8aa2cc58c61cedf..02120cc2fd4b30659bf127d3f55bf73d840d3c83 100644 |
| --- a/components/rappor/byte_vector_utils.cc |
| +++ b/components/rappor/byte_vector_utils.cc |
| @@ -78,6 +78,17 @@ bool HMAC_DRBG_Update(const std::string& provided_data, |
| } // namespace |
| +void Uint64ToByteVector(uint64_t value, uint64_t size, ByteVector* output) { |
| + DCHECK_LE(size, 8u); |
| + DCHECK_EQ(size, output->size()); |
| + for (size_t i = 0; i < size; i++) { |
| + // Get the value of the i-th smallest byte and copy it to the byte vector. |
| + uint64_t shift = i * 8; |
|
brucedawson
2015/04/29 18:21:51
Why is shift a uint64_t? The legal values are from
|
| + uint64_t byte_mask = uint64_t(0xff) << shift; |
|
Alexei Svitkine (slow)
2015/04/29 15:01:07
Our style guide prefers static_cast<uint64_t>().
Steven Holte
2015/04/29 18:18:56
Done.
|
| + (*output)[i] = (value & byte_mask) >> shift; |
| + } |
| +} |
| + |
| ByteVector* ByteVectorAnd(const ByteVector& lhs, ByteVector* rhs) { |
| DCHECK_EQ(lhs.size(), rhs->size()); |
| for (size_t i = 0; i < lhs.size(); ++i) { |