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

Unified Diff: components/rappor/bytevector.cc

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BrowserProcess member 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..0edec03f09e86f66796183dfcae49b9572e229d0
--- /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::operator&(ByteVector rhs) const {
+ DCHECK(size() == rhs.size());
jwd 2013/12/16 17:04:03 I would document the size equality restriction in
Steven Holte 2013/12/16 23:02:16 Done.
+ ByteVector output(*this);
+ for (size_t i = 0, len = rhs.size(); i < len; i++) {
+ output[i] = output[i] & rhs[i];
+ }
+ return output;
+}
+
+ByteVector ByteVector::operator|(ByteVector rhs) const {
+ DCHECK(size() == rhs.size());
jwd 2013/12/16 17:04:03 Dito
Steven Holte 2013/12/16 23:02:16 Done.
+ ByteVector output(*this);
+ for (size_t i = 0, len = rhs.size(); i < len; i++) {
+ output[i] = output[i] | rhs[i];
+ }
+ return output;
+}
+
+ByteVector ByteVector::operator~() 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