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

Unified Diff: components/offline_pages/offline_page_model.cc

Issue 1307753002: [Offline pages] Adding capability to free up space used by Offline pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt 2 at the arm64 build issue Created 5 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/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 e89ae2add15ad730c64a7120bfad6fc60eb214cc..35e47f1e1f40d1fbfbd745154dba58647832e1aa 100644
--- a/components/offline_pages/offline_page_model.cc
+++ b/components/offline_pages/offline_page_model.cc
@@ -22,6 +22,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) {
@@ -141,6 +145,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 {

Powered by Google App Engine
This is Rietveld 408576698