diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 01:26:10 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 01:26:10 +0000 |
commit | 4f32303e4491c3b2358825e0b26f8c5db3b28b33 (patch) | |
tree | eeb15549ae8540ddc6e1be0a5400247d5f771844 /webkit/appcache/appcache_storage_impl.cc | |
parent | e07dfdab975039ea0719e8dc7e7f5faaf0887a91 (diff) | |
download | chromium_src-4f32303e4491c3b2358825e0b26f8c5db3b28b33.zip chromium_src-4f32303e4491c3b2358825e0b26f8c5db3b28b33.tar.gz chromium_src-4f32303e4491c3b2358825e0b26f8c5db3b28b33.tar.bz2 |
Undo in memory changes made by an update job if the commit to disk fails. Provide a more clear error message when the commit fails due to exceeding the quota.
TEST=MasterEntryFailStoreNewestCacheTest
BUG=50985
Review URL: http://codereview.chromium.org/2836075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_storage_impl.cc')
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index 3f9ba1a..c715863 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -401,13 +401,14 @@ class AppCacheStorageImpl::StoreGroupAndCacheTask : public StoreOrLoadTask { scoped_refptr<AppCacheGroup> group_; scoped_refptr<AppCache> cache_; bool success_; + bool would_exceed_quota_; std::vector<int64> newly_deletable_response_ids_; }; AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( AppCacheStorageImpl* storage, AppCacheGroup* group, AppCache* newest_cache) : StoreOrLoadTask(storage), group_(group), cache_(newest_cache), - success_(false) { + success_(false), would_exceed_quota_(false) { group_record_.group_id = group->group_id(); group_record_.manifest_url = group->manifest_url(); group_record_.origin = group_record_.manifest_url.GetOrigin(); @@ -479,10 +480,19 @@ void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { database_->InsertCache(&cache_record_) && database_->InsertEntryRecords(entry_records_) && database_->InsertFallbackNameSpaceRecords(fallback_namespace_records_)&& - database_->InsertOnlineWhiteListRecords(online_whitelist_records_) && - (database_->GetOriginUsage(group_record_.origin) <= - database_->GetOriginQuota(group_record_.origin)) && - transaction.Commit(); + database_->InsertOnlineWhiteListRecords(online_whitelist_records_); + + if (!success_) + return; + + if (database_->GetOriginUsage(group_record_.origin) > + database_->GetOriginQuota(group_record_.origin)) { + would_exceed_quota_ = true; + success_ = false; + return; + } + + success_ = transaction.Commit(); } void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() { @@ -496,7 +506,8 @@ void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() { group_->AddNewlyDeletableResponseIds(&newly_deletable_response_ids_); } FOR_EACH_DELEGATE(delegates_, - OnGroupAndNewestCacheStored(group_, cache_, success_)); + OnGroupAndNewestCacheStored(group_, cache_, success_, + would_exceed_quota_)); group_ = NULL; cache_ = NULL; } |