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

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

Issue 2804633003: Add base::FeatureParam<> struct (Closed)
Patch Set: rebase Created 3 years, 4 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 1b9b50ff445b729db9f21185d5f3724968484596..ce2003a07ce247c91dd8605c1b6a424c839dfe9a 100644
--- a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
+++ b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
@@ -30,34 +30,18 @@ namespace ntp_snippets {
namespace {
-const int kMaxBookmarks = 10;
-const int kMaxBookmarkAgeInDays = 7;
-
-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", 7};
+constexpr base::FeatureParam<bool> kConsiderDesktopVisitsParam{
+ &kBookmarkSuggestionsFeature, "bookmarks_consider_desktop_visits", false};
Alexei Svitkine (slow) 2017/08/24 18:13:05 Seems you're changing logic as the previous code h
sfiera 2017/08/25 11:56:16 Fixed.
// Any bookmark created or visited after this time will be considered recent.
// 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, true);
+ base::TimeDelta::FromDays(kMaxBookmarkAgeInDaysParam.Get());
}
} // namespace
@@ -72,7 +56,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_);
bookmark_model_->AddObserver(this);
FetchBookmarks();
@@ -275,7 +260,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