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

Unified Diff: components/ntp_snippets/user_classifier.h

Issue 2315273002: Measure usage metrics to prepare for adaptive fetching rates in M55 (Closed)
Patch Set: Created 4 years, 3 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/ntp_snippets/user_classifier.h
diff --git a/components/ntp_snippets/user_classifier.h b/components/ntp_snippets/user_classifier.h
new file mode 100644
index 0000000000000000000000000000000000000000..e85f51ce8207f1604ffd8a0a4298247b20fa9084
--- /dev/null
+++ b/components/ntp_snippets/user_classifier.h
@@ -0,0 +1,50 @@
+// Copyright 2016 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_NTP_SNIPPETS_USER_CLASSIFIER_H_
+#define COMPONENTS_NTP_SNIPPETS_USER_CLASSIFIER_H_
+
+class PrefRegistrySimple;
+class PrefService;
+
+namespace ntp_snippets {
+
+// Collects data about user usage patterns of content suggestions, computes
+// long-term user metrics locally using pref, reports the metrics to UMA,
+// classifies the users into discrete categories based on the metrics, and makes
+// the metrics and the classification available to other parts of the component.
+// TODO(jkrcal): Add the classification and the getters.
Marc Treib 2016/09/07 13:23:48 nit: IMO the comment above should say only what th
jkrcal 2016/09/07 14:19:08 Done.
+class UserClassifier {
+ public:
+ // The provided |pref_service| may be nullptr in unit-tests.
+ explicit UserClassifier(PrefService* pref_service);
+ ~UserClassifier();
+
+ // Registers profile prefs for all metrics. Called from browser_prefs.cc.
+ static void RegisterProfilePrefs(PrefRegistrySimple* registry);
+
+ // When the user opens a new NTP - this indicates potential use of content
+ // suggestions.
+ void OnNTPOpened();
+ // When the content suggestions are shown to the user - in the current
Bernhard Bauer 2016/09/07 13:46:45 Add empty lines before comment blocks?
jkrcal 2016/09/07 14:19:08 Done.
+ // implementation when the user scrolls below the fold.
+ void OnSuggestionsShown();
+ // When the user clicks on some suggestions or on some "More" button.
+ void OnSuggestionsUsed();
+
+ private:
+ double UpdateMetric(const char* metric_pref_name,
+ const char* last_time_pref_name,
+ double default_metric_value);
+
+ double GetHoursSinceLastTime(const char* last_time_pref_name,
+ double default_hours_since_last_time);
+ void SetLastTimeToNow(const char* last_time_pref_name);
+
+ PrefService* pref_service_;
Bernhard Bauer 2016/09/07 13:46:45 DISALLOW_COPY_AND_ASSIGN
jkrcal 2016/09/07 14:19:08 Done.
+};
+
+} // namespace ntp_snippets
+
+#endif // COMPONENTS_NTP_SNIPPETS_USER_CLASSIFIER_H_

Powered by Google App Engine
This is Rietveld 408576698