Index: components/offline_pages/offline_page_model.cc |
diff --git a/components/offline_pages/offline_page_model.cc b/components/offline_pages/offline_page_model.cc |
index f658ff59edb666b582ee6ad2a98fe3606771d199..b06ebe58bc008c54eca6e7a969245f7778704c26 100644 |
--- a/components/offline_pages/offline_page_model.cc |
+++ b/components/offline_pages/offline_page_model.cc |
@@ -24,6 +24,10 @@ namespace offline_pages { |
namespace { |
+// Threshold for how old offline copy of a page should be before we offer to |
+// delete it to free up space. |
+const base::TimeDelta kPageCleanUpThreshold = base::TimeDelta::FromDays(30); |
+ |
SavePageResult ToSavePageResult(ArchiverResult archiver_result) { |
SavePageResult result; |
switch (archiver_result) { |
@@ -152,6 +156,17 @@ const std::vector<OfflinePageItem> OfflinePageModel::GetAllPages() const { |
return offline_pages; |
} |
+const std::vector<OfflinePageItem> OfflinePageModel::GetPagesToCleanUp() const { |
+ DCHECK(is_loaded_); |
+ std::vector<OfflinePageItem> offline_pages; |
+ base::Time now = base::Time::Now(); |
+ for (const auto& id_page_pair : offline_pages_) { |
+ if (now - id_page_pair.second.creation_time > kPageCleanUpThreshold) |
+ offline_pages.push_back(id_page_pair.second); |
+ } |
+ return offline_pages; |
+} |
+ |
bool OfflinePageModel::GetPageByBookmarkId( |
int64 bookmark_id, |
OfflinePageItem* offline_page) const { |