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

Unified Diff: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc

Issue 2804633003: Add base::FeatureParam<> struct (Closed)
Patch Set: Remove windows-incompatible constexpr Created 3 years, 8 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/bookmarks/bookmark_suggestions_provider.cc
diff --git a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
index 436e8bcee05591fd06b15d27983bbd40e3239477..d2cbee8a52f0c8dd0caed27a7f2a990056a14eee 100644
--- a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
+++ b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
@@ -33,13 +33,12 @@ namespace ntp_snippets {
namespace {
-const int kMaxBookmarks = 10;
-const int kMaxBookmarkAgeInDays = 42;
-
-const char* kMaxBookmarksParamName = "bookmarks_max_count";
-const char* kMaxBookmarkAgeInDaysParamName = "bookmarks_max_age_in_days";
-const char* kConsiderDesktopVisitsParamName =
- "bookmarks_consider_desktop_visits";
+constexpr base::FeatureParam<int> kMaxBookmarksParam{
+ &kBookmarkSuggestionsFeature, "bookmarks_max_count", 10};
+constexpr base::FeatureParam<int> kMaxBookmarkAgeInDaysParam{
+ &kBookmarkSuggestionsFeature, "bookmarks_max_age_in_days", 42};
+constexpr base::FeatureParam<bool> kConsiderDesktopVisitsParam{
+ &kBookmarkSuggestionsFeature, "bookmarks_consider_desktop_visits", false};
// TODO(treib,jkrcal): Remove this after M57.
const char kDeprecatedBookmarksFirstM54StartPref[] =
@@ -49,22 +48,7 @@ const char kDeprecatedBookmarksFirstM54StartPref[] =
// Note that bookmarks can be shown that do not meet this threshold.
base::Time GetThresholdTime() {
return base::Time::Now() -
- base::TimeDelta::FromDays(variations::GetVariationParamByFeatureAsInt(
- ntp_snippets::kBookmarkSuggestionsFeature,
- kMaxBookmarkAgeInDaysParamName, kMaxBookmarkAgeInDays));
-}
-
-// The maximum number of suggestions ever provided.
-int GetMaxCount() {
- return variations::GetVariationParamByFeatureAsInt(
- ntp_snippets::kBookmarkSuggestionsFeature, kMaxBookmarksParamName,
- kMaxBookmarks);
-}
-
-bool AreDesktopVisitsConsidered() {
- return variations::GetVariationParamByFeatureAsBool(
- ntp_snippets::kBookmarkSuggestionsFeature,
- kConsiderDesktopVisitsParamName, false);
+ base::TimeDelta::FromDays(kMaxBookmarkAgeInDaysParam.Get());
}
} // namespace
@@ -80,7 +64,8 @@ BookmarkSuggestionsProvider::BookmarkSuggestionsProvider(
bookmark_model_(bookmark_model),
fetch_requested_(false),
end_of_list_last_visit_date_(GetThresholdTime()),
- consider_bookmark_visits_from_desktop_(AreDesktopVisitsConsidered()) {
+ consider_bookmark_visits_from_desktop_(
+ kConsiderDesktopVisitsParam.Get()) {
observer->OnCategoryStatusChanged(this, provided_category_, category_status_);
pref_service->ClearPref(kDeprecatedBookmarksFirstM54StartPref);
bookmark_model_->AddObserver(this);
@@ -290,7 +275,7 @@ void BookmarkSuggestionsProvider::FetchBookmarksInternal() {
base::Time threshold_time = GetThresholdTime();
std::vector<const BookmarkNode*> bookmarks = GetRecentlyVisitedBookmarks(
- bookmark_model_, GetMaxCount(), threshold_time,
+ bookmark_model_, kMaxBookmarksParam.Get(), threshold_time,
consider_bookmark_visits_from_desktop_);
std::vector<ContentSuggestion> suggestions;

Powered by Google App Engine
This is Rietveld 408576698