diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 20:39:01 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 20:39:01 +0000 |
commit | ca25209a0338e538e0199b07bbd5c2411f52e906 (patch) | |
tree | c4cb2c20599249e0c8a23b6424551280dfc6fd15 /webkit/appcache/appcache_storage_impl.cc | |
parent | 1ce698cdc9cec84dcd0eea437f266d5e0b217060 (diff) | |
download | chromium_src-ca25209a0338e538e0199b07bbd5c2411f52e906.zip chromium_src-ca25209a0338e538e0199b07bbd5c2411f52e906.tar.gz chromium_src-ca25209a0338e538e0199b07bbd5c2411f52e906.tar.bz2 |
Keep track of appcache creation and last access times.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/630009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_storage_impl.cc')
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index 0d908aa..6fd5486 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -268,6 +268,10 @@ void AppCacheStorageImpl::CacheLoadTask::Run() { database_->FindCache(cache_id_, &cache_record_) && database_->FindGroup(cache_record_.group_id, &group_record_) && FindRelatedCacheRecords(cache_id_); + + if (success_) + database_->UpdateGroupLastAccessTime(group_record_.group_id, + base::Time::Now()); } void AppCacheStorageImpl::CacheLoadTask::RunCompleted() { @@ -302,6 +306,10 @@ void AppCacheStorageImpl::GroupLoadTask::Run() { database_->FindGroupForManifestUrl(manifest_url_, &group_record_) && database_->FindCacheForGroup(group_record_.group_id, &cache_record_) && FindRelatedCacheRecords(cache_record_.cache_id); + + if (success_) + database_->UpdateGroupLastAccessTime(group_record_.group_id, + base::Time::Now()); } void AppCacheStorageImpl::GroupLoadTask::RunCompleted() { @@ -366,12 +374,17 @@ void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { AppCacheDatabase::GroupRecord existing_group; success_ = database_->FindGroup(group_record_.group_id, &existing_group); if (!success_) { + group_record_.creation_time = base::Time::Now(); + group_record_.last_access_time = base::Time::Now(); success_ = database_->InsertGroup(&group_record_); } else { DCHECK(group_record_.group_id == existing_group.group_id); DCHECK(group_record_.manifest_url == existing_group.manifest_url); DCHECK(group_record_.origin == existing_group.origin); + database_->UpdateGroupLastAccessTime(group_record_.group_id, + base::Time::Now()); + AppCacheDatabase::CacheRecord cache; if (database_->FindCacheForGroup(group_record_.group_id, &cache)) { // Get the set of response ids in the old cache. @@ -685,8 +698,10 @@ class AppCacheStorageImpl::GetDeletableResponseIdsTask : public DatabaseTask { public: GetDeletableResponseIdsTask(AppCacheStorageImpl* storage, int64 max_rowid) : DatabaseTask(storage), max_rowid_(max_rowid) {} + virtual void Run(); virtual void RunCompleted(); + int64 max_rowid_; std::vector<int64> response_ids_; }; @@ -731,6 +746,25 @@ void AppCacheStorageImpl::DeleteDeletableResponseIdsTask::Run() { database_->DeleteDeletableResponseIds(response_ids_); } +// UpdateGroupLastAccessTimeTask ------- + +class AppCacheStorageImpl::UpdateGroupLastAccessTimeTask + : public DatabaseTask { + public: + UpdateGroupLastAccessTimeTask( + AppCacheStorageImpl* storage, int64 group_id, base::Time time) + : DatabaseTask(storage), group_id_(group_id), last_access_time_(time) {} + + virtual void Run(); + + int64 group_id_; + base::Time last_access_time_; +}; + +void AppCacheStorageImpl::UpdateGroupLastAccessTimeTask::Run() { + database_->UpdateGroupLastAccessTime(group_id_, last_access_time_); +} + // AppCacheStorageImpl --------------------------------------------------- @@ -780,9 +814,20 @@ void AppCacheStorageImpl::Disable() { void AppCacheStorageImpl::LoadCache(int64 id, Delegate* delegate) { DCHECK(delegate); + if (is_disabled_) { + delegate->OnCacheLoaded(NULL, id); + return; + } + AppCache* cache = working_set_.GetCache(id); - if (cache || is_disabled_) { + if (cache) { delegate->OnCacheLoaded(cache, id); + if (cache->owning_group()) { + scoped_refptr<DatabaseTask> update_task = + new UpdateGroupLastAccessTimeTask( + this, cache->owning_group()->group_id(), base::Time::Now()); + update_task->Schedule(); + } return; } scoped_refptr<CacheLoadTask> task = GetPendingCacheLoadTask(id); @@ -799,9 +844,18 @@ void AppCacheStorageImpl::LoadCache(int64 id, Delegate* delegate) { void AppCacheStorageImpl::LoadOrCreateGroup( const GURL& manifest_url, Delegate* delegate) { DCHECK(delegate); + if (is_disabled_) { + delegate->OnGroupLoaded(NULL, manifest_url); + return; + } + AppCacheGroup* group = working_set_.GetGroup(manifest_url); - if (group || is_disabled_) { + if (group) { delegate->OnGroupLoaded(group, manifest_url); + scoped_refptr<DatabaseTask> update_task = + new UpdateGroupLastAccessTimeTask( + this, group->group_id(), base::Time::Now()); + update_task->Schedule(); return; } |