| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/webdata/web_database.h" | 5 #include "chrome/browser/webdata/web_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" | 9 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
| 10 #include "chrome/browser/webdata/autofill_table.h" | 10 #include "chrome/browser/webdata/autofill_table.h" |
| 11 #include "chrome/browser/webdata/keyword_table.h" | 11 #include "chrome/browser/webdata/keyword_table.h" |
| 12 #include "chrome/browser/webdata/logins_table.h" | 12 #include "chrome/browser/webdata/logins_table.h" |
| 13 #include "chrome/browser/webdata/token_service_table.h" | 13 #include "chrome/browser/webdata/token_service_table.h" |
| 14 #include "chrome/browser/webdata/web_apps_table.h" | 14 #include "chrome/browser/webdata/web_apps_table.h" |
| 15 #include "chrome/browser/webdata/web_intents_table.h" | 15 #include "chrome/browser/webdata/web_intents_table.h" |
| 16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "sql/statement.h" | 17 #include "sql/statement.h" |
| 18 #include "sql/transaction.h" | 18 #include "sql/transaction.h" |
| 19 | 19 |
| 20 // Current version number. Note: when changing the current version number, | 20 // Current version number. Note: when changing the current version number, |
| 21 // corresponding changes must happen in the unit tests, and new migration test | 21 // corresponding changes must happen in the unit tests, and new migration test |
| 22 // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. | 22 // added. See |WebDatabaseMigrationTest::kCurrentTestedVersionNumber|. |
| 23 // static | 23 // static |
| 24 const int WebDatabase::kCurrentVersionNumber = 46; | 24 const int WebDatabase::kCurrentVersionNumber = 47; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const int kCompatibleVersionNumber = 46; | 28 const int kCompatibleVersionNumber = 47; |
| 29 | 29 |
| 30 // Change the version number and possibly the compatibility version of | 30 // Change the version number and possibly the compatibility version of |
| 31 // |meta_table_|. | 31 // |meta_table_|. |
| 32 void ChangeVersion(sql::MetaTable* meta_table, | 32 void ChangeVersion(sql::MetaTable* meta_table, |
| 33 int version_num, | 33 int version_num, |
| 34 bool update_compatible_version_num) { | 34 bool update_compatible_version_num) { |
| 35 meta_table->SetVersionNumber(version_num); | 35 meta_table->SetVersionNumber(version_num); |
| 36 if (update_compatible_version_num) { | 36 if (update_compatible_version_num) { |
| 37 meta_table->SetCompatibleVersionNumber( | 37 meta_table->SetCompatibleVersionNumber( |
| 38 std::min(version_num, kCompatibleVersionNumber)); | 38 std::min(version_num, kCompatibleVersionNumber)); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // FALL THROUGH | 232 // FALL THROUGH |
| 233 | 233 |
| 234 case 27: | 234 case 27: |
| 235 if (!keyword_table_->MigrateToVersion28SupportsInstantColumn()) | 235 if (!keyword_table_->MigrateToVersion28SupportsInstantColumn()) |
| 236 return FailedMigrationTo(28); | 236 return FailedMigrationTo(28); |
| 237 | 237 |
| 238 ChangeVersion(&meta_table_, 28, true); | 238 ChangeVersion(&meta_table_, 28, true); |
| 239 // FALL THROUGH | 239 // FALL THROUGH |
| 240 | 240 |
| 241 case 28: | 241 case 28: |
| 242 if (!keyword_table_->MigrateToVersion29InstantUrlToSupportsInstant()) | 242 if (!keyword_table_->MigrateToVersion29InstantURLToSupportsInstant()) |
| 243 return FailedMigrationTo(29); | 243 return FailedMigrationTo(29); |
| 244 | 244 |
| 245 ChangeVersion(&meta_table_, 29, true); | 245 ChangeVersion(&meta_table_, 29, true); |
| 246 // FALL THROUGH | 246 // FALL THROUGH |
| 247 | 247 |
| 248 case 29: | 248 case 29: |
| 249 if (!autofill_table_->MigrateToVersion30AddDateModifed()) | 249 if (!autofill_table_->MigrateToVersion30AddDateModifed()) |
| 250 return FailedMigrationTo(30); | 250 return FailedMigrationTo(30); |
| 251 | 251 |
| 252 ChangeVersion(&meta_table_, 30, true); | 252 ChangeVersion(&meta_table_, 30, true); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 ChangeVersion(&meta_table_, 45, true); | 336 ChangeVersion(&meta_table_, 45, true); |
| 337 // FALL THROUGH | 337 // FALL THROUGH |
| 338 | 338 |
| 339 case 45: | 339 case 45: |
| 340 if (!web_intents_table_->MigrateToVersion46AddSchemeColumn()) | 340 if (!web_intents_table_->MigrateToVersion46AddSchemeColumn()) |
| 341 return FailedMigrationTo(46); | 341 return FailedMigrationTo(46); |
| 342 | 342 |
| 343 ChangeVersion(&meta_table_, 46, true); | 343 ChangeVersion(&meta_table_, 46, true); |
| 344 // FALL THROUGH | 344 // FALL THROUGH |
| 345 | 345 |
| 346 case 46: |
| 347 if (!keyword_table_->MigrateToVersion47AddAlternateURLsColumn()) |
| 348 return FailedMigrationTo(47); |
| 349 |
| 350 ChangeVersion(&meta_table_, 47, true); |
| 351 // FALL THROUGH |
| 352 |
| 346 // Add successive versions here. Each should set the version number and | 353 // Add successive versions here. Each should set the version number and |
| 347 // compatible version number as appropriate, then fall through to the next | 354 // compatible version number as appropriate, then fall through to the next |
| 348 // case. | 355 // case. |
| 349 | 356 |
| 350 case kCurrentVersionNumber: | 357 case kCurrentVersionNumber: |
| 351 // No migration needed. | 358 // No migration needed. |
| 352 return sql::INIT_OK; | 359 return sql::INIT_OK; |
| 353 } | 360 } |
| 354 } | 361 } |
| OLD | NEW |