| Index: gears/base/common/permissions_db.cc |
| =================================================================== |
| --- gears/base/common/permissions_db.cc (revision 1639) |
| +++ gears/base/common/permissions_db.cc (working copy) |
| @@ -32,7 +32,7 @@ |
| static const char16 *kVersionTableName = STRING16(L"VersionInfo"); |
| static const char16 *kVersionKeyName = STRING16(L"Version"); |
| static const char16 *kAccessTableName = STRING16(L"Access"); |
| -static const int kCurrentVersion = 7; |
| +static const int kCurrentVersion = 8; |
| static const int kOldestUpgradeableVersion = 1; |
| @@ -71,7 +71,8 @@ |
| : version_table_(&db_, kVersionTableName), |
| access_table_(&db_, kAccessTableName), |
| shortcut_table_(&db_), |
| - database_name_table_(&db_) { |
| + database_name_table_(&db_), |
| + database2_metadata_table_(&db_) { |
| } |
| @@ -116,7 +117,7 @@ |
| return false; |
| } |
| } else { |
| - if (!UpgradeToVersion7()) { |
| + if (!UpgradeToVersion8()) { |
| return false; |
| } |
| } |
| @@ -310,6 +311,10 @@ |
| basename); |
| } |
| +Database2Metadata &PermissionsDB::GetDatabase2Metadata() { |
| + return database2_metadata_table_; |
| +} |
| + |
| bool PermissionsDB::CreateDatabase() { |
| ASSERT_SINGLE_THREAD(); |
| @@ -531,3 +536,36 @@ |
| return transaction.Commit(); |
| } |
| + |
| +bool PermissionsDB::UpgradeToVersion8() { |
| + SQLTransaction transaction(&db_, "PermissionsDB::UpgradeToVersion8"); |
| + if (!transaction.Begin()) { |
| + return false; |
| + } |
| + |
| + int version = 0; |
| + version_table_.GetInt(kVersionKeyName, &version); |
| + |
| + if (version < 7) { |
| + if (!UpgradeToVersion7()) { |
| + return false; |
| + } |
| + version_table_.GetInt(kVersionKeyName, &version); |
| + } |
| + |
| + if (version != 7) { |
| + LOG(("PermissionsDB::UpgradeToVersion8 unexpected version: %d", version)); |
| + return false; |
| + } |
| + |
| + // Adding new database2_metadata_table_ |
| + if (!database2_metadata_table_.CreateTableVersion8()) { |
| + return false; |
| + } |
| + |
| + if (!version_table_.SetInt(kVersionKeyName, 8)) { |
| + return false; |
| + } |
| + |
| + return transaction.Commit(); |
| +} |