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

Unified Diff: base/metrics/user_metrics.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: Changed to ETLD_PLUS_ONE 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: base/metrics/user_metrics.cc
diff --git a/base/metrics/user_metrics.cc b/base/metrics/user_metrics.cc
index 9db5840ab57052746537bb223a8f6445735d53d9..ee02893f19e2edd4de3c588ba7b0a526360721ea 100644
--- a/base/metrics/user_metrics.cc
+++ b/base/metrics/user_metrics.cc
@@ -25,6 +25,12 @@ class Callbacks {
}
}
+ void Record(const std::string& metric, const std::string& sample) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!rappor_callback_.is_null())
+ rappor_callback_.Run(metric, sample);
+ }
+
// Adds |callback| to the list of |callbacks_|.
void AddCallback(const ActionCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -43,9 +49,16 @@ class Callbacks {
}
}
+ void AddCallback(const RapporCallback& callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(rappor_callback_.is_null());
+ rappor_callback_ = callback;
+ }
+
private:
base::ThreadChecker thread_checker_;
std::vector<ActionCallback> callbacks_;
+ RapporCallback rappor_callback_;
DISALLOW_COPY_AND_ASSIGN(Callbacks);
};
@@ -62,13 +75,20 @@ void RecordComputedAction(const std::string& action) {
g_callbacks.Get().Record(action);
}
+void RecordRappor(const std::string& metric, const std::string& sample) {
+ g_callbacks.Get().Record(metric, sample);
+}
+
void AddActionCallback(const ActionCallback& callback) {
g_callbacks.Get().AddCallback(callback);
}
void RemoveActionCallback(const ActionCallback& callback) {
g_callbacks.Get().RemoveCallback(callback);
+}
+void AddRapporCallback(const RapporCallback& callback) {
+ g_callbacks.Get().AddCallback(callback);
}
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698