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

Side by Side Diff: components/ntp_snippets/user_classifier.cc

Issue 2395123002: Connecting UserClassifier to NtpSnippetsFetcher (Closed)
Patch Set: A small 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/user_classifier.h" 5 #include "components/ntp_snippets/user_classifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cfloat> 8 #include <cfloat>
9 #include <string> 9 #include <string>
10 10
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 273 }
274 274
275 if (GetEstimatedAvgTime(Metric::SUGGESTIONS_SHOWN) <= 275 if (GetEstimatedAvgTime(Metric::SUGGESTIONS_SHOWN) <=
276 active_consumer_scrolls_at_least_once_per_hours_) { 276 active_consumer_scrolls_at_least_once_per_hours_) {
277 return UserClass::ACTIVE_SUGGESTIONS_CONSUMER; 277 return UserClass::ACTIVE_SUGGESTIONS_CONSUMER;
278 } 278 }
279 279
280 return UserClass::ACTIVE_NTP_USER; 280 return UserClass::ACTIVE_NTP_USER;
281 } 281 }
282 282
283 std::string UserClassifier::GetUserClassNameForProto() const {
284 switch (GetUserClass()) {
285 case UserClass::RARE_NTP_USER:
286 return "RARE_NTP_USER";
287 case UserClass::ACTIVE_NTP_USER:
288 return "ACTIVE_NTP_USER";
289 case UserClass::ACTIVE_SUGGESTIONS_CONSUMER:
290 return "ACTIVE_SUGGESTIONS_CONSUMER";
291 }
292 NOTREACHED();
293 return std::string();
294 }
295
283 std::string UserClassifier::GetUserClassDescriptionForDebugging() const { 296 std::string UserClassifier::GetUserClassDescriptionForDebugging() const {
284 switch (GetUserClass()) { 297 switch (GetUserClass()) {
285 case UserClass::RARE_NTP_USER: 298 case UserClass::RARE_NTP_USER:
286 return "Rare user of the NTP"; 299 return "Rare user of the NTP";
287 case UserClass::ACTIVE_NTP_USER: 300 case UserClass::ACTIVE_NTP_USER:
288 return "Active user of the NTP"; 301 return "Active user of the NTP";
289 case UserClass::ACTIVE_SUGGESTIONS_CONSUMER: 302 case UserClass::ACTIVE_SUGGESTIONS_CONSUMER:
290 return "Active consumer of NTP suggestions"; 303 return "Active consumer of NTP suggestions";
291 } 304 }
292 NOTREACHED(); 305 NOTREACHED();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 377
365 void UserClassifier::SetMetricValue(Metric metric, double metric_value) { 378 void UserClassifier::SetMetricValue(Metric metric, double metric_value) {
366 pref_service_->SetDouble(kMetricKeys[static_cast<int>(metric)], metric_value); 379 pref_service_->SetDouble(kMetricKeys[static_cast<int>(metric)], metric_value);
367 } 380 }
368 381
369 void UserClassifier::ClearMetricValue(Metric metric) { 382 void UserClassifier::ClearMetricValue(Metric metric) {
370 pref_service_->ClearPref(kMetricKeys[static_cast<int>(metric)]); 383 pref_service_->ClearPref(kMetricKeys[static_cast<int>(metric)]);
371 } 384 }
372 385
373 } // namespace ntp_snippets 386 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698