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

Unified Diff: components/ntp_snippets/user_classifier.cc

Issue 2395123002: Connecting UserClassifier to NtpSnippetsFetcher (Closed)
Patch Set: Unit-test fix Created 4 years, 2 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.cc
diff --git a/components/ntp_snippets/user_classifier.cc b/components/ntp_snippets/user_classifier.cc
index a9122343a1ee3e2977c2416e02121463455b04e1..d25cb2256a1d36bc822d2529f99bf62738eee321 100644
--- a/components/ntp_snippets/user_classifier.cc
+++ b/components/ntp_snippets/user_classifier.cc
@@ -267,6 +267,10 @@ double UserClassifier::GetEstimatedAvgTime(Metric metric) const {
}
UserClassifier::UserClass UserClassifier::GetUserClass() const {
+ // The pref_service_ can be null in tests.
+ if (!pref_service_)
+ return UserClass::ACTIVE_NTP_USER;
+
if (GetEstimatedAvgTime(Metric::NTP_OPENED) >=
rare_user_opens_ntp_at_most_once_per_hours_) {
return UserClass::RARE_NTP_USER;

Powered by Google App Engine
This is Rietveld 408576698