diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-01 19:40:21 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-01 19:40:21 +0000 |
commit | c4925d5805396a5e15ae4297b6173b5ed2610a93 (patch) | |
tree | e821154e001de7b637657f8f5b096000cb482be2 /webkit/appcache/appcache_storage_impl.cc | |
parent | 93330676dddfffc05a070df8e7b7e91fd5801ca2 (diff) | |
download | chromium_src-c4925d5805396a5e15ae4297b6173b5ed2610a93.zip chromium_src-c4925d5805396a5e15ae4297b6173b5ed2610a93.tar.gz chromium_src-c4925d5805396a5e15ae4297b6173b5ed2610a93.tar.bz2 |
AppCache: If we can't read the existing data delete it and start over.
BUG=38360
TEST=some unit tests apply, but no new tests for this specifically
Review URL: http://codereview.chromium.org/1562005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_storage_impl.cc')
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index d700d24c..10724eb 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -17,11 +17,19 @@ #include "webkit/appcache/appcache_database.h" #include "webkit/appcache/appcache_entry.h" #include "webkit/appcache/appcache_group.h" +#include "webkit/appcache/appcache_histograms.h" #include "webkit/appcache/appcache_policy.h" #include "webkit/appcache/appcache_response.h" #include "webkit/appcache/appcache_service.h" #include "webkit/appcache/appcache_thread.h" +namespace { +// Helper with no return value for use with NewRunnableFunction. +void DeleteDirectory(const FilePath& path) { + file_util::Delete(path, true); +} +} + namespace appcache { static const char kAppCacheDatabaseName[] = "Index"; @@ -1275,9 +1283,19 @@ AppCacheDiskCache* AppCacheStorageImpl::disk_cache() { void AppCacheStorageImpl::OnDiskCacheInitialized(int rv) { if (rv != net::OK) { - // TODO(michaeln): We're unable to open the disk cache, how - // do we recover from this error? + LOG(ERROR) << "Failed to open the appcache diskcache."; + AppCacheHistograms::CountInitResult(AppCacheHistograms::DISK_CACHE_ERROR); + + // We're unable to open the disk cache, this is a fatal error that we can't + // really recover from. We handle it by disabling the appcache for this + // browser session and deleting the directory on disk. The next browser + // session should start with a clean slate. Disable(); + if (!is_incognito_) { + LOG(INFO) << "Deleting existing appcache data and starting over."; + AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE, + NewRunnableFunction(DeleteDirectory, cache_directory_)); + } } } |