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

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: Fixing a crash from a second round of manual pass 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..b45bfbaec20e30f894c0d44b0ecb8f9084fc931b 100644
--- a/components/offline_pages/offline_page_model.cc
+++ b/components/offline_pages/offline_page_model.cc
@@ -22,6 +22,8 @@ namespace offline_pages {
namespace {
+const base::TimeDelta OLD_PAGE_INTERVAL = base::TimeDelta::FromDays(30);
jianli 2015/08/21 21:06:27 We should use C++ style constant here. Also it is
fgorski 2015/08/21 22:09:39 Done.
+
SavePageResult ToSavePageResult(ArchiverResult archiver_result) {
SavePageResult result;
switch (archiver_result) {
@@ -141,6 +143,16 @@ 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;
+ for (const auto& id_page : offline_pages_) {
+ if (base::Time::Now() - id_page.second.creation_time > OLD_PAGE_INTERVAL)
+ offline_pages.push_back(id_page.second);
jianli 2015/08/21 21:06:27 nit: it is better to store Now time before for loo
fgorski 2015/08/21 22:09:39 Done.
+ }
+ return offline_pages;
+}
+
bool OfflinePageModel::GetPageByBookmarkId(
int64 bookmark_id,
OfflinePageItem* offline_page) const {

Powered by Google App Engine
This is Rietveld 408576698