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

Unified Diff: components/rappor/rappor_service.h

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/rappor_service.h
diff --git a/components/rappor/rappor_service.h b/components/rappor/rappor_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..b16ea25a76a1c37410f742114ff123d7bd6e68dd
--- /dev/null
+++ b/components/rappor/rappor_service.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2013 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_SERVICE_H_
+#define COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/lazy_instance.h"
+#include "base/memory/weak_ptr.h"
+#include "base/prefs/pref_service.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "components/rappor/log_uploader.h"
+#include "components/rappor/proto/rappor_metric.pb.h"
+
+class PrefRegistrySimple;
+
+namespace rappor {
+
+// This class provides base functionality for logging rappor data.
+class RapporService {
+ public:
+ RapporService();
+ virtual ~RapporService();
+
+ // Starts the rappord system. Should be called when starting up.
+ void Start(PrefService* pref_service, net::URLRequestContextGetter* context);
+
+ // At startup, prefs needs to be called with a list of all the pref names and
+ // types we'll be using.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ private:
+ friend class RapporServiceTest;
+
+ // Client side secret used to generate fake bits.
+ std::string rappor_secret_;
Alexei Svitkine (slow) 2013/12/19 19:47:02 Nit: Variables should be below functions.
Steven Holte 2013/12/20 03:03:55 Done.
+
+ RapporMetricsProto rappor_metrics_proto_;
+
+ // Timer which schedules calls OnLogInterval()
+ base::OneShotTimer<RapporService> log_rotation_timer_;
+
+ LogUploader uploader_;
+
+ // Generates a rappor_secret and stores it in preferences. If already stored,
+ // just retreives the stored value.
+ void GenerateRapporSecret(PrefService* pref_service);
+
+ // Records a single Rappor value to the rappor_metrics_proto_.
+ void RecordRapporMetric(const std::string& metric_name,
+ const std::vector<uint8_t> bytes);
+
+ // Records all of the collected Rappor metrics to the rappor_metric_proto_.
+ void RecordRapporMetrics();
+
+ // Called whenever the logging interval elapses.
+ void OnLogInterval();
+
+ DISALLOW_COPY_AND_ASSIGN(RapporService);
+};
+
+} // namespace rappor
+
+#endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698