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

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: Further polish 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 #include "base/macros.h"
9
10 class PrefRegistrySimple;
11 class PrefService;
12
13 namespace ntp_snippets {
14
15 // Collects data about user usage patterns of content suggestions, computes
16 // long-term user metrics locally using pref, and reports the metrics to UMA.
17 // TODO(jkrcal): Add classification of users based on the metrics and getters
18 // for the classification as well as for the metrics.
19 class UserClassifier {
20 public:
21 // The provided |pref_service| may be nullptr in unit-tests.
22 explicit UserClassifier(PrefService* pref_service);
23 ~UserClassifier();
24
25 // Registers profile prefs for all metrics. Called from browser_prefs.cc.
26 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
27
28 // When the user opens a new NTP - this indicates potential use of content
29 // suggestions.
30 void OnNTPOpened();
31
32 // When the content suggestions are shown to the user - in the current
33 // implementation when the user scrolls below the fold.
34 void OnSuggestionsShown();
35
36 // When the user clicks on some suggestions or on some "More" button.
37 void OnSuggestionsUsed();
38
39 private:
40 // The event has happened, recompute and store the metric accordingly.
41 void UpdateMetricOnEvent(const char* metric_pref_name,
42 const char* last_time_pref_name);
43
44 // Compute the number of hours between two events for the given metric value
45 // assuming the events were equally distributed.
46 double GetEstimateHoursBetweenEvents(const char* metric_pref_name);
47
48 // Returns the number of hours since the last event of the same type or
49 // DBL_MAX if there is no last event of that type.
50 double GetHoursSinceLastTime(const char* last_time_pref_name);
51 void SetLastTimeToNow(const char* last_time_pref_name);
52
53 PrefService* pref_service_;
54 double discount_rate_per_hour_;
Bernhard Bauer 2016/09/07 21:31:00 const
jkrcal 2016/09/08 05:45:24 Done.
55
56 DISALLOW_COPY_AND_ASSIGN(UserClassifier);
57 };
58
59 } // namespace ntp_snippets
60
61 #endif // COMPONENTS_NTP_SNIPPETS_USER_CLASSIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698