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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/rappor/bytevector.cc
diff --git a/components/rappor/bytevector.cc b/components/rappor/bytevector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..47386a723b4a2aca1b7965a164a8812dc042267b
--- /dev/null
+++ b/components/rappor/bytevector.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "components/rappor/bytevector.h"
+
+namespace rappor {
+
+ByteVector::ByteVector(size_t bytes_size) : std::vector<uint8_t>(bytes_size) {}
+
+ByteVector::ByteVector(const std::vector<uint8_t>& v)
+ : std::vector<uint8_t>(v) {}
+
+ByteVector::ByteVector(const char* bytes, int size)
+ : std::vector<uint8_t>(bytes, bytes + size) {}
+
+ByteVector ByteVector::And(ByteVector rhs) const {
+ DCHECK_EQ(size(), rhs.size());
+ ByteVector output(*this);
+ for (size_t i = 0, len = rhs.size(); i < len; i++) {
+ output[i] = output[i] & rhs[i];
+ }
+ return output;
+}
+
+ByteVector ByteVector::Or(ByteVector rhs) const {
+ DCHECK_EQ(size(), rhs.size());
+ ByteVector output(*this);
+ for (size_t i = 0, len = rhs.size(); i < len; i++) {
+ output[i] = output[i] | rhs[i];
+ }
+ return output;
+}
+
+ByteVector ByteVector::Not() const {
+ ByteVector output(size());
+ for (size_t i = 0, len = size(); i < len; i++) {
+ output[i] = ~at(i);
+ }
+ return output;
+}
+
+} // namespace rappor

Powered by Google App Engine
This is Rietveld 408576698