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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_NTP_SNIPPETS_USER_CLASSIFIER_H_
6 #define COMPONENTS_NTP_SNIPPETS_USER_CLASSIFIER_H_
7
8 class PrefRegistrySimple;
9 class PrefService;
10
11 namespace ntp_snippets {
12
13 // Collects data about user usage patterns of content suggestions, computes
14 // long-term user metrics locally using pref, reports the metrics to UMA,
15 // classifies the users into discrete categories based on the metrics, and makes
16 // the metrics and the classification available to other parts of the component.
17 // 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.
18 class UserClassifier {
19 public:
20 // The provided |pref_service| may be nullptr in unit-tests.
21 explicit UserClassifier(PrefService* pref_service);
22 ~UserClassifier();
23
24 // Registers profile prefs for all metrics. Called from browser_prefs.cc.
25 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
26
27 // When the user opens a new NTP - this indicates potential use of content
28 // suggestions.
29 void OnNTPOpened();
30 // 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.
31 // implementation when the user scrolls below the fold.
32 void OnSuggestionsShown();
33 // When the user clicks on some suggestions or on some "More" button.
34 void OnSuggestionsUsed();
35
36 private:
37 double UpdateMetric(const char* metric_pref_name,
38 const char* last_time_pref_name,
39 double default_metric_value);
40
41 double GetHoursSinceLastTime(const char* last_time_pref_name,
42 double default_hours_since_last_time);
43 void SetLastTimeToNow(const char* last_time_pref_name);
44
45 PrefService* pref_service_;
Bernhard Bauer 2016/09/07 13:46:45 DISALLOW_COPY_AND_ASSIGN
jkrcal 2016/09/07 14:19:08 Done.
46 };
47
48 } // namespace ntp_snippets
49
50 #endif // COMPONENTS_NTP_SNIPPETS_USER_CLASSIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698