Chromium Code Reviews| Index: components/history/core/browser/expire_history_backend.cc |
| diff --git a/components/history/core/browser/expire_history_backend.cc b/components/history/core/browser/expire_history_backend.cc |
| index d57a60432afb85c3f74790c13d50d8e7865dd7b9..ecadbe1ec1d64d2fc475b16fdf49d0baf0a96066 100644 |
| --- a/components/history/core/browser/expire_history_backend.cc |
| +++ b/components/history/core/browser/expire_history_backend.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/bind.h" |
| #include "base/compiler_specific.h" |
| +#include "base/feature_list.h" |
| #include "base/files/file_enumerator.h" |
| #include "base/files/file_util.h" |
| #include "base/location.h" |
| @@ -114,8 +115,23 @@ const int kExpirationDelaySec = 30; |
| // iteration, so we want to wait longer before checking to avoid wasting CPU. |
| const int kExpirationEmptyDelayMin = 5; |
| +bool IsAnyURLBookmarked(HistoryBackendClient* backend_client, |
| + std::vector<GURL> urls) { |
|
pkotwicz
2017/07/10 05:23:28
Nit: const std::vector<GURL>& urls
jkrcal
2017/07/10 16:14:30
Ah, sure. Thanks!
|
| + for (const GURL& url : urls) { |
| + if (backend_client->IsBookmarked(url)) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| } // namespace |
| +namespace internal { |
| + |
| +const base::Feature kClearOldOnDemandFavicons{ |
| + "ClearOldOnDemandFavicons", base::FEATURE_DISABLED_BY_DEFAULT}; |
| + |
| +} // namespace internal |
| // ExpireHistoryBackend::DeleteEffects ---------------------------------------- |
| @@ -477,10 +493,37 @@ void ExpireHistoryBackend::DoExpireIteration() { |
| // creating a new task for future iterations. |
| if (more_to_expire) |
| work_queue_.push(reader); |
| + // Otherwise do a final clean-up - remove old favicons not bound to visits. |
| + else |
| + ClearOldOnDemandFavicons(GetCurrentExpirationTime()); |
| ScheduleExpire(); |
| } |
| +void ExpireHistoryBackend::ClearOldOnDemandFavicons( |
| + base::Time expiration_threshold) { |
| + if (!base::FeatureList::IsEnabled(internal::kClearOldOnDemandFavicons)) |
| + return; |
| + |
| + std::map<favicon_base::FaviconID, FaviconURLs> favicons = |
|
pkotwicz
2017/07/10 05:23:28
I would rather that you do one of:
1) Put the Favi
jkrcal
2017/07/10 16:14:30
I do understand the benefits of 2) or 3) but miss
pkotwicz
2017/07/10 19:50:19
I don't have a strong preference between the 3 opt
jkrcal
2017/07/11 13:19:34
Not really. Currently, I have conceptually
std::ma
|
| + thumb_db_->GetOldOnDemandFavicons(expiration_threshold); |
| + DeleteEffects effects; |
| + |
| + for (auto id_and_urls_pair : favicons) { |
| + favicon_base::FaviconID icon_id = id_and_urls_pair.first; |
| + const FaviconURLs& urls = id_and_urls_pair.second; |
| + |
| + if (backend_client_ && IsAnyURLBookmarked(backend_client_, urls.page_urls)) |
| + continue; |
| + |
| + thumb_db_->DeleteFavicon(icon_id); |
| + thumb_db_->DeleteIconMappingsForFaviconId(icon_id); |
| + effects.deleted_favicons.insert(urls.icon_url); |
| + } |
| + |
| + BroadcastNotifications(&effects, DELETION_EXPIRED); |
| +} |
| + |
| bool ExpireHistoryBackend::ExpireSomeOldHistory( |
| base::Time end_time, |
| const ExpiringVisitsReader* reader, |