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

Unified Diff: content/browser/appcache/appcache_storage_impl.cc

Issue 879393002: Expire appcaches that fail to update for "too long". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « content/browser/appcache/appcache_storage_impl.h ('k') | content/browser/appcache/appcache_update_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/appcache/appcache_storage_impl.cc
diff --git a/content/browser/appcache/appcache_storage_impl.cc b/content/browser/appcache/appcache_storage_impl.cc
index 7494f5a4666f3c8ee92037f6c3ac564f28918756..7f1ee9a3fcbfa269f15096c9de6f0a616d251f06 100644
--- a/content/browser/appcache/appcache_storage_impl.cc
+++ b/content/browser/appcache/appcache_storage_impl.cc
@@ -470,6 +470,10 @@ void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords(
storage_, group_record_.manifest_url,
group_record_.group_id);
group->get()->set_creation_time(group_record_.creation_time);
+ group->get()->set_last_full_update_check_time(
+ group_record_.last_full_update_check_time);
+ group->get()->set_first_evictable_error_time(
+ group_record_.first_evictable_error_time);
group->get()->AddCache(cache->get());
// TODO(michaeln): histogram is fishing for clues to crbug/95101
@@ -632,6 +636,10 @@ AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask(
group_record_.group_id = group->group_id();
group_record_.manifest_url = group->manifest_url();
group_record_.origin = group_record_.manifest_url.GetOrigin();
+ group_record_.last_full_update_check_time =
+ group->last_full_update_check_time();
+ group_record_.first_evictable_error_time =
+ group->first_evictable_error_time();
newest_cache->ToDatabaseRecords(
group,
&cache_record_, &entry_records_,
@@ -704,6 +712,11 @@ void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() {
database_->UpdateLastAccessTime(group_record_.group_id,
base::Time::Now());
+ database_->UpdateEvictionTimes(
+ group_record_.group_id,
+ group_record_.last_full_update_check_time,
+ group_record_.first_evictable_error_time);
+
AppCacheDatabase::CacheRecord cache;
if (database_->FindCacheForGroup(group_record_.group_id, &cache)) {
// Get the set of response ids in the old cache.
@@ -1355,6 +1368,39 @@ class AppCacheStorageImpl::CommitLastAccessTimesTask
~CommitLastAccessTimesTask() override {}
};
+// UpdateEvictionTimes -------
+
+class AppCacheStorageImpl::UpdateEvictionTimesTask
+ : public DatabaseTask {
+ public:
+ UpdateEvictionTimesTask(
+ AppCacheStorageImpl* storage, AppCacheGroup* group)
+ : DatabaseTask(storage), group_id_(group->group_id()),
+ last_full_update_check_time_(group->last_full_update_check_time()),
+ first_evictable_error_time_(group->first_evictable_error_time()) {
+ }
+
+ // DatabaseTask:
+ void Run() override;
+
+ protected:
+ ~UpdateEvictionTimesTask() override {}
+
+ private:
+ int64 group_id_;
+ base::Time last_full_update_check_time_;
+ base::Time first_evictable_error_time_;
+};
+
+void AppCacheStorageImpl::UpdateEvictionTimesTask::Run() {
+ tracked_objects::ScopedTracker tracking_profile(
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(
+ "AppCacheStorageImpl::UpdateEvictionTimes"));
+ database_->UpdateEvictionTimes(group_id_,
+ last_full_update_check_time_,
+ first_evictable_error_time_);
+}
+
// AppCacheStorageImpl ---------------------------------------------------
AppCacheStorageImpl::AppCacheStorageImpl(AppCacheServiceImpl* service)
@@ -1674,6 +1720,12 @@ void AppCacheStorageImpl::MakeGroupObsolete(AppCacheGroup* group,
task->Schedule();
}
+void AppCacheStorageImpl::StoreEvictionTimes(AppCacheGroup* group) {
+ scoped_refptr<UpdateEvictionTimesTask> task(
+ new UpdateEvictionTimesTask(this, group));
+ task->Schedule();
+}
+
AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader(
const GURL& manifest_url, int64 group_id, int64 response_id) {
return new AppCacheResponseReader(response_id, group_id, disk_cache());
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.h ('k') | content/browser/appcache/appcache_update_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698