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

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

Issue 497213002: Mark some destructors as virtual. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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_BYTE_VECTOR_UTILS_H_ 5 #ifndef COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_
6 #define COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ 6 #define COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 25 matching lines...) Expand all
36 36
37 // Counts the number of bits set in the byte vector. 37 // Counts the number of bits set in the byte vector.
38 int CountBits(const ByteVector& vector); 38 int CountBits(const ByteVector& vector);
39 39
40 // A utility object for generating random binary data with different 40 // A utility object for generating random binary data with different
41 // likelihood of bits being true, using entropy from crypto::RandBytes(). 41 // likelihood of bits being true, using entropy from crypto::RandBytes().
42 class ByteVectorGenerator { 42 class ByteVectorGenerator {
43 public: 43 public:
44 explicit ByteVectorGenerator(size_t byte_count); 44 explicit ByteVectorGenerator(size_t byte_count);
45 45
46 ~ByteVectorGenerator(); 46 virtual ~ByteVectorGenerator();
47 47
48 // Generates a random byte vector where the bits are independent random 48 // Generates a random byte vector where the bits are independent random
49 // variables which are true with the given |probability|. 49 // variables which are true with the given |probability|.
50 ByteVector GetWeightedRandomByteVector(Probability probability); 50 ByteVector GetWeightedRandomByteVector(Probability probability);
51 51
52 protected: 52 protected:
53 // Size of vectors to be generated. 53 // Size of vectors to be generated.
54 size_t byte_count() const { return byte_count_; } 54 size_t byte_count() const { return byte_count_; }
55 55
56 // Generates a random vector of bytes from a uniform distribution. 56 // Generates a random vector of bytes from a uniform distribution.
(...skipping 16 matching lines...) Expand all
73 // based on a secret seed. 73 // based on a secret seed.
74 class HmacByteVectorGenerator : public ByteVectorGenerator { 74 class HmacByteVectorGenerator : public ByteVectorGenerator {
75 public: 75 public:
76 // Constructor takes the size of the vector to generate, along with a 76 // Constructor takes the size of the vector to generate, along with a
77 // |entropy_input| and |personalization_string| to seed the pseudo-random 77 // |entropy_input| and |personalization_string| to seed the pseudo-random
78 // number generator. The string parameters are treated as byte arrays. 78 // number generator. The string parameters are treated as byte arrays.
79 HmacByteVectorGenerator(size_t byte_count, 79 HmacByteVectorGenerator(size_t byte_count,
80 const std::string& entropy_input, 80 const std::string& entropy_input,
81 const std::string& personalization_string); 81 const std::string& personalization_string);
82 82
83 ~HmacByteVectorGenerator(); 83 virtual ~HmacByteVectorGenerator();
84 84
85 // Generates a random string suitable for passing to the constructor as 85 // Generates a random string suitable for passing to the constructor as
86 // |entropy_input|. 86 // |entropy_input|.
87 static std::string GenerateEntropyInput(); 87 static std::string GenerateEntropyInput();
88 88
89 // Key size required for 128-bit security strength (including nonce). 89 // Key size required for 128-bit security strength (including nonce).
90 static const size_t kEntropyInputSize; 90 static const size_t kEntropyInputSize;
91 91
92 protected: 92 protected:
93 // Generate byte vector generator that streams from the next request instead 93 // Generate byte vector generator that streams from the next request instead
(...skipping 12 matching lines...) Expand all
106 106
107 // Total number of bytes streamed from the HMAC_DRBG Generate Process. 107 // Total number of bytes streamed from the HMAC_DRBG Generate Process.
108 size_t generated_bytes_; 108 size_t generated_bytes_;
109 109
110 DISALLOW_ASSIGN(HmacByteVectorGenerator); 110 DISALLOW_ASSIGN(HmacByteVectorGenerator);
111 }; 111 };
112 112
113 } // namespace rappor 113 } // namespace rappor
114 114
115 #endif // COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_ 115 #endif // COMPONENTS_RAPPOR_BYTE_VECTOR_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698