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

Unified Diff: components/rappor/rappor_service.cc

Issue 1014543003: Add an IPC method for Blink to call RapporService::RecordSample() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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.cc
diff --git a/components/rappor/rappor_service.cc b/components/rappor/rappor_service.cc
index 7fc4fce7fb4e86f94b330d1e6a94df7927960137..9f1a2d1dd3bf918920d56825752ed4e72874efdc 100644
--- a/components/rappor/rappor_service.cc
+++ b/components/rappor/rappor_service.cc
@@ -5,6 +5,7 @@
#include "components/rappor/rappor_service.h"
#include "base/metrics/field_trial.h"
+#include "base/metrics/user_metrics.h"
#include "base/stl_util.h"
#include "base/time/time.h"
#include "components/metrics/metrics_hashes.h"
@@ -105,6 +106,8 @@ void RapporService::Initialize(net::URLRequestContextGetter* request_context) {
request_context)),
internal::LoadCohort(pref_service_),
internal::LoadSecret(pref_service_));
+
+ EnableRecordFromUserMetrics();
}
void RapporService::Update(RecordingLevel recording_level, bool may_upload) {
@@ -183,6 +186,18 @@ void RapporService::OnLogInterval() {
ScheduleNextLogRotation(base::TimeDelta::FromSeconds(kLogIntervalSeconds));
}
+void RapporService::EnableRecordFromUserMetrics() {
+ user_metrics_callback_ = base::Bind(&RapporService::OnUserMetricsCallback,
+ base::Unretained(this));
+ base::AddRapporCallback(user_metrics_callback_);
+}
+
+void RapporService::OnUserMetricsCallback(
+ const std::string& metric,
+ const std::string& sample) {
+ RecordSample(metric, COARSE_RAPPOR_TYPE, sample);
Steven Holte 2015/03/23 20:34:06 This should probably be ETLD_PLUS_ONE type or just
+}
+
bool RapporService::ExportMetrics(RapporReports* reports) {
if (metrics_map_.empty()) {
DVLOG(2) << "metrics_map_ is empty.";

Powered by Google App Engine
This is Rietveld 408576698