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

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: Converting jlongarray to std::vector<int64> 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 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 {
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | components/offline_pages/offline_page_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698