From 14645017bef26e8ac8eae6dafdbaa9ef679679fa Mon Sep 17 00:00:00 2001 From: "dumi@chromium.org" Date: Tue, 17 Nov 2009 05:24:23 +0000 Subject: 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 --- webkit/database/database_tracker.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'webkit') 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_; } -- cgit v1.1