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

Unified Diff: chrome/browser/ntp_snippets/download_suggestions_provider.cc

Issue 2683553003: [NTP::Downloads] Consider recently visited offline pages not outdated. (Closed)
Patch Set: Created 3 years, 10 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: chrome/browser/ntp_snippets/download_suggestions_provider.cc
diff --git a/chrome/browser/ntp_snippets/download_suggestions_provider.cc b/chrome/browser/ntp_snippets/download_suggestions_provider.cc
index a645129930f3cd7b55be77f8438b2031979ce0da..08cb77b9280cdb09af2b4aed10a0f31690e43ee9 100644
--- a/chrome/browser/ntp_snippets/download_suggestions_provider.cc
+++ b/chrome/browser/ntp_snippets/download_suggestions_provider.cc
@@ -521,10 +521,13 @@ void DownloadSuggestionsProvider::FetchAssetsDownloads() {
for (DownloadItem* item : all_downloads) {
std::string within_category_id =
GetAssetDownloadPerCategoryID(item->GetId());
+ // TODO(vitaliii): Provide proper last access time here once it is collected
+ // for asset downloads.
if (old_dismissed_ids.count(within_category_id)) {
retained_dismissed_ids.insert(within_category_id);
} else if (IsAssetDownloadCompleted(*item) &&
- !IsDownloadOutdated(GetAssetDownloadPublishedTime(*item))) {
+ !IsDownloadOutdated(GetAssetDownloadPublishedTime(*item),
+ base::Time())) {
cached_asset_downloads_.push_back(item);
// We may already observe this item and, therefore, we remove the
// observer first.
@@ -629,10 +632,13 @@ ContentSuggestion DownloadSuggestionsProvider::ConvertDownloadItem(
}
bool DownloadSuggestionsProvider::IsDownloadOutdated(
- const base::Time& published_time) {
- // TODO(vitaliii): Also consider last access time here once it is collected
- // for asset downloads.
- return published_time <
+ const base::Time& published_time,
+ const base::Time& last_visited_time) {
+ DCHECK(last_visited_time == base::Time() ||
+ last_visited_time >= published_time);
+ const base::Time& last_interaction_time =
+ (last_visited_time == base::Time() ? published_time : last_visited_time);
+ return last_interaction_time <
clock_->Now() - base::TimeDelta::FromHours(GetMaxDownloadAgeHours());
}
@@ -747,7 +753,8 @@ void DownloadSuggestionsProvider::UpdateOfflinePagesCache(
if (old_dismissed_ids.count(id_within_category)) {
retained_dismissed_ids.insert(id_within_category);
} else {
- if (!IsDownloadOutdated(GetOfflinePagePublishedTime(item))) {
+ if (!IsDownloadOutdated(GetOfflinePagePublishedTime(item),
+ item.last_access_time)) {
items.push_back(&item);
}
}

Powered by Google App Engine
This is Rietveld 408576698