summaryrefslogtreecommitdiffstats
path: root/webkit/database/database_tracker.cc
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-17 05:24:23 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-17 05:24:23 +0000
commit14645017bef26e8ac8eae6dafdbaa9ef679679fa (patch)
tree9086aa031b527bb148d2703dbcb371b1007a356a /webkit/database/database_tracker.cc
parentf9569168353af29fe8136e1b507851747dee807e (diff)
downloadchromium_src-14645017bef26e8ac8eae6dafdbaa9ef679679fa.zip
chromium_src-14645017bef26e8ac8eae6dafdbaa9ef679679fa.tar.gz
chromium_src-14645017bef26e8ac8eae6dafdbaa9ef679679fa.tar.bz2
Fix DatabaseTracker::LazyInit() to open the tracker database only
once. TEST=none BUG=none Review URL: http://codereview.chromium.org/397023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32155 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/database/database_tracker.cc')
-rw-r--r--webkit/database/database_tracker.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc
index 54e52d7..125ab38 100644
--- a/webkit/database/database_tracker.cc
+++ b/webkit/database/database_tracker.cc
@@ -110,6 +110,10 @@ FilePath DatabaseTracker::GetFullDBFilePath(
bool DatabaseTracker::LazyInit() {
if (!initialized_) {
+ DCHECK(!db_->is_open());
+ DCHECK(!databases_table_.get());
+ DCHECK(!meta_table_.get());
+
// If the tracker database exists, but it's corrupt or doesn't
// have a meta table, delete the database directory
const FilePath kTrackerDatabaseFullPath =
@@ -128,10 +132,15 @@ bool DatabaseTracker::LazyInit() {
initialized_ =
file_util::CreateDirectory(db_dir_) &&
- db_->Open(kTrackerDatabaseFullPath) &&
+ (db_->is_open() || db_->Open(kTrackerDatabaseFullPath)) &&
meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion) &&
(meta_table_->GetCompatibleVersionNumber() <= kCurrentVersion) &&
databases_table_->Init();
+ if (!initialized_) {
+ databases_table_.reset(NULL);
+ meta_table_.reset(NULL);
+ db_->Close();
+ }
}
return initialized_;
}