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

Side by Side Diff: components/rappor/bytevector.cc

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "components/rappor/bytevector.h"
7
8 namespace rappor {
9
10 ByteVector::ByteVector(size_t bytes_size) : std::vector<uint8_t>(bytes_size) {}
11
12 ByteVector::ByteVector(const std::vector<uint8_t>& v)
13 : std::vector<uint8_t>(v) {}
14
15 ByteVector::ByteVector(const char* bytes, int size)
16 : std::vector<uint8_t>(bytes, bytes + size) {}
17
18 ByteVector ByteVector::And(ByteVector rhs) const {
19 DCHECK_EQ(size(), rhs.size());
20 ByteVector output(*this);
21 for (size_t i = 0, len = rhs.size(); i < len; i++) {
22 output[i] = output[i] & rhs[i];
23 }
24 return output;
25 }
26
27 ByteVector ByteVector::Or(ByteVector rhs) const {
28 DCHECK_EQ(size(), rhs.size());
29 ByteVector output(*this);
30 for (size_t i = 0, len = rhs.size(); i < len; i++) {
31 output[i] = output[i] | rhs[i];
32 }
33 return output;
34 }
35
36 ByteVector ByteVector::Not() const {
37 ByteVector output(size());
38 for (size_t i = 0, len = size(); i < len; i++) {
39 output[i] = ~at(i);
40 }
41 return output;
42 }
43
44 } // namespace rappor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698