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

Unified Diff: components/offline_pages/offline_page_model.cc

Issue 1997543002: [Useless] Hooking up storage manager in page model. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shouldClean
Patch Set: changes related to another patch Created 4 years, 7 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
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b4e916fe123cc1e6faefca9786fa95e4ad78bef2..92d8c628cf791c41fb46dfcbc9034973d5681768 100644
--- a/components/offline_pages/offline_page_model.cc
+++ b/components/offline_pages/offline_page_model.cc
@@ -26,6 +26,8 @@
#include "url/gurl.h"
using ArchiverResult = offline_pages::OfflinePageArchiver::ArchiverResult;
+using ClearPagesCallback =
+ offline_pages::OfflinePageStorageManager::ClearPagesCallback;
namespace offline_pages {
@@ -508,6 +510,10 @@ void OfflinePageModel::CheckForExternalFileDeletion() {
weak_ptr_factory_.GetWeakPtr()));
}
+void OfflinePageModel::ExpirePages(const ClearPagesCallback& callback) {
+ storage_manager_->ClearPagesIfNeeded(callback);
+}
+
ClientPolicyController* OfflinePageModel::GetPolicyController() {
return policy_controller_.get();
}
@@ -628,6 +634,13 @@ void OfflinePageModel::OnLoadDone(
delayed_task.Run();
delayed_tasks_.clear();
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&OfflinePageModel::ExpirePages, weak_ptr_factory_.GetWeakPtr(),
+ base::Bind(&OfflinePageModel::OnExpiredPagesCleared,
+ weak_ptr_factory_.GetWeakPtr())),
+ base::TimeDelta::FromSeconds(20));
+
FOR_EACH_OBSERVER(Observer, observers_, OfflinePageModelLoaded(this));
CheckForExternalFileDeletion();
@@ -643,6 +656,11 @@ void OfflinePageModel::InformSavePageDone(const SavePageCallback& callback,
static_cast<int>(SavePageResult::RESULT_COUNT));
archive_manager_->GetStorageStats(
base::Bind(&ReportStorageHistogramsAfterSave));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&OfflinePageModel::ExpirePages, weak_ptr_factory_.GetWeakPtr(),
+ base::Bind(&OfflinePageModel::OnExpiredPagesCleared,
+ weak_ptr_factory_.GetWeakPtr())));
callback.Run(result, offline_id);
}
@@ -819,6 +837,13 @@ void OfflinePageModel::CacheLoadedData(
offline_pages_[offline_page.offline_id] = offline_page;
}
+void OfflinePageModel::OnExpiredPagesCleared(
+ const int expired_page_count,
+ OfflinePageStorageManager::ClearStorageResult result) {
+ // TODO(romax) Add something here.
+}
+
+// static
int64_t OfflinePageModel::GenerateOfflineId() {
return base::RandGenerator(std::numeric_limits<int64_t>::max()) + 1;
}
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698