diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-30 23:31:20 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-30 23:31:20 +0000 |
commit | 9ee940637811aecf53be849da9e5ea5e8956ee10 (patch) | |
tree | 5b1deb8e0ba5c2c1fb00100f985b283fd2081686 /webkit/appcache | |
parent | dce023d24ba0d30606658158e402479e30c4bf08 (diff) | |
download | chromium_src-9ee940637811aecf53be849da9e5ea5e8956ee10.zip chromium_src-9ee940637811aecf53be849da9e5ea5e8956ee10.tar.gz chromium_src-9ee940637811aecf53be849da9e5ea5e8956ee10.tar.bz2 |
Be sure to create and populate the meta table within the transaction that creates the rest of the schema.
BUG=none
TEST=existing tests apply
Review URL: http://codereview.chromium.org/518023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_database.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/webkit/appcache/appcache_database.cc b/webkit/appcache/appcache_database.cc index 256def1..fd2a9e9 100644 --- a/webkit/appcache/appcache_database.cc +++ b/webkit/appcache/appcache_database.cc @@ -769,6 +769,8 @@ 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) @@ -784,17 +786,13 @@ bool AppCacheDatabase::LazyOpen(bool create_if_needed) { } bool AppCacheDatabase::EnsureDatabaseVersion() { - bool did_create_meta_table = !sql::MetaTable::DoesTableExist(db_.get()); + if (!sql::MetaTable::DoesTableExist(db_.get())) + return CreateSchema(); - meta_table_.reset(new sql::MetaTable); if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion)) return false; - if (did_create_meta_table) - return CreateSchema(); - if (meta_table_->GetCompatibleVersionNumber() > kCurrentVersion) { - DCHECK(!did_create_meta_table); LOG(WARNING) << "AppCache database is too new."; return false; } @@ -803,6 +801,7 @@ bool AppCacheDatabase::EnsureDatabaseVersion() { return UpgradeSchema(); #ifndef NDEBUG + DCHECK(sql::MetaTable::DoesTableExist(db_.get())); for (int i = 0; i < kTableCount; ++i) { DCHECK(db_->DoesTableExist(kTables[i].table_name)); } @@ -816,6 +815,9 @@ bool AppCacheDatabase::CreateSchema() { if (!transaction.Begin()) return false; + if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion)) + return false; + for (int i = 0; i < kTableCount; ++i) { std::string sql("CREATE TABLE "); sql += kTables[i].table_name; |