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

Unified Diff: components/rappor/rappor_metric.h

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RapporMetric 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/rappor_metric.h
diff --git a/components/rappor/rappor_metric.h b/components/rappor/rappor_metric.h
new file mode 100644
index 0000000000000000000000000000000000000000..23ad4c4da57ba4d2b6c18be80bb4a69c96edaddb
--- /dev/null
+++ b/components/rappor/rappor_metric.h
@@ -0,0 +1,49 @@
+// 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.
+
+#ifndef COMPONENTS_RAPPOR_RAPPOR_H_
+#define COMPONENTS_RAPPOR_RAPPOR_H_
+
+#include <assert.h>
+#include <limits.h>
+#include <math.h>
+
+#include <string>
+#include <vector>
+
+#include "components/rappor/bloom_filter.h"
+#include "components/rappor/rappor_parameters.h"
+#include "components/rappor/byte_vector_utils.h"
+
+namespace rappor {
+
+// A RapporMetric is an object for collects string samples into a bloom filter,
+// and generates randomized reports about the collected data.
+//
+// For a full description of the rappor metrics, see
+// http://www.chromium.org/developers/design-documents/rappor
+class RapporMetric {
+ public:
+ RapporMetric(const RapporParameters* parameters);
Alexei Svitkine (slow) 2013/12/24 16:59:30 Nit: explicit. What's the ownership model for |pa
Steven Holte 2014/01/04 00:12:54 Changed to copy in ctor. On 2013/12/24 16:59:30,
+
+ // Record additional samples in the bloom filter.
+ void AddSamples(const std::vector<std::string>& strings);
+ void AddSample(const std::string& str);
+
+ // Retrieves the current bloom filter bits.
+ const ByteVector& GetBytes() const;
+ const RapporParameters* parameters() const { return parameters_; }
+
+ ByteVector GetReport(const std::string& secret) const;
+
+ private:
+ const RapporParameters* parameters_;
+ BloomFilter bloom_;
+
+ DISALLOW_COPY_AND_ASSIGN(RapporMetric);
+};
+
+} // namespace rappor
+
+#endif // COMPONENTS_RAPPOR_RAPPOR_H_

Powered by Google App Engine
This is Rietveld 408576698