summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_database.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-18 23:27:27 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-18 23:27:27 +0000
commit1ededee8107fd0e40e6371a5d35f7d2b451ca433 (patch)
treee180d5419e246f0f3bb69ba274d7abcf409741f9 /webkit/appcache/appcache_database.cc
parent5510cff445f38b167c8ca9c734e9311fd0505212 (diff)
downloadchromium_src-1ededee8107fd0e40e6371a5d35f7d2b451ca433.zip
chromium_src-1ededee8107fd0e40e6371a5d35f7d2b451ca433.tar.gz
chromium_src-1ededee8107fd0e40e6371a5d35f7d2b451ca433.tar.bz2
Put appcache storage on disk and add a means of disabling the appcache system when certain error conditions arise.
TEST=existing tests apply BUG=none Review URL: http://codereview.chromium.org/542071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_database.cc')
-rw-r--r--webkit/appcache/appcache_database.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/webkit/appcache/appcache_database.cc b/webkit/appcache/appcache_database.cc
index 8b9da0a..7182141 100644
--- a/webkit/appcache/appcache_database.cc
+++ b/webkit/appcache/appcache_database.cc
@@ -135,7 +135,7 @@ const int kIndexCount = ARRAYSIZE_UNSAFE(kIndexes);
namespace appcache {
AppCacheDatabase::AppCacheDatabase(const FilePath& path)
- : db_file_path_(path), has_open_error_(false), is_recreating_(false) {
+ : db_file_path_(path), is_disabled_(false), is_recreating_(false) {
}
AppCacheDatabase::~AppCacheDatabase() {
@@ -150,6 +150,13 @@ void AppCacheDatabase::CloseConnection() {
}
}
+void AppCacheDatabase::Disable() {
+ LOG(INFO) << "Disabling appcache database.";
+ is_disabled_ = true;
+ meta_table_.reset();
+ db_.reset();
+}
+
bool AppCacheDatabase::FindOriginsWithGroups(std::set<GURL>* origins) {
DCHECK(origins && origins->empty());
if (!LazyOpen(false))
@@ -902,7 +909,7 @@ bool AppCacheDatabase::LazyOpen(bool create_if_needed) {
// If we tried and failed once, don't try again in the same session
// to avoid creating an incoherent mess on disk.
- if (has_open_error_)
+ if (is_disabled_)
return false;
// Avoid creating a database at all if we can.
@@ -915,14 +922,19 @@ bool AppCacheDatabase::LazyOpen(bool create_if_needed) {
db_.reset(new sql::Connection);
meta_table_.reset(new sql::MetaTable);
- bool opened = use_in_memory_db ? db_->OpenInMemory()
- : db_->Open(db_file_path_);
- if (opened)
- db_->Preload();
+ bool opened = false;
+ if (use_in_memory_db) {
+ opened = db_->OpenInMemory();
+ } else if (!file_util::CreateDirectory(db_file_path_.DirName())) {
+ LOG(ERROR) << "Failed to create appcache directory.";
+ } else {
+ opened = db_->Open(db_file_path_);
+ if (opened)
+ db_->Preload();
+ }
+
if (!opened || !EnsureDatabaseVersion()) {
- has_open_error_ = true;
- meta_table_.reset();
- db_.reset();
+ Disable();
return false;
}